Skip to content

Commit

Permalink
fix(dashboard): set/unset automatic taxes on a region (#9315)
Browse files Browse the repository at this point in the history
* fix: region automatic taxes

* fix: query keys and cache issues
  • Loading branch information
fPolic authored Sep 26, 2024
1 parent 9480deb commit f294c99
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/admin/dashboard/src/hooks/api/regions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
Expand Down Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const RegionDetail = () => {
error: regionError,
} = useRegion(
id!,
{ fields: "*payment_providers,*countries" },
{ fields: "*payment_providers,*countries,+automatic_taxes" },
{
initialData,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit f294c99

Please sign in to comment.