|
1
|
import { useParams } from "react-router-dom" |
|
2
|
import { RouteFocusModal } from "../../../components/modals" |
|
3
|
import { usePriceList } from "../../../hooks/api/price-lists" |
|
4
|
import { usePriceListCurrencyData } from "../common/hooks/use-price-list-currency-data" |
|
5
|
import { PriceListPricesAddForm } from "./components/price-list-prices-add-form" |
|
6
|
|
|
7
|
export const PriceListProductsAdd = () => { |
|
8
|
const { id } = useParams<{ id: string }>() |
|
9
|
|
|
10
|
const { price_list, isPending, isError, error } = usePriceList(id!, { |
|
11
|
fields: |
|
12
|
"*prices,prices.price_set.variant.id,prices.price_rules.attribute,prices.price_rules.value", |
|
13
|
}) |
|
14
|
const { currencies, regions, pricePreferences, isReady } = |
|
15
|
usePriceListCurrencyData() |
|
16
|
|
|
17
|
const ready = isReady && !isPending && !!price_list |
|
18
|
|
|
19
|
if (isError) { |
|
20
|
throw error |
|
21
|
} |
|
22
|
|
|
23
|
return ( |
|
24
|
<RouteFocusModal> |
|
25
|
{ready && ( |
|
26
|
<PriceListPricesAddForm |
|
27
|
priceList={price_list} |
|
28
|
currencies={currencies} |
|
29
|
regions={regions} |
|
30
|
pricePreferences={pricePreferences} |
|
31
|
/> |
|
32
|
)} |
|
33
|
</RouteFocusModal> |
|
34
|
) |
|
35
|
} |