I've a problem within my CartScreen. It's about chosing payment method. It worked everything fine all the time and today i open the cartscreen and i got a lot of error but if I remember correctly i didn't touch this component for quite some time...
Here i call the component in my CartScreen:
const [sliderPaymentValue, setSliderPaymentValue] = useState('');
<PaymentChoice
setState={setSliderPaymentValue}
/>
And this is my PaymentChoice component:
import React, { useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { systemSettings } from '../../../redux/actions/systemSettingsAction';
import './optionPicker.css';
const PaymentChoice = ({ setState }) => {
const dispatch = useDispatch();
useEffect(() => {
dispatch(systemSettings());
}, []);
const settingsstate = useSelector((state) => state.systemSettingsReducer);
const { settings } = settingsstate;
//console.log(settings[0]?.payments);
function handleChange(event) {
setState(event.target.value);
}
return (
<div className='border-1 border-red-500 flex justify-center'>
{settings[0]?.payments.map((payment) => {
return (
<div>
<div className=''>
<input
checked={settings[0]?.payments.length === 1 ? 'checked' : null}
type='radio'
id={payment.value}
name='payment'
value={payment.value}
onChange={
settings[0]?.payments.length === 1
? setState(payment.value)
: handleChange
}
></input>
<label className='inline-block w-32' for={payment.value}>
<img
src={`/images/${payment.value}.png`}
alt={`${payment.value}.png`}
className='max-h-[50px] mx-auto'
/>
<div className='text-center'>{payment.label}</div>
</label>
</div>
</div>
);
})}
</div>
);
};
export default PaymentChoice;
Edit: If i use bargeld (german word for cash money) it works (This is one of 2 options you can choose from PaymentChoice one has "paypal" and the other "bargeld"
const [sliderPaymentValue, setSliderPaymentValue] = useState('bargeld');