diff --git a/admin-spa/src/index.css b/admin-spa/src/index.css index c164956..e84301a 100644 --- a/admin-spa/src/index.css +++ b/admin-spa/src/index.css @@ -130,4 +130,9 @@ /* --- WooNooW: Popper menus & fullscreen fixes --- */ [data-radix-popper-content-wrapper] { z-index: 2147483647 !important; } -body.woonoow-fullscreen .woonoow-app { overflow: visible; } \ No newline at end of file +body.woonoow-fullscreen .woonoow-app { overflow: visible; } + +/* a[href] { + color: rgb(34 197 94); + font-weight: bold; +} */ \ No newline at end of file diff --git a/admin-spa/src/routes/Settings/Shipping.tsx b/admin-spa/src/routes/Settings/Shipping.tsx index a215be7..a787f1f 100644 --- a/admin-spa/src/routes/Settings/Shipping.tsx +++ b/admin-spa/src/routes/Settings/Shipping.tsx @@ -1,10 +1,13 @@ import React, { useState } from 'react'; +import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'; +import { api } from '@/lib/api'; import { SettingsLayout } from './components/SettingsLayout'; import { SettingsCard } from './components/SettingsCard'; import { ToggleField } from './components/ToggleField'; import { Button } from '@/components/ui/button'; -import { Globe, Truck, MapPin, Edit, Trash2 } from 'lucide-react'; +import { Globe, Truck, MapPin, Edit, Trash2, RefreshCw, Loader2, ExternalLink } from 'lucide-react'; import { toast } from 'sonner'; +import { __ } from '@/lib/i18n'; interface ShippingRate { id: string; @@ -22,68 +25,79 @@ interface ShippingZone { } export default function ShippingPage() { - const [zones] = useState([ - { - id: 'domestic', - name: 'Domestic (Indonesia)', - regions: 'All Indonesia', - rates: [ - { - id: 'standard', - name: 'Standard Shipping', - price: 'Rp 15,000', - transitTime: '3-5 business days', - }, - { - id: 'express', - name: 'Express Shipping', - price: 'Rp 30,000', - transitTime: '1-2 business days', - }, - { - id: 'free', - name: 'Free Shipping', - price: 'Free', - condition: 'Order total > Rp 500,000', - }, - ], - }, - { - id: 'international', - name: 'International', - regions: 'Rest of world', - rates: [ - { - id: 'intl', - name: 'International Shipping', - price: 'Calculated', - transitTime: '7-14 business days', - }, - ], - }, - ]); + const queryClient = useQueryClient(); + const wcAdminUrl = (window as any).WNW_CONFIG?.wpAdminUrl || '/wp-admin'; + + // Fetch shipping zones from WooCommerce + const { data: zones = [], isLoading, refetch } = useQuery({ + queryKey: ['shipping-zones'], + queryFn: () => api.get('/settings/shipping/zones'), + staleTime: 5 * 60 * 1000, // 5 minutes + }); - const [localPickup, setLocalPickup] = useState(true); - const [showDeliveryEstimates, setShowDeliveryEstimates] = useState(true); - - const handleSave = async () => { - await new Promise((resolve) => setTimeout(resolve, 1000)); - toast.success('Shipping settings have been updated successfully.'); - }; + if (isLoading) { + return ( + +
+ +
+
+ ); + } return ( + + + + } > {/* Shipping Zones */} -
- {zones.map((zone) => ( + {zones.length === 0 ? ( +
+

+ {__('No shipping zones configured yet.')} +

+ +
+ ) : ( +
+ {zones.map((zone: any) => (
- - {zone.id !== 'domestic' && ( - - )}
{/* Shipping Rates */}
- {zone.rates.map((rate) => ( + {zone.rates?.map((rate: any) => (
- ))} + ))} - -
- - - {/* Local Pickup */} - - - - {localPickup && ( -
-
- -
-

Main Store

-

- Jl. Example No. 123, Jakarta 12345 -

-

- Mon-Fri: 9:00 AM - 5:00 PM -

-
- -
-
)}
- {/* Shipping Options */} - - - - { /* TODO: Implement */ }} - /> - - { /* TODO: Implement */ }} - /> - - {/* Help Card */}
-

💡 Shipping tips

+

💡 {__('Shipping tips')}

    -
  • • Offer free shipping for orders above a certain amount to increase average order value
  • -
  • • Provide multiple shipping options to give customers flexibility
  • -
  • • Set realistic delivery estimates to manage customer expectations
  • +
  • • {__('Offer free shipping for orders above a certain amount to increase average order value')}
  • +
  • • {__('Provide multiple shipping options to give customers flexibility')}
  • +
  • • {__('Set realistic delivery estimates to manage customer expectations')}
  • +
  • • {__('Configure detailed shipping settings in WooCommerce for full control')}