|
1
|
import { useParams } from "react-router-dom" |
|
2
|
import { MetadataForm } from "../../../components/forms/metadata-form" |
|
3
|
import { useStockLocation, useUpdateStockLocation } from "../../../hooks/api" |
|
4
|
|
|
5
|
export const LocationMetadata = () => { |
|
6
|
const { location_id } = useParams() |
|
7
|
|
|
8
|
const { stock_location, isPending, isError, error } = useStockLocation( |
|
9
|
location_id!, |
|
10
|
{ fields: "id,metadata" } |
|
11
|
) |
|
12
|
|
|
13
|
const { mutateAsync, isPending: isMutating } = useUpdateStockLocation( |
|
14
|
location_id! |
|
15
|
) |
|
16
|
|
|
17
|
if (isError) { |
|
18
|
throw error |
|
19
|
} |
|
20
|
|
|
21
|
return ( |
|
22
|
<MetadataForm |
|
23
|
metadata={stock_location?.metadata} |
|
24
|
hook={mutateAsync} |
|
25
|
isPending={isPending} |
|
26
|
isMutating={isMutating} |
|
27
|
/> |
|
28
|
) |
|
29
|
} |