debug error on profile edit (in server)

This commit is contained in:
Nuwan 2024-03-11 16:38:22 +05:30
parent 9164a1058d
commit 95008f49e6
1 changed files with 24 additions and 24 deletions

View File

@ -65,11 +65,10 @@ function JKEditProfile() {
setCurrentUserLoaded(true); setCurrentUserLoaded(true);
fetchCurentUser().then(data => { fetchCurentUser().then(data => {
console.log("userData", data) console.log("userData", data)
//setUserData(data);
updateUserData(data); updateUserData(data);
fetchInstruments(); fetchInstruments();
fetchGenres(); fetchGenres();
//fetchCountries(); fetchCountries();
}); });
} }
}, [currentUser]); }, [currentUser]);
@ -329,6 +328,7 @@ function JKEditProfile() {
}; };
const handleRegionChange = selectedOpt => { const handleRegionChange = selectedOpt => {
if (!selectedOpt) return;
if (skipRegionChange.current) { if (skipRegionChange.current) {
skipRegionChange.current = false; skipRegionChange.current = false;
return; return;
@ -344,6 +344,7 @@ function JKEditProfile() {
}; };
const handleCityChange = selectedOpt => { const handleCityChange = selectedOpt => {
if (!selectedOpt) return;
const city = selectedOpt.value; const city = selectedOpt.value;
setValue('city', city); setValue('city', city);
handleChange(); handleChange();
@ -464,31 +465,30 @@ function JKEditProfile() {
<FormGroup> <FormGroup>
<Label for="country">{t('country')}</Label> <Label for="country">{t('country')}</Label>
{countries.length > 0 && ( {countries.length > 0 && (
<div></div> <Controller
// <Controller name="country"
// name="country" control={control}
// control={control} render={({ field: { onChange, value } }) => {
// render={({ field: { onChange, value } }) => { const country = countries.find(country => country.countrycode === value);
// const country = countries.find(country => country.countrycode === value); return (
// return ( <Select
// <Select data-testid="countrySelect"
// data-testid="countrySelect" value={{ value: country.countrycode, label: country.countryname }}
// value={{ value: country.countrycode, label: country.countryname }} onChange={handleCountryChange}
// onChange={handleCountryChange} options={countries.map(country => {
// options={countries.map(country => { return { value: country.countrycode, label: country.countryname };
// return { value: country.countrycode, label: country.countryname }; })}
// })} />
// /> );
// ); }}
// }} />
// />
)} )}
</FormGroup> </FormGroup>
</Col> </Col>
<Col md={4}> <Col md={4}>
<FormGroup> <FormGroup>
<Label for="state">{t('state')}</Label> <Label for="state">{t('state')}</Label>
{regions.length > 0 && (
<Controller <Controller
name="state" name="state"
control={control} control={control}
@ -496,17 +496,17 @@ function JKEditProfile() {
const region = regions.find(region => region.region === value); const region = regions.find(region => region.region === value);
return ( return (
<Select <Select
value={{ value: region.region, label: region.region }} value={{ value: region?.region, label: region?.region }}
ref={regionRef} ref={regionRef}
onChange={handleRegionChange} onChange={handleRegionChange}
options={regions.map(region => { options={regions.map(region => {
return { value: region.region, label: region.region }; return { value: region?.region, label: region?.region };
})} })}
/> />
); );
}} }}
/> />
)}
</FormGroup> </FormGroup>
</Col> </Col>
<Col md={4}> <Col md={4}>