fix design bug responsive
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
'use client'
|
||||
import { useState, useEffect } from 'react'
|
||||
import { useState } from 'react'
|
||||
import Image from 'next/image'
|
||||
import { Truck, Sort, Flash } from 'iconsax-react'
|
||||
import { ShopShippingType, ShipmentInfoType, ShipperType } from '../types/Types'
|
||||
import { ShopShippingType, ShipperType } from '../types/Types'
|
||||
|
||||
interface ShippingMethodSelectorProps {
|
||||
shippingData: ShopShippingType[]
|
||||
@@ -51,15 +52,6 @@ const ShippingMethodSelector = ({
|
||||
})
|
||||
}
|
||||
|
||||
// هندلر تغییر مرتبسازی
|
||||
const handleSortChange = (newSortBy: 'price' | 'time' | 'default') => {
|
||||
if (sortBy === newSortBy) {
|
||||
setSortOrder(sortOrder === 'asc' ? 'desc' : 'asc')
|
||||
} else {
|
||||
setSortBy(newSortBy)
|
||||
setSortOrder('asc')
|
||||
}
|
||||
}
|
||||
|
||||
// هندلر toggle محصولات فروشگاه
|
||||
const toggleShopExpansion = (shopId: string) => {
|
||||
@@ -106,7 +98,7 @@ const ShippingMethodSelector = ({
|
||||
|
||||
return (
|
||||
<div className="mt-5 border border-border rounded-2xl p-4 sm:p-6">
|
||||
<div className="flex items-center justify-between mb-4">
|
||||
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-4">
|
||||
<div className="flex items-center gap-2">
|
||||
<Truck size={20} color="#333333" />
|
||||
<div>
|
||||
@@ -125,7 +117,7 @@ const ShippingMethodSelector = ({
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="flex flex-col sm:flex-row items-start sm:items-center gap-3 sm:gap-2">
|
||||
{/* انتخاب سریع */}
|
||||
<div className="flex items-center gap-1">
|
||||
<Flash size={16} color="#666" />
|
||||
@@ -157,7 +149,7 @@ const ShippingMethodSelector = ({
|
||||
setSortBy(newSortBy)
|
||||
setSortOrder(newSortOrder)
|
||||
}}
|
||||
className="text-sm border border-gray-300 rounded px-2 py-1 bg-white"
|
||||
className="text-sm border border-gray-300 rounded px-2 py-1 bg-white min-w-[120px]"
|
||||
>
|
||||
<option value="default-asc">پیشفرض</option>
|
||||
<option value="price-asc">ارزانترین</option>
|
||||
@@ -170,7 +162,7 @@ const ShippingMethodSelector = ({
|
||||
{onClearSelections && Object.keys(selectedShipments).length > 0 && (
|
||||
<button
|
||||
onClick={onClearSelections}
|
||||
className="text-sm text-red-600 hover:text-red-800 font-medium px-3 py-1 rounded-md hover:bg-red-50 transition-colors"
|
||||
className="text-sm text-red-600 hover:text-red-800 font-medium px-3 py-1 rounded-md hover:bg-red-50 transition-colors whitespace-nowrap"
|
||||
>
|
||||
پاک کردن انتخابها
|
||||
</button>
|
||||
@@ -181,7 +173,7 @@ const ShippingMethodSelector = ({
|
||||
<div className="space-y-6">
|
||||
{shippingData?.map((shop) => (
|
||||
<div key={shop.shopId} className="border border-gray-200 rounded-lg p-4">
|
||||
<div className="flex items-center justify-between mb-4">
|
||||
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 sm:gap-4 mb-4">
|
||||
<div>
|
||||
<h4 className="font-medium text-gray-900 text-lg">{shop.shopName}</h4>
|
||||
<p className="text-sm text-gray-600">
|
||||
@@ -189,7 +181,7 @@ const ShippingMethodSelector = ({
|
||||
</p>
|
||||
</div>
|
||||
{selectedShipments[shop.shopId] && (
|
||||
<div className="flex items-center gap-1 px-2 py-1 bg-green-100 text-green-800 text-xs rounded-full">
|
||||
<div className="flex items-center gap-1 px-2 py-1 bg-green-100 text-green-800 text-xs rounded-full self-start sm:self-center">
|
||||
<svg className="w-3 h-3" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fillRule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clipRule="evenodd" />
|
||||
</svg>
|
||||
@@ -217,17 +209,19 @@ const ShippingMethodSelector = ({
|
||||
{expandedShops.has(shop.shopId) && (
|
||||
<div className="space-y-3 max-h-48 overflow-y-auto">
|
||||
{shop.items?.map((item, index) => (
|
||||
<div key={index} className="flex items-center gap-3 p-3 bg-gray-50 rounded-lg border border-gray-100">
|
||||
<img
|
||||
<div key={index} className="flex flex-col sm:flex-row items-start sm:items-center gap-3 p-3 bg-gray-50 rounded-lg border border-gray-100">
|
||||
<Image
|
||||
src={item.product.imagesUrl.cover}
|
||||
alt={item.product.title_fa}
|
||||
className="w-12 h-12 object-cover rounded-lg flex-shrink-0"
|
||||
width={48}
|
||||
height={48}
|
||||
className="w-12 h-12 object-cover rounded-lg flex-shrink-0 self-center sm:self-start"
|
||||
/>
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="text-sm font-medium text-gray-900 truncate mb-1">
|
||||
<div className="flex-1 min-w-0 w-full sm:w-auto">
|
||||
<div className="text-sm font-medium text-gray-900 mb-2 sm:mb-1">
|
||||
{item.product.title_fa}
|
||||
</div>
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 sm:gap-4">
|
||||
<div className="text-xs text-gray-600">
|
||||
تعداد: {item.quantity}
|
||||
</div>
|
||||
@@ -257,25 +251,25 @@ const ShippingMethodSelector = ({
|
||||
return (
|
||||
<label
|
||||
key={shipper.shipperId}
|
||||
className={`flex items-center justify-between p-3 border rounded-lg cursor-pointer transition-colors ${selectedShipments[shop.shopId] === shipper.shipperId
|
||||
className={`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 p-3 border rounded-lg cursor-pointer transition-colors ${selectedShipments[shop.shopId] === shipper.shipperId
|
||||
? 'border-primary bg-primary/5'
|
||||
: 'border-gray-200 hover:bg-gray-50'
|
||||
}`}
|
||||
>
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="flex items-center gap-3 flex-1 min-w-0">
|
||||
<input
|
||||
type="radio"
|
||||
name={`shipment-${shop.shopId}`}
|
||||
value={shipper.shipperId}
|
||||
checked={selectedShipments[shop.shopId] === shipper.shipperId}
|
||||
onChange={() => onShipmentSelect(shop.shopId, shipper.shipperId)}
|
||||
className="text-primary focus:ring-primary"
|
||||
className="text-primary focus:ring-primary flex-shrink-0"
|
||||
/>
|
||||
<div>
|
||||
<div className="font-medium text-gray-900 flex items-center gap-2">
|
||||
{shipper.shipperName}
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="font-medium text-gray-900 flex items-center gap-2 flex-wrap">
|
||||
<span className="truncate">{shipper.shipperName}</span>
|
||||
{isCheapest && (
|
||||
<span className="text-xs bg-green-100 text-green-800 px-1.5 py-0.5 rounded">
|
||||
<span className="text-xs bg-green-100 text-green-800 px-1.5 py-0.5 rounded flex-shrink-0">
|
||||
ارزانترین
|
||||
</span>
|
||||
)}
|
||||
@@ -286,8 +280,8 @@ const ShippingMethodSelector = ({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="text-left">
|
||||
<div className="font-medium text-gray-900 relative group">
|
||||
<div className="flex items-center justify-end sm:justify-start">
|
||||
<div className="font-medium text-gray-900 relative group text-right">
|
||||
{shipper.totalShippingCost.toLocaleString('fa-IR')} تومان
|
||||
{priceDifference > 0 && (
|
||||
<div className="text-xs text-orange-600 mt-1">
|
||||
|
||||
Reference in New Issue
Block a user