From 83836298ec73822c37e3e45bdd08ec26eadfcd58 Mon Sep 17 00:00:00 2001 From: Dwindi Ramadhana Date: Thu, 8 Jan 2026 10:22:26 +0700 Subject: [PATCH] fix(admin): WC settings link uses siteUrl + /wp-admin The wpAdminUrl config already includes admin.php?page=woonoow, so constructing /admin.php?page=wc-settings on top of it was wrong. Now uses siteUrl + /wp-admin for external WC links. --- admin-spa/src/routes/Settings/Shipping.tsx | 231 ++++++++++----------- 1 file changed, 115 insertions(+), 116 deletions(-) diff --git a/admin-spa/src/routes/Settings/Shipping.tsx b/admin-spa/src/routes/Settings/Shipping.tsx index 0336414..a786f39 100644 --- a/admin-spa/src/routes/Settings/Shipping.tsx +++ b/admin-spa/src/routes/Settings/Shipping.tsx @@ -31,7 +31,8 @@ interface ShippingZone { export default function ShippingPage() { const queryClient = useQueryClient(); - const wcAdminUrl = (window as any).WNW_CONFIG?.wpAdminUrl || '/wp-admin'; + // Use siteUrl + /wp-admin since wpAdminUrl already includes admin.php?page=woonoow + const wcAdminUrl = ((window as any).WNW_CONFIG?.siteUrl || '') + '/wp-admin'; const [togglingMethod, setTogglingMethod] = useState(null); const [selectedZone, setSelectedZone] = useState(null); const [showAddMethod, setShowAddMethod] = useState(false); @@ -44,7 +45,7 @@ export default function ShippingPage() { const [deletingZone, setDeletingZone] = useState(null); const [regionSearch, setRegionSearch] = useState(''); const isDesktop = useMediaQuery("(min-width: 768px)"); - + // Fetch shipping zones from WooCommerce const { data: zones = [], isLoading, refetch } = useQuery({ queryKey: ['shipping-zones'], @@ -125,7 +126,7 @@ export default function ShippingPage() { // Fetch method settings when accordion expands const fetchMethodSettings = async (instanceId: number) => { if (!selectedZone || methodSettings[instanceId]) return; - + try { const settings = await api.get(`/settings/shipping/zones/${selectedZone.id}/methods/${instanceId}/settings`); setMethodSettings(prev => ({ ...prev, [instanceId]: settings })); @@ -174,9 +175,9 @@ export default function ShippingPage() { const confirmDelete = () => { if (deletingMethod) { - deleteMethodMutation.mutate({ - zoneId: deletingMethod.zoneId, - instanceId: deletingMethod.instanceId + deleteMethodMutation.mutate({ + zoneId: deletingMethod.zoneId, + instanceId: deletingMethod.instanceId }); setDeletingMethod(null); } @@ -230,8 +231,8 @@ export default function ShippingPage() { if (isLoading) { return ( -
@@ -287,102 +288,102 @@ export default function ShippingPage() { ) : (
{zones.map((zone: any) => ( -
-
-
-
- +
+
+
+
+ +
+
+

{zone.name}

+

+ {__('Available to:')} {zone.regions} +

+

+ {zone.rates.length} {zone.rates.length === 1 ? __('delivery option') : __('delivery options')} +

+
-
-

{zone.name}

-

- {__('Available to:')} {zone.regions} -

-

- {zone.rates.length} {zone.rates.length === 1 ? __('delivery option') : __('delivery options')} -

+
+ + +
-
- - - -
-
- {/* Shipping Rates */} -
- {zone.rates?.map((rate: any) => ( -
-
-
- + {/* Shipping Rates */} +
+ {zone.rates?.map((rate: any) => ( +
+
+
+ +
+
+ + {rate.transitTime && ( + + • {rate.transitTime} + + )} + {rate.condition && ( + + • {rate.condition} + + )} +
-
- + + handleToggle(zone.id, rate.instance_id, checked)} + disabled={togglingMethod === `${zone.id}-${rate.instance_id}`} /> - {rate.transitTime && ( - - • {rate.transitTime} - - )} - {rate.condition && ( - - • {rate.condition} - - )}
-
- - handleToggle(zone.id, rate.instance_id, checked)} - disabled={togglingMethod === `${zone.id}-${rate.instance_id}`} - /> -
-
- ))} + ))} +
-
))} -