fix(dashboard): set/unset automatic taxes on a region (#9315)
* fix: region automatic taxes * fix: query keys and cache issues
This commit is contained in:
@@ -29,7 +29,7 @@ export const useRegion = (
|
||||
>
|
||||
) => {
|
||||
const { data, ...rest } = useQuery({
|
||||
queryKey: regionsQueryKeys.detail(id),
|
||||
queryKey: regionsQueryKeys.detail(id, query),
|
||||
queryFn: async () => sdk.admin.region.retrieve(id, query),
|
||||
...options,
|
||||
})
|
||||
@@ -95,7 +95,7 @@ export const useUpdateRegion = (
|
||||
mutationFn: (payload) => sdk.admin.region.update(id, payload),
|
||||
onSuccess: (data, variables, context) => {
|
||||
queryClient.invalidateQueries({ queryKey: regionsQueryKeys.lists() })
|
||||
queryClient.invalidateQueries({ queryKey: regionsQueryKeys.detail(id) })
|
||||
queryClient.invalidateQueries({ queryKey: regionsQueryKeys.details() })
|
||||
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: pricePreferencesQueryKeys.list(),
|
||||
|
||||
@@ -7,7 +7,9 @@ import { queryClient } from "../../../lib/query-client"
|
||||
const regionQuery = (id: string) => ({
|
||||
queryKey: regionsQueryKeys.detail(id),
|
||||
queryFn: async () =>
|
||||
sdk.admin.region.retrieve(id, { fields: "*payment_providers" }),
|
||||
sdk.admin.region.retrieve(id, {
|
||||
fields: "*payment_providers,*countries,+automatic_taxes",
|
||||
}),
|
||||
})
|
||||
|
||||
export const regionLoader = async ({ params }: LoaderFunctionArgs) => {
|
||||
|
||||
@@ -23,7 +23,7 @@ export const RegionDetail = () => {
|
||||
error: regionError,
|
||||
} = useRegion(
|
||||
id!,
|
||||
{ fields: "*payment_providers,*countries" },
|
||||
{ fields: "*payment_providers,*countries,+automatic_taxes" },
|
||||
{
|
||||
initialData,
|
||||
}
|
||||
|
||||
@@ -62,6 +62,7 @@ export const EditRegionForm = ({
|
||||
currency_code: values.currency_code.toLowerCase(),
|
||||
payment_providers: values.payment_providers,
|
||||
is_tax_inclusive: values.is_tax_inclusive,
|
||||
automatic_taxes: values.automatic_taxes,
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
|
||||
@@ -19,7 +19,9 @@ export const RegionEdit = () => {
|
||||
isPending: isRegionLoading,
|
||||
isError: isRegionError,
|
||||
error: regionError,
|
||||
} = useRegion(id!, { fields: "*payment_providers" })
|
||||
} = useRegion(id!, {
|
||||
fields: "*payment_providers,*countries,+automatic_taxes",
|
||||
})
|
||||
|
||||
const {
|
||||
store,
|
||||
|
||||
Reference in New Issue
Block a user