Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/issue 1187 #1314

Merged
merged 4 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/MultilingualInput/multilingualInput.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
}

.bilingual-child-wrapper .literal-badge {
top: 11px;
right: 3px;
top: 9px;
right: -3px;
}

.bilingual-child-wrapper .ant-form-item {
Expand Down
4 changes: 2 additions & 2 deletions src/constants/formFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const formFieldValue = [
<CreateMultiLingualFormItems
calendarContentLanguage={calendarContentLanguage}
form={form}
name={name}
name={Array.isArray(name) ? name[0] : name}
data={data}
entityId={entityId}
validations={validations}
Expand Down Expand Up @@ -524,7 +524,7 @@ export const formFieldValue = [
data={data}
form={form}
calendarContentLanguage={calendarContentLanguage}
name={name}
name={Array.isArray(name) ? name[0] : name}
entityId={entityId}
placeholder={placeholder}
descriptionMinimumWordCount={descriptionMinimumWordCount}
Expand Down
6 changes: 3 additions & 3 deletions src/pages/Dashboard/AddEvent/AddEvent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ function AddEvent() {
form
.validateFields([
...new Set([
'name',
...(calendarContentLanguage.map((language) => ['name', `${contentLanguageKeyMap[language]}`]) ?? []),
'datePicker',
'dateRangePicker',
'datePickerWrapper',
Expand Down Expand Up @@ -1834,7 +1834,7 @@ function AddEvent() {
break;
case eventFormRequiredFieldNames.DESCRIPTION:
calendarContentLanguage.forEach((language) => {
publishValidateFields.push(['editor', [contentLanguageKeyMap[language]]]);
publishValidateFields.push(['editor', contentLanguageKeyMap[language]]);
});
setDescriptionMinimumWordCount(
requiredField?.rule?.minimumWordCount ? Number(requiredField?.rule?.minimumWordCount) : 1,
Expand Down Expand Up @@ -2955,7 +2955,7 @@ function AddEvent() {
data={eventData?.description}
form={form}
calendarContentLanguage={calendarContentLanguage}
name={['editor']}
name={'editor'}
required={requiredFieldNames?.includes(eventFormRequiredFieldNames?.DESCRIPTION)}
placeholder={placeHolderCollectionCreator({
calendarContentLanguage,
Expand Down
63 changes: 35 additions & 28 deletions src/pages/Dashboard/CreateNewPlace/CreateNewPlace.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -715,20 +715,6 @@ function CreateNewPlace() {
const handleSelect = (address) => {
geocodeByAddress(address)
.then((results) => {
form.setFieldsValue({
address: results[0]?.formatted_address,
addressCountry: results[0].address_components.find((item) => item.types.includes('country'))?.long_name,
addressCountryEn: results[0].address_components.find((item) => item.types.includes('country'))?.long_name,
addressLocality: results[0].address_components.find((item) => item.types.includes('locality'))?.long_name,
addressLocalityEn: results[0].address_components.find((item) => item.types.includes('locality'))?.long_name,
addressRegion: results[0].address_components.find((item) =>
item.types.includes('administrative_area_level_1'),
)?.short_name,
addressRegionEn: results[0].address_components.find((item) =>
item.types.includes('administrative_area_level_1'),
)?.short_name,
postalCode: results[0].address_components.find((item) => item.types.includes('postal_code'))?.long_name,
});
let streetNumber =
results[0].address_components.find((item) => item.types.includes('street_number'))?.long_name ?? null;
let streetName = results[0].address_components.find((item) => item.types.includes('route'))?.long_name ?? null;
Expand All @@ -737,10 +723,31 @@ function CreateNewPlace() {
else if (streetNumber && !streetName) streetAddress = streetNumber;
else if (!streetNumber && streetName) streetAddress = streetName;
else if (!streetNumber && !streetName) streetAddress = null;
form.setFieldsValue({
streetAddress: streetAddress,
streetAddressEn: streetAddress,

calendarContentLanguage.forEach((language) => {
const langKey = contentLanguageKeyMap[language];
form.setFieldValue([formFieldNames.STREET_ADDRESS, langKey], streetAddress);
form.setFieldValue(
[formFieldNames.COUNTRY, langKey],
results[0].address_components.find((item) => item.types.includes('country'))?.long_name,
);

form.setFieldValue(
[formFieldNames.CITY, langKey],
results[0].address_components.find((item) => item.types.includes('locality'))?.long_name,
);
form.setFieldValue(
[formFieldNames.PROVINCE, langKey],
results[0].address_components.find((item) => item.types.includes('administrative_area_level_1'))
?.short_name,
);
});

form.setFieldValue(
formFieldNames.POSTAL_CODE,
results[0].address_components.find((item) => item.types.includes('postal_code'))?.long_name,
);

return getLatLng(results[0]);
})
.then((latLng) => {
Expand Down Expand Up @@ -1161,7 +1168,7 @@ function CreateNewPlace() {
break;
case placeFormRequiredFieldNames.DESCRIPTION:
calendarContentLanguage.forEach((language) => {
publishValidateFields.push([formFieldNames.DESCRIPTION, [contentLanguageKeyMap[language]]]);
publishValidateFields.push([formFieldNames.DESCRIPTION, contentLanguageKeyMap[language]]);
});
// setDescriptionMinimumWordCount(Number(requiredField?.rule?.minimumWordCount));
break;
Expand All @@ -1170,7 +1177,7 @@ function CreateNewPlace() {
break;
case placeFormRequiredFieldNames.STREET_ADDRESS:
calendarContentLanguage.forEach((language) => {
publishValidateFields.push([formFieldNames.STREET_ADDRESS, [contentLanguageKeyMap[language]]]);
publishValidateFields.push([formFieldNames.STREET_ADDRESS, contentLanguageKeyMap[language]]);
});
break;
case placeFormRequiredFieldNames.DISAMBIGUATING_DESCRIPTION:
Expand Down Expand Up @@ -1231,7 +1238,7 @@ function CreateNewPlace() {
} else if (newEntityName) {
calendarContentLanguage.forEach((language) => {
const langKey = contentLanguageKeyMap[language];
form.setFieldValue([[formFieldNames.NAME], `${langKey}`], newEntityName);
form.setFieldValue([formFieldNames.NAME, `${langKey}`], newEntityName);
});
}
}, []);
Expand Down Expand Up @@ -1392,7 +1399,7 @@ function CreateNewPlace() {
entityId={placeId}
calendarContentLanguage={calendarContentLanguage}
form={form}
name={[formFieldNames.NAME]}
name={formFieldNames.NAME}
data={
placeData?.name
? placeData?.name
Expand Down Expand Up @@ -1496,7 +1503,7 @@ function CreateNewPlace() {
entityId={placeId}
calendarContentLanguage={calendarContentLanguage}
form={form}
name={[formFieldNames.DISAMBIGUATING_DESCRIPTION]}
name={formFieldNames.DISAMBIGUATING_DESCRIPTION}
data={
placeData?.disambiguatingDescription
? placeData?.disambiguatingDescription
Expand Down Expand Up @@ -1543,7 +1550,7 @@ function CreateNewPlace() {
}
form={form}
calendarContentLanguage={calendarContentLanguage}
name={[formFieldNames.DESCRIPTION]}
name={formFieldNames.DESCRIPTION}
placeholder={placeHolderCollectionCreator({
calendarContentLanguage,
t,
Expand Down Expand Up @@ -1778,7 +1785,7 @@ function CreateNewPlace() {
entityId={placeId}
calendarContentLanguage={calendarContentLanguage}
form={form}
name={[formFieldNames.STREET_ADDRESS]}
name={formFieldNames.STREET_ADDRESS}
data={
placeData?.address?.streetAddress
? placeData?.address?.streetAddress
Expand Down Expand Up @@ -1816,7 +1823,7 @@ function CreateNewPlace() {
entityId={placeId}
calendarContentLanguage={calendarContentLanguage}
form={form}
name={[formFieldNames.CITY]}
name={formFieldNames.CITY}
data={
placeData?.address?.addressLocality
? placeData?.address?.addressLocality
Expand Down Expand Up @@ -1884,7 +1891,7 @@ function CreateNewPlace() {
entityId={placeId}
calendarContentLanguage={calendarContentLanguage}
form={form}
name={[formFieldNames.PROVINCE]}
name={formFieldNames.PROVINCE}
data={
placeData?.address?.addressRegion
? placeData?.address?.addressRegion
Expand Down Expand Up @@ -1924,7 +1931,7 @@ function CreateNewPlace() {
entityId={placeId}
calendarContentLanguage={calendarContentLanguage}
form={form}
name={[formFieldNames.COUNTRY]}
name={formFieldNames.COUNTRY}
data={
placeData?.address?.addressCountry
? placeData?.address?.addressCountry
Expand Down Expand Up @@ -2625,7 +2632,7 @@ function CreateNewPlace() {
entityId={placeId}
calendarContentLanguage={calendarContentLanguage}
form={form}
name={[formFieldNames.ACCESSIBILITY_NOTE]}
name={formFieldNames.ACCESSIBILITY_NOTE}
data={placeData?.accessibilityNote}
required={false}
validations={t('common.validations.informationRequired')}
Expand Down