diff --git a/src/components/Modal/QuickCreatePlace/QuickCreatePlace.jsx b/src/components/Modal/QuickCreatePlace/QuickCreatePlace.jsx index 5f5f594a2..8566bdbbe 100644 --- a/src/components/Modal/QuickCreatePlace/QuickCreatePlace.jsx +++ b/src/components/Modal/QuickCreatePlace/QuickCreatePlace.jsx @@ -101,15 +101,15 @@ function QuickCreatePlace(props) { const [address, setAddress] = useState(''); const [dropdownOpen, setDropdownOpen] = useState(false); - const handleChange = (address) => { - if (address === '') setDropdownOpen(false); + const handleChange = (value) => { + if (value === '') setDropdownOpen(false); else setDropdownOpen(true); - setAddress(address); }; const handleSelect = (address) => { geocodeByAddress(address) .then((results) => { + setAddress(results[0]?.formatted_address); form.setFieldsValue({ address: results[0]?.formatted_address, addressCountry: results[0].address_components.find((item) => item.types.includes('country'))?.long_name, @@ -437,9 +437,18 @@ function QuickCreatePlace(props) { { + if (address === '' || value !== address) { + return Promise.reject( + t('dashboard.events.addEditEvent.location.quickCreatePlace.validations.address'), + ); + } else { + return Promise.resolve(); + } + }, message: t('dashboard.events.addEditEvent.location.quickCreatePlace.validations.address'), }, ]} @@ -456,6 +465,7 @@ function QuickCreatePlace(props) { open={dropdownOpen} overlayClassName="filter-sort-dropdown-wrapper" getPopupContainer={(trigger) => trigger.parentNode} + onBlur={() => setDropdownOpen(false)} menu={{ items: suggestions?.map((suggestion, index) => { return { diff --git a/src/layout/ErrorLayout/ErrorLayout.jsx b/src/layout/ErrorLayout/ErrorLayout.jsx index b39efe2be..74dc06c66 100644 --- a/src/layout/ErrorLayout/ErrorLayout.jsx +++ b/src/layout/ErrorLayout/ErrorLayout.jsx @@ -14,7 +14,8 @@ function ErrorLayout({ children }) { } else if ( errorDetails.errorCode === '403' || errorDetails.errorCode === '500' || - errorDetails.errorCode === '400' + errorDetails.errorCode === '400' || + errorDetails.errorCode === '404' ) { setErrorComponent(); } diff --git a/src/services/externalSource.js b/src/services/externalSource.js index db477d0a6..79e4ce3b1 100644 --- a/src/services/externalSource.js +++ b/src/services/externalSource.js @@ -7,10 +7,9 @@ export const externalSourceApi = createApi({ keepUnusedDataFor: 10, endpoints: (builder) => ({ getExternalSource: builder.query({ - query: ({ searchKey, classes, calendarId, excludeExistingCMS = true, sources }) => ({ + query: ({ searchKey, classes, calendarId, excludeExistingCMS = true, sources = 'sources=Artsdata' }) => ({ url: `search-external-sources?query=${searchKey}&${classes}&${sources}&exclude-existing-cms-entites=${excludeExistingCMS}`, //Note: Change the source and excludeCms as per the api need method: 'GET', - headers: { 'calendar-id': calendarId, }, diff --git a/src/utils/services.js b/src/utils/services.js index 0dbec2446..4db359ed2 100644 --- a/src/utils/services.js +++ b/src/utils/services.js @@ -123,6 +123,18 @@ export const baseQueryWithReauth = async (args, api, extraOptions) => { placement: 'top', }); } + if (result.error && result.error.status === 404) { + // HTTP 403 Forbidden response status code indicates that the server understands the request but refuses to authorize it. + // This status is similar to 401, but for the 403 Forbidden status code, re-authenticating makes no difference. + // The access is tied to the application logic, such as insufficient rights to a resource. + api.dispatch(setErrorStates({ errorCode: '404', isError: true, message: result.error?.data?.message })); + + notification.info({ + key: '404', + message: {(t) => t('common.server.status.403.message')}, + placement: 'top', + }); + } if (result?.meta?.response?.status === 502) { // HTTP 503 Service Unavailable server error response code indicates that the server is not ready to handle the request. // Common causes are a server that is down for maintenance or that is overloaded.