| 1 |
import { Dialog } from '@headlessui/react'; |
| 2 |
import { XMarkIcon } from '@heroicons/react/24/solid'; |
| 3 |
import { __ } from '@wordpress/i18n'; |
| 4 |
|
| 5 |
const Popup = ({ |
| 6 |
title = 'Products Added', |
| 7 |
data = [], |
| 8 |
open = false, |
| 9 |
onClose = () => {}, |
| 10 |
}) => { |
| 11 |
const totalCount = data.length.toString().padStart(2, '0'); |
| 12 |
|
| 13 |
return ( |
| 14 |
<Dialog |
| 15 |
open={open} |
| 16 |
onClose={onClose} |
| 17 |
className="disco-relative disco-z-50" |
| 18 |
> |
| 19 |
<div |
| 20 |
className="disco-fixed disco-inset-0 disco-bg-black/50" |
| 21 |
aria-hidden="true" |
| 22 |
/> |
| 23 |
<div className="disco-fixed disco-inset-0 disco-flex disco-items-center disco-justify-center disco-p-2"> |
| 24 |
<Dialog.Panel className="disco-bg-white disco-rounded-xl disco-shadow-2xl disco-min-w-xs disco-p-4 disco-max-h-[60vh] disco-flex disco-flex-col"> |
| 25 |
<Dialog.Title className="disco-text-lg disco-font-semibold disco-mb-4 disco-flex disco-justify-between disco-items-center"> |
| 26 |
<div className="disco-flex disco-items-center disco-gap-2"> |
| 27 |
{title} |
| 28 |
<span className="disco-text-lg disco-font-medium disco-text-gray-600"> |
| 29 |
({totalCount}) |
| 30 |
</span> |
| 31 |
</div> |
| 32 |
<button |
| 33 |
onClick={onClose} |
| 34 |
className="disco-text-gray-500 hover:disco-text-black disco-text-xl disco-font-light" |
| 35 |
> |
| 36 |
<XMarkIcon className="disco-size-5 disco-text-red-700" /> |
| 37 |
</button> |
| 38 |
</Dialog.Title> |
| 39 |
|
| 40 |
{/* 2. Content: Product List */} |
| 41 |
{data.length > 0 ? ( |
| 42 |
<div className="disco-space-y-1 disco-flex-grow disco-overflow-y-auto disco-p-2 disco-rounded-md disco-shadow"> |
| 43 |
{data.map((item) => ( |
| 44 |
<div |
| 45 |
key={item.id} |
| 46 |
className="disco-p-1 disco-flex disco-items-center disco-gap-3" |
| 47 |
> |
| 48 |
<div className="disco-w-6 disco-h-6 disco-flex disco-items-center disco-justify-center disco-text-xl"> |
| 49 |
{item.image ? ( |
| 50 |
<img |
| 51 |
src={item.image} |
| 52 |
alt={item.name} |
| 53 |
className="disco-w-6 disco-h-6 disco-rounded" |
| 54 |
/> |
| 55 |
) : ( |
| 56 |
<span className="disco-text-base"> |
| 57 |
{item.emoji || '📦'} |
| 58 |
</span> |
| 59 |
)} |
| 60 |
</div> |
| 61 |
|
| 62 |
<p className="disco-text-gray-700 disco-font-light"> |
| 63 |
{item.id} - {item.name} |
| 64 |
</p> |
| 65 |
</div> |
| 66 |
))} |
| 67 |
</div> |
| 68 |
) : ( |
| 69 |
<div className="disco-text-center disco-text-gray-500 disco-py-8"> |
| 70 |
{__('No items available.', 'disco')} |
| 71 |
</div> |
| 72 |
)} |
| 73 |
</Dialog.Panel> |
| 74 |
</div> |
| 75 |
</Dialog> |
| 76 |
); |
| 77 |
}; |
| 78 |
|
| 79 |
export default Popup; |
| 80 |
|