From 3b979119ed76407f31135dc1b166ac38ac09d76c Mon Sep 17 00:00:00 2001 From: Hafid Nur Date: Mon, 31 Mar 2025 17:32:30 +0700 Subject: [PATCH] feat: slicing modal for backoffice 'data pengiriman hadiah' page --- .../prizes/_components/modal-process-item.tsx | 71 ++++ apps/backoffice/src/app/prizes/page.tsx | 306 +++++++++--------- 2 files changed, 227 insertions(+), 150 deletions(-) create mode 100644 apps/backoffice/src/app/prizes/_components/modal-process-item.tsx diff --git a/apps/backoffice/src/app/prizes/_components/modal-process-item.tsx b/apps/backoffice/src/app/prizes/_components/modal-process-item.tsx new file mode 100644 index 0000000..3472c45 --- /dev/null +++ b/apps/backoffice/src/app/prizes/_components/modal-process-item.tsx @@ -0,0 +1,71 @@ +import { Button } from '@imphnen-frontend-service/ui/atoms'; +import { InputForm, Modal } from '@imphnen-frontend-service/ui/molecules'; + +interface IModalProcessDelivery { + isOpen: boolean; + onClose: () => void; + onProcessDelivery?: () => void; +} + +const ModalProcessDelivery = ({ isOpen, onClose }: IModalProcessDelivery) => { + return ( + + +

+ Delivery Process +

+

+ Lakukan pengiriman hadiah gacha untuk pengguna di bawah ini, jika + sudah ubah status menjadi “Delivered”. +

+
+ +
+ + + + +
+ + +
+
+ ); +}; + +export default ModalProcessDelivery; diff --git a/apps/backoffice/src/app/prizes/page.tsx b/apps/backoffice/src/app/prizes/page.tsx index f7828c4..ffac78d 100644 --- a/apps/backoffice/src/app/prizes/page.tsx +++ b/apps/backoffice/src/app/prizes/page.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; -import { FC, ReactElement, useState } from 'react'; +import { FC, Fragment, ReactElement, useState } from 'react'; import { FilterOutlined, SearchOutlined, @@ -17,13 +17,15 @@ import { useReactTable, RowSelectionState, } from '@tanstack/react-table'; +import ModalProcessDelivery from './_components/modal-process-item'; -type Status = 'valid' | 'invalid' | 'unchecked'; +type OrderValid = 'valid' | 'invalid' | 'unchecked'; +type Status = 'undelivered' | 'delivered'; interface Prize { id: number; name: string; - orderValid: Status; + orderValid: OrderValid; items: string; address: string; status: Status; @@ -46,119 +48,16 @@ const mockData: Prize[] = Array.from({ length: 90 }, (_, i) => ({ ? 'invalid' : i % 5 === 0 ? 'unchecked' - : 'valid') as Status, + : 'valid') as OrderValid, items: items[i % items.length], address: 'Jl. Pantai Cibaduyut Indah', - status: (i % 3 === 0 - ? 'unchecked' - : i % 5 === 0 - ? 'invalid' - : 'valid') as Status, + status: (i % 3 === 0 ? 'undelivered' : 'delivered') as Status, })); -const columns: ColumnDef[] = [ - { - id: 'select', - header: ({ table }) => ( - - ), - cell: ({ row }) => ( - - ), - }, - { - header: 'No', - accessorKey: 'id', - }, - { - header: 'Nama Lengkap', - accessorKey: 'name', - }, - { - header: 'Order Valid?', - accessorKey: 'orderValid', - cell: ({ row }) => { - const status = row.original.orderValid; - const statusColors: Record = { - valid: 'bg-success-200 text-success-500', - invalid: 'bg-danger-200 text-danger-500', - unchecked: 'bg-warning-200 text-warning-900', - }; - const statusText: Record = { - valid: 'Valid', - invalid: 'Invalid', - unchecked: 'Unchecked', - }; - return ( -
- {statusText[status]} -
- ); - }, - }, - { - header: 'Items', - accessorKey: 'items', - }, - { - header: 'Alamat Pengiriman', - accessorKey: 'address', - }, - { - header: 'Status', - accessorKey: 'status', - cell: ({ row }) => { - const status = row.original.status; - const statusColors: Record = { - valid: 'bg-success-200 text-success-500', - invalid: 'bg-danger-200 text-danger-500', - unchecked: 'bg-warning-200 text-warning-900', - }; - const statusText: Record = { - valid: 'Valid', - invalid: 'Invalid', - unchecked: 'Unchecked', - }; - return ( -
- {statusText[status]} -
- ); - }, - }, - { - header: 'Action', - cell: ({ row }) => ( - - ), - }, -]; - export const Components: FC = (): ReactElement => { + const [showModalProcessDelivery, setShowModalProcessDelivery] = + useState(false); + const [pagination, setPagination] = React.useState({ pageIndex: 0, pageSize: 9, @@ -167,6 +66,105 @@ export const Components: FC = (): ReactElement => { const [rowSelection, setRowSelection] = React.useState({}); const [showFilter, setShowFilter] = useState(false); + const columns: ColumnDef[] = [ + { + id: 'select', + header: ({ table }) => ( + + ), + cell: ({ row }) => ( + + ), + }, + { + header: 'No', + accessorKey: 'id', + }, + { + header: 'Nama Lengkap', + accessorKey: 'name', + }, + { + header: 'Order Valid?', + accessorKey: 'orderValid', + cell: ({ row }) => { + const status = row.original.orderValid; + const statusColors: Record = { + valid: 'bg-success-200 text-success-500', + invalid: 'bg-danger-200 text-danger-500', + unchecked: 'bg-warning-200 text-warning-900', + }; + const statusText: Record = { + valid: 'Valid', + invalid: 'Invalid', + unchecked: 'Unchecked', + }; + return ( +
+ {statusText[status]} +
+ ); + }, + }, + { + header: 'Items', + accessorKey: 'items', + }, + { + header: 'Alamat Pengiriman', + accessorKey: 'address', + }, + { + header: 'Status', + accessorKey: 'status', + cell: ({ row }) => { + const status = row.original.status; + const statusColors: Record = { + delivered: 'bg-success-200 text-success-500', + undelivered: 'bg-danger-200 text-danger-500', + }; + const statusText: Record = { + delivered: 'Delivered', + undelivered: 'Undelivered', + }; + return ( +
+ {statusText[status]} +
+ ); + }, + }, + { + header: 'Action', + cell: ({ row }) => ( + + ), + }, + ]; + const table = useReactTable({ data: mockData, columns, @@ -184,48 +182,56 @@ export const Components: FC = (): ReactElement => { }); return ( -
- {/* Header */} -
-

Data Pengiriman Hadiah

-
- - {/* Account Table Section */} -
- {/* Search and Filter */} -
-
- -
- + +
+ {/* Header */} +
+

Data Pengiriman Hadiah

+
+ {/* Account Table Section */} +
+ {/* Search and Filter */} +
+
+ +
+ +
+
+
+ + {showFilter && ( +
+ setShowFilter(false)} /> +
+ )}
+ {/* Table */} + +
+
-
- - {showFilter && ( -
- setShowFilter(false)} /> -
- )} -
-
- - {/* Table */} - -
-
+ {/* Modal Process Delivery */} + setShowModalProcessDelivery(false)} + onProcessDelivery={() => { + console.log('Item added'); + }} + /> + ); };