Files
negareh-console/src/pages/request/RequestDetail.tsx
T
morteza c06415536a
deploy to danak / build_and_deploy (push) Has been cancelled
up
2026-06-26 16:25:30 +03:30

117 lines
6.5 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { type FC } from 'react'
import { useParams } from 'react-router-dom'
import { useGetRequestDetails } from './hooks/useRequestData'
import TicketSection from './components/TicketSection'
import placeholderProductImage from '@/assets/images/placeholder-product.svg'
const RequestDetail: FC = () => {
const { id } = useParams()
const { data } = useGetRequestDetails(id!)
return (
<div className="w-full min-h-screen bg-[#eceef6] p-6">
{/* Header Section */}
<div className="flex items-start justify-between mb-6">
<div className="text-sm text-[#8C90A3]">
درخواست #{data?.data?.requestNumber}
</div>
</div>
{/* Order Information Section */}
<div className="bg-white rounded-2xl p-6 mb-6">
<div className='flex justify-between items-center'>
<h2 className="text-lg font-light mb-6">اطلاعات درخواست</h2>
</div>
<div className='flex flex-col gap-10'>
{
data?.data?.items?.map((item) => {
const productImage = item.product?.images?.[0]
return (
<div key={item.product.id}>
<div className="flex items-center gap-6">
{/* Product Image */}
<div className='size-[86px] rounded-lg overflow-hidden bg-gray-100'>
<img
src={productImage || placeholderProductImage}
alt={item.product?.title ?? 'محصول'}
className='size-full object-cover'
onError={(e) => {
e.currentTarget.src = placeholderProductImage
}}
/>
</div>
{/* Order Details */}
<div className="flex-1 flex gap-20 pr-10">
<div className='flex items-center gap-2'>
<div className="text-xs text-desc">عنوان:</div>
<div className="text-sm font-medium text-black">{item.product.title}</div>
</div>
</div>
</div>
{/* Order Description */}
<div className="mt-6 pt-6 border-t border-dashed border-desc">
<div className="text-sm font-medium mb-2 text-desc">شرح درخواست:</div>
<p className="text-sm font-light text-black leading-6">
{item.description || '—'}
</p>
</div>
{/* Attributes from field */}
{item.attributes?.length ? (
<>
<div className='font-bold mb-5 mt-7'>ویژگیها</div>
<div className='flex flex-col gap-3'>
{item.attributes.map((attr) => (
<div className='flex gap-3 items-center' key={attr.fieldId}>
<div className='text-sm text-gray-500'>{attr.field?.name}:</div>
<div className='text-sm -mt-px'>{attr.value ?? '—'}</div>
</div>
))}
</div>
</>
) : null}
{/* Attachments */}
{item.attachments?.length ? (
<div className="mt-6 pt-6 border-t border-dashed border-desc">
<div className="text-sm font-medium mb-3 text-desc">پیوستها:</div>
<div className="flex flex-wrap gap-4">
{item.attachments.map((att) => (
att.type === 'voice' ? (
<div key={att.url} className="flex items-center gap-2 p-3 bg-[#f5f6fa] rounded-xl">
<audio controls src={att.url} className="max-w-[240px] h-9" />
</div>
) : (
<a
key={att.url}
href={att.url}
target="_blank"
rel="noopener noreferrer"
className="block size-20 rounded-lg overflow-hidden border border-desc hover:opacity-90"
>
<img src={att.url} alt="پیوست" className="size-full object-cover" />
</a>
)
))}
</div>
</div>
) : null}
</div>
)
})
}
</div>
</div>
{/* Bottom Section - White Card */}
<TicketSection />
</div>
)
}
export default RequestDetail