-
Notifications
You must be signed in to change notification settings - Fork 0
/
AddPlace.jsx
40 lines (32 loc) · 1.08 KB
/
AddPlace.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { useParams } from 'react-router-dom';
// React Query Hooks
import { useRequestCreatePlacePermissions } from 'src/hooks/queries/useRequestCreatePlacePermissions';
// Global Hoooks
import { useErrorBoundary } from 'react-error-boundary';
// Custom Hooks
import { useDocumentTitle } from 'src/hooks/useDocumentTitle';
// Global Components
import { DarkOverlay } from 'src/components/DarkOverlay/DarkOverlay';
// Local Components
import { Form } from './Form/Form';
export const AddPlace = () => {
const { showBoundary } = useErrorBoundary();
const { destinationId } = useParams();
const { data, isLoading, error } = useRequestCreatePlacePermissions(destinationId);
useDocumentTitle(`Add place - ${data?.city || ''}`);
if (error) {
showBoundary(error);
return null;
}
return isLoading ? (
<DarkOverlay isLoading={isLoading} />
) : (
<>
<Form
destinationId={destinationId}
allowedCategories={data.allowedPlaceCategories}
city={data.city}
/>
</>
);
};