Skip to content

Commit

Permalink
Merge pull request #1040 from culturecreates/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
sahalali authored Mar 26, 2024
2 parents 5317c22 + 358de6a commit cb50685
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
18 changes: 14 additions & 4 deletions src/components/Modal/QuickCreatePlace/QuickCreatePlace.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -437,9 +437,18 @@ function QuickCreatePlace(props) {
<Form.Item
name="address"
label={t('dashboard.events.addEditEvent.location.quickCreatePlace.address')}
validateTrigger={['onBlur']}
rules={[
{
required: true,
validator: (rules, value) => {
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'),
},
]}
Expand All @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion src/layout/ErrorLayout/ErrorLayout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(<ErrorAlert errorType="failedAPI" />);
}
Expand Down
3 changes: 1 addition & 2 deletions src/services/externalSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
12 changes: 12 additions & 0 deletions src/utils/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: <Translation>{(t) => t('common.server.status.403.message')}</Translation>,
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.
Expand Down

0 comments on commit cb50685

Please sign in to comment.