Raw
1 import { useParams } from "react-router-dom"
2
3 import { RouteFocusModal } from "../../../components/modals"
4 import { useStockLocation } from "../../../hooks/api/stock-locations"
5 import { LocationEditSalesChannelsForm } from "./components/edit-sales-channels-form"
6
7 export const LocationSalesChannels = () => {
8 const { location_id } = useParams()
9 const { stock_location, isPending, isError, error } = useStockLocation(
10 location_id!,
11 {
12 fields: "id,*sales_channels",
13 }
14 )
15
16 const ready = !isPending && !!stock_location
17
18 if (isError) {
19 throw error
20 }
21
22 return (
23 <RouteFocusModal>
24 {ready && <LocationEditSalesChannelsForm location={stock_location} />}
25 </RouteFocusModal>
26 )
27 }