diff --git a/admin-spa/src/lib/api.ts b/admin-spa/src/lib/api.ts index 1c54b59..785f50c 100644 --- a/admin-spa/src/lib/api.ts +++ b/admin-spa/src/lib/api.ts @@ -59,6 +59,14 @@ export const api = { }); }, + async put(path: string, body?: any) { + return api.wpFetch(path, { + method: 'PUT', + headers: { 'Content-Type': 'application/json' }, + body: body != null ? JSON.stringify(body) : undefined, + }); + }, + async del(path: string) { return api.wpFetch(path, { method: 'DELETE' }); }, diff --git a/admin-spa/src/routes/Settings/Tax.tsx b/admin-spa/src/routes/Settings/Tax.tsx index f6b1a21..fc1e8e8 100644 --- a/admin-spa/src/routes/Settings/Tax.tsx +++ b/admin-spa/src/routes/Settings/Tax.tsx @@ -175,56 +175,15 @@ export default function TaxSettings() { description={__('Enable or disable tax calculation for your store')} > toggleMutation.mutate(checked)} + onCheckedChange={(checked: boolean) => toggleMutation.mutate(checked)} disabled={toggleMutation.isPending} /> - {/* Suggested Tax Rates (when enabled) */} - {settings?.calc_taxes === 'yes' && suggested?.suggested && suggested.suggested.length > 0 && ( - -
- {suggested.suggested.map((rate: any) => { - const added = isRateAdded(rate.code); - return ( -
-
-
-

{rate.country}

- {added && ( - - - {__('Added')} - - )} -
-

- {rate.rate}% • {rate.name} -

-
- {!added && ( - - )} -
- ); - })} -
-
- )} - {/* Tax Rates */} {settings?.calc_taxes === 'yes' && ( } > + {/* Suggested Rates Notice */} + {suggested?.suggested && suggested.suggested.length > 0 && suggested.suggested.some((r: any) => !isRateAdded(r.code)) && ( +
+
+
+

+ {__('Suggested tax rates based on your selling locations')} +

+
+ {suggested.suggested.filter((r: any) => !isRateAdded(r.code)).map((rate: any) => ( +
+ + {rate.country}: {rate.rate}% ({rate.name}) + + +
+ ))} +
+
+
+
+ )} + + {/* Tax Rates List */} {allRates.length === 0 ? (

{__('No tax rates configured yet')}

@@ -441,16 +432,15 @@ export default function TaxSettings() {
- +