import React, { useState } from 'react'; import { Calculator, Package, DollarSign, Truck, Plane, ArrowRight, ArrowLeft } from 'lucide-react'; // Main App Component export default function ShippingCalculator() { // State for active tab const [activeTab, setActiveTab] = useState('sea'); // 'sea' or 'air' // Sea Shipping Calculator (CBM) const SeaShippingCalculator = () => { // State for dimensions and units const [dimensions, setDimensions] = useState({ length: '', width: '', height: '', quantity: 1 }); const [unit, setUnit] = useState('cm'); const [result, setResult] = useState(null); // Handle input changes const handleChange = (e) => { const { name, value } = e.target; setDimensions({ ...dimensions, [name]: value }); }; // Calculate CBM and cost const calculateCBM = () => { // Validate inputs if (!dimensions.length || !dimensions.width || !dimensions.height) { alert('الرجاء إدخال جميع الأبعاد'); return; } // Convert to meters if needed const conversionFactor = unit === 'cm' ? 0.01 : 1; // Calculate volume in cubic meters const length = parseFloat(dimensions.length) * conversionFactor; const width = parseFloat(dimensions.width) * conversionFactor; const height = parseFloat(dimensions.height) * conversionFactor; const quantity = parseInt(dimensions.quantity) || 1; const cbm = length * width * height * quantity; // Calculate cost (partial CBM counts as full) const fullCBM = Math.ceil(cbm); const cost = fullCBM * 280; setResult({ cbm, fullCBM, cost }); }; // Reset form const resetForm = () => { setDimensions({ length: '', width: '', height: '', quantity: 1 }); setResult(null); }; return ( <>

أدخل أبعاد الشحنة

{unit}
{unit}
{unit}
{result && (

نتائج الحساب

الحجم الفعلي

{result.cbm.toFixed(4)} CBM

الحجم المحسوب للفواتير

{result.fullCBM} CBM

* يتم احتساب الأحجام الجزئية كوحدة CBM كاملة

إجمالي تكلفة الشحن

${result.cost.toLocaleString()}

بسعر $280 لكل CBM

)}

معلومات الشحن البحري

); }; // Air Shipping Calculator (DHL) const AirShippingCalculator = () => { // State for weight const [weight, setWeight] = useState(''); const [result, setResult] = useState(null); // Handle input changes const handleChange = (e) => { setWeight(e.target.value); }; // Calculate shipping cost const calculateShipping = () => { // Validate input if (!weight) { alert('الرجاء إدخال الوزن'); return; } const weightValue = parseFloat(weight); // Apply minimum weight rule const billableWeight = Math.max(weightValue, 30); // Calculate cost (30 SAR per kg) const cost = billableWeight * 30; setResult({ actualWeight: weightValue, billableWeight, cost }); }; // Reset form const resetForm = () => { setWeight(''); setResult(null); }; return ( <>

أدخل وزن الشحنة

كجم

* الحد الأدنى للوزن هو 30 كجم

{result && (

نتائج الحساب

الوزن الفعلي

{result.actualWeight.toFixed(2)} كجم

الوزن المحسوب للفواتير

{result.billableWeight.toFixed(2)} كجم

{result.actualWeight < 30 && (

* تم تطبيق الحد الأدنى للوزن (30 كجم)

)}

إجمالي تكلفة الشحن

{result.cost.toLocaleString()} ريال

بسعر 30 ريال لكل كجم

)}

معلومات الشحن الجوي DHL

); }; return (
{/* Logo and Header */}

AJADEAL

حاسبة الشحن

من الصين إلى المملكة العربية السعودية

{/* Navigation Tabs */}
{/* Active Calculator */} {activeTab === 'sea' ? : }
); }