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 ( <>
الحجم الفعلي
{result.cbm.toFixed(4)} CBM
الحجم المحسوب للفواتير
{result.fullCBM} CBM
* يتم احتساب الأحجام الجزئية كوحدة CBM كاملة
إجمالي تكلفة الشحن
${result.cost.toLocaleString()}
بسعر $280 لكل CBM
* الحد الأدنى للوزن هو 30 كجم
الوزن الفعلي
{result.actualWeight.toFixed(2)} كجم
الوزن المحسوب للفواتير
{result.billableWeight.toFixed(2)} كجم
{result.actualWeight < 30 && (* تم تطبيق الحد الأدنى للوزن (30 كجم)
)}إجمالي تكلفة الشحن
{result.cost.toLocaleString()} ريال
بسعر 30 ريال لكل كجم
من الصين إلى المملكة العربية السعودية