1 import { useParams } from "react-router-dom"
2
3 import { RouteFocusModal } from "../../../components/modals"
4 import { useEntityColumns } from "../../../hooks/api/views"
5 import { usePropertyLabels } from "../../../hooks/api/property-labels"
6 import { PropertyLabelsEditForm } from "../components/property-labels-edit-form"
7
8 export const PropertyLabelsEdit = () => {
9 const { entity } = useParams()
10
11 const {
12 columns,
13 isLoading: isLoadingColumns,
14 isError: isColumnsError,
15 error: columnsError,
16 } = useEntityColumns(entity!)
17
18 const {
19 property_labels,
20 isLoading: isLoadingLabels,
21 isError: isLabelsError,
22 error: labelsError,
23 } = usePropertyLabels({
24 entity: entity!,
25 })
26
27 if (isColumnsError) {
28 throw columnsError
29 }
30
31 if (isLabelsError) {
32 throw labelsError
33 }
34
35 const isLoading = isLoadingColumns || isLoadingLabels
36
37 return (
38 <RouteFocusModal>
39 {!isLoading && columns && property_labels && (
40 <PropertyLabelsEditForm
41 entity={entity!}
42 columns={columns}
43 propertyLabels={property_labels}
44 />
45 )}
46 </RouteFocusModal>
47 )
48 }