feat: slicing modal for backoffice 'validasi transaksi' page
- Tambah fungsi untuk handle aksi ketika button pada modal ditekan
This commit is contained in:
@@ -4,14 +4,14 @@ import { InputForm, Modal } from '@imphnen-frontend-service/ui/molecules';
|
|||||||
interface IModalAddItem {
|
interface IModalAddItem {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
onAddItem: () => void;
|
handleAddItem: () => void;
|
||||||
currentStep?: number;
|
currentStep?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ModalAddItem = ({
|
const ModalAddItem = ({
|
||||||
isOpen,
|
isOpen,
|
||||||
onClose,
|
onClose,
|
||||||
onAddItem,
|
handleAddItem,
|
||||||
currentStep = 1,
|
currentStep = 1,
|
||||||
}: IModalAddItem) => {
|
}: IModalAddItem) => {
|
||||||
return (
|
return (
|
||||||
@@ -32,6 +32,7 @@ const ModalAddItem = ({
|
|||||||
{currentStep === 2 && (
|
{currentStep === 2 && (
|
||||||
<StepTwo
|
<StepTwo
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
|
handleAddItem={handleAddItem}
|
||||||
resetStep={() => {
|
resetStep={() => {
|
||||||
console.log('Reset step');
|
console.log('Reset step');
|
||||||
}}
|
}}
|
||||||
@@ -92,9 +93,10 @@ const StepOne = ({ nextStep, onClose }: IStepOneProps) => (
|
|||||||
interface IStepTwoProps {
|
interface IStepTwoProps {
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
resetStep: () => void;
|
resetStep: () => void;
|
||||||
|
handleAddItem?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const StepTwo = ({ onClose, resetStep }: IStepTwoProps) => (
|
const StepTwo = ({ onClose, handleAddItem, resetStep }: IStepTwoProps) => (
|
||||||
<>
|
<>
|
||||||
<Modal.Header className="mb-0 text-center items-center">
|
<Modal.Header className="mb-0 text-center items-center">
|
||||||
<h2 className="text-p1 font-semibold text-primary-500 mb-3">
|
<h2 className="text-p1 font-semibold text-primary-500 mb-3">
|
||||||
@@ -106,10 +108,22 @@ const StepTwo = ({ onClose, resetStep }: IStepTwoProps) => (
|
|||||||
</p>
|
</p>
|
||||||
</Modal.Header>
|
</Modal.Header>
|
||||||
<Modal.Content className="flex gap-4">
|
<Modal.Content className="flex gap-4">
|
||||||
<Button variant="bordered" size="lg" className="w-full" onClick={onClose}>
|
<Button
|
||||||
|
variant="bordered"
|
||||||
|
size="lg"
|
||||||
|
className="w-full"
|
||||||
|
onClick={resetStep}
|
||||||
|
>
|
||||||
Batal
|
Batal
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="primary" size="lg" className="w-full">
|
<Button
|
||||||
|
variant="primary"
|
||||||
|
size="lg"
|
||||||
|
className="w-full"
|
||||||
|
onClick={() => {
|
||||||
|
handleAddItem && handleAddItem();
|
||||||
|
}}
|
||||||
|
>
|
||||||
Tambahkan
|
Tambahkan
|
||||||
</Button>
|
</Button>
|
||||||
</Modal.Content>
|
</Modal.Content>
|
||||||
|
|||||||
@@ -4,13 +4,13 @@ import { Modal } from '@imphnen-frontend-service/ui/molecules';
|
|||||||
interface IModalDeleteItem {
|
interface IModalDeleteItem {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
onDeleteItem: () => void;
|
handleDeleteItem?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ModalDeleteItem = ({
|
const ModalDeleteItem = ({
|
||||||
isOpen,
|
isOpen,
|
||||||
onClose,
|
onClose,
|
||||||
onDeleteItem,
|
handleDeleteItem,
|
||||||
}: IModalDeleteItem) => {
|
}: IModalDeleteItem) => {
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
@@ -48,7 +48,9 @@ const ModalDeleteItem = ({
|
|||||||
variant="danger"
|
variant="danger"
|
||||||
size="lg"
|
size="lg"
|
||||||
className="w-full"
|
className="w-full"
|
||||||
onClick={() => onDeleteItem()}
|
onClick={() => {
|
||||||
|
handleDeleteItem && handleDeleteItem();
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
Hapus Item
|
Hapus Item
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ import { InputForm, Modal } from '@imphnen-frontend-service/ui/molecules';
|
|||||||
interface IModalEditItem {
|
interface IModalEditItem {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
onEditItem: () => void;
|
handleEditItem?: () => void;
|
||||||
currentStep?: number;
|
currentStep?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ModalEditItem = ({
|
const ModalEditItem = ({
|
||||||
isOpen,
|
isOpen,
|
||||||
onClose,
|
onClose,
|
||||||
onEditItem,
|
handleEditItem,
|
||||||
currentStep = 1,
|
currentStep = 1,
|
||||||
}: IModalEditItem) => {
|
}: IModalEditItem) => {
|
||||||
return (
|
return (
|
||||||
@@ -81,7 +81,7 @@ const StepOne = ({ nextStep, onClose }: IStepOneProps) => (
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Button variant="primary" size="lg" className="w-full">
|
<Button variant="primary" size="lg" className="w-full" onClick={nextStep}>
|
||||||
Perbarui Item
|
Perbarui Item
|
||||||
</Button>
|
</Button>
|
||||||
</Modal.Content>
|
</Modal.Content>
|
||||||
@@ -90,10 +90,11 @@ const StepOne = ({ nextStep, onClose }: IStepOneProps) => (
|
|||||||
|
|
||||||
interface IStepTwoProps {
|
interface IStepTwoProps {
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
|
handleEditItem?: () => void;
|
||||||
resetStep: () => void;
|
resetStep: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const StepTwo = ({ onClose, resetStep }: IStepTwoProps) => (
|
const StepTwo = ({ onClose, handleEditItem, resetStep }: IStepTwoProps) => (
|
||||||
<>
|
<>
|
||||||
<Modal.Header className="mb-0 text-center items-center">
|
<Modal.Header className="mb-0 text-center items-center">
|
||||||
<h2 className="text-p1 font-semibold text-primary-500 mb-3">
|
<h2 className="text-p1 font-semibold text-primary-500 mb-3">
|
||||||
@@ -105,10 +106,22 @@ const StepTwo = ({ onClose, resetStep }: IStepTwoProps) => (
|
|||||||
</p>
|
</p>
|
||||||
</Modal.Header>
|
</Modal.Header>
|
||||||
<Modal.Content className="flex gap-4">
|
<Modal.Content className="flex gap-4">
|
||||||
<Button variant="bordered" size="lg" className="w-full" onClick={onClose}>
|
<Button
|
||||||
|
variant="bordered"
|
||||||
|
size="lg"
|
||||||
|
className="w-full"
|
||||||
|
onClick={resetStep}
|
||||||
|
>
|
||||||
Batal
|
Batal
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="primary" size="lg" className="w-full">
|
<Button
|
||||||
|
variant="primary"
|
||||||
|
size="lg"
|
||||||
|
className="w-full"
|
||||||
|
onClick={() => {
|
||||||
|
handleEditItem && handleEditItem();
|
||||||
|
}}
|
||||||
|
>
|
||||||
Update
|
Update
|
||||||
</Button>
|
</Button>
|
||||||
</Modal.Content>
|
</Modal.Content>
|
||||||
|
|||||||
@@ -161,16 +161,16 @@ export const Components: FC = (): ReactElement => {
|
|||||||
<ModalAddItem
|
<ModalAddItem
|
||||||
isOpen={showModalAddItem}
|
isOpen={showModalAddItem}
|
||||||
onClose={() => setShowModalAddItem(false)}
|
onClose={() => setShowModalAddItem(false)}
|
||||||
onAddItem={() => {
|
handleAddItem={() => {
|
||||||
console.log('Item added');
|
console.log('Item added');
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Modal Add Item */}
|
{/* Modal Edit Item */}
|
||||||
<ModalEditItem
|
<ModalEditItem
|
||||||
isOpen={showModalEditItem}
|
isOpen={showModalEditItem}
|
||||||
onClose={() => setShowModalEditItem(false)}
|
onClose={() => setShowModalEditItem(false)}
|
||||||
onEditItem={() => {
|
handleEditItem={() => {
|
||||||
console.log('Item edited');
|
console.log('Item edited');
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@@ -179,7 +179,7 @@ export const Components: FC = (): ReactElement => {
|
|||||||
<ModalDeleteItem
|
<ModalDeleteItem
|
||||||
isOpen={showModalDeleteItem}
|
isOpen={showModalDeleteItem}
|
||||||
onClose={() => setShowModalDeleteItem(false)}
|
onClose={() => setShowModalDeleteItem(false)}
|
||||||
onDeleteItem={() => {
|
handleDeleteItem={() => {
|
||||||
console.log('Item deleted');
|
console.log('Item deleted');
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -4,10 +4,14 @@ import { InputForm, Modal } from '@imphnen-frontend-service/ui/molecules';
|
|||||||
interface IModalProcessDelivery {
|
interface IModalProcessDelivery {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
onProcessDelivery?: () => void;
|
handleProcessDelivery?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ModalProcessDelivery = ({ isOpen, onClose }: IModalProcessDelivery) => {
|
const ModalProcessDelivery = ({
|
||||||
|
isOpen,
|
||||||
|
onClose,
|
||||||
|
handleProcessDelivery,
|
||||||
|
}: IModalProcessDelivery) => {
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
className="min-w-[400px] bg-primary-50 rounded-lg p-[40px] flex flex-col gap-8 text-center"
|
className="min-w-[400px] bg-primary-50 rounded-lg p-[40px] flex flex-col gap-8 text-center"
|
||||||
@@ -33,6 +37,7 @@ const ModalProcessDelivery = ({ isOpen, onClose }: IModalProcessDelivery) => {
|
|||||||
value="Ahmad Wiyana"
|
value="Ahmad Wiyana"
|
||||||
size="lg"
|
size="lg"
|
||||||
className="w-full"
|
className="w-full"
|
||||||
|
readOnly
|
||||||
/>
|
/>
|
||||||
<InputForm
|
<InputForm
|
||||||
label="Item yang didapatkan"
|
label="Item yang didapatkan"
|
||||||
@@ -41,6 +46,7 @@ const ModalProcessDelivery = ({ isOpen, onClose }: IModalProcessDelivery) => {
|
|||||||
value="Lanyard + ID Card"
|
value="Lanyard + ID Card"
|
||||||
size="lg"
|
size="lg"
|
||||||
className="w-full"
|
className="w-full"
|
||||||
|
readOnly
|
||||||
/>
|
/>
|
||||||
<InputForm
|
<InputForm
|
||||||
label="Alamat Pengiriman"
|
label="Alamat Pengiriman"
|
||||||
@@ -49,6 +55,7 @@ const ModalProcessDelivery = ({ isOpen, onClose }: IModalProcessDelivery) => {
|
|||||||
value="Jl. Pantai Cibaduyut Indah"
|
value="Jl. Pantai Cibaduyut Indah"
|
||||||
size="lg"
|
size="lg"
|
||||||
className="w-full"
|
className="w-full"
|
||||||
|
readOnly
|
||||||
/>
|
/>
|
||||||
<InputForm
|
<InputForm
|
||||||
label="Status"
|
label="Status"
|
||||||
@@ -57,10 +64,16 @@ const ModalProcessDelivery = ({ isOpen, onClose }: IModalProcessDelivery) => {
|
|||||||
value="Lanyard + ID Card"
|
value="Lanyard + ID Card"
|
||||||
size="lg"
|
size="lg"
|
||||||
className="w-full"
|
className="w-full"
|
||||||
|
readOnly
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Button variant="primary" size="lg" className="w-full">
|
<Button
|
||||||
|
variant="primary"
|
||||||
|
size="lg"
|
||||||
|
className="w-full"
|
||||||
|
onClick={() => handleProcessDelivery && handleProcessDelivery()}
|
||||||
|
>
|
||||||
Proses Pengiriman
|
Proses Pengiriman
|
||||||
</Button>
|
</Button>
|
||||||
</Modal.Content>
|
</Modal.Content>
|
||||||
|
|||||||
@@ -155,6 +155,7 @@ export const Components: FC = (): ReactElement => {
|
|||||||
variant="primary"
|
variant="primary"
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
setShowModalProcessDelivery(true);
|
setShowModalProcessDelivery(true);
|
||||||
}}
|
}}
|
||||||
className="flex items-center gap-2 w-full"
|
className="flex items-center gap-2 w-full"
|
||||||
@@ -227,8 +228,8 @@ export const Components: FC = (): ReactElement => {
|
|||||||
<ModalProcessDelivery
|
<ModalProcessDelivery
|
||||||
isOpen={showModalProcessDelivery}
|
isOpen={showModalProcessDelivery}
|
||||||
onClose={() => setShowModalProcessDelivery(false)}
|
onClose={() => setShowModalProcessDelivery(false)}
|
||||||
onProcessDelivery={() => {
|
handleProcessDelivery={() => {
|
||||||
console.log('Item added');
|
console.log('Action ketika user menekan tombol Proses Pengiriman');
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
import { Button } from '@imphnen-frontend-service/ui/atoms';
|
||||||
|
import { InputForm, Modal } from '@imphnen-frontend-service/ui/molecules';
|
||||||
|
|
||||||
|
interface IModalValidate {
|
||||||
|
isOpen: boolean;
|
||||||
|
onClose: () => void;
|
||||||
|
handleValid?: () => void;
|
||||||
|
handleInvalid?: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ModalValidate = ({
|
||||||
|
isOpen,
|
||||||
|
onClose,
|
||||||
|
handleValid,
|
||||||
|
handleInvalid,
|
||||||
|
}: IModalValidate) => {
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
className="min-w-[400px] bg-primary-50 rounded-lg p-[40px] flex flex-col gap-8 text-center"
|
||||||
|
isOpen={isOpen}
|
||||||
|
onClose={onClose}
|
||||||
|
disableEscapeKeyDown={true}
|
||||||
|
>
|
||||||
|
<Modal.Header className="mb-0 text-center items-center">
|
||||||
|
<h2 className="text-p1 font-semibold text-primary-500 mb-3">
|
||||||
|
Validasi Transaksi
|
||||||
|
</h2>
|
||||||
|
</Modal.Header>
|
||||||
|
<Modal.Content className="flex flex-col gap-8">
|
||||||
|
<InputForm
|
||||||
|
label="Nomor Transaksi"
|
||||||
|
type="text"
|
||||||
|
placeholder="Masukkan Nomor Transaksi"
|
||||||
|
value="2502133Y9AFVBO"
|
||||||
|
size="lg"
|
||||||
|
className="w-full"
|
||||||
|
/>
|
||||||
|
<div className="flex gap-4">
|
||||||
|
<Button
|
||||||
|
variant="bordered"
|
||||||
|
size="lg"
|
||||||
|
className="w-full border-danger-500 text-danger-500 hover:border-danger-700 hover:text-danger-700"
|
||||||
|
onClick={() => handleInvalid && handleInvalid()}
|
||||||
|
>
|
||||||
|
Tidak Valid
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="primary"
|
||||||
|
size="lg"
|
||||||
|
className="w-full"
|
||||||
|
onClick={() => handleValid && handleValid()}
|
||||||
|
>
|
||||||
|
Valid
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</Modal.Content>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ModalValidate;
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { FC, ReactElement, useState } from 'react';
|
import { FC, Fragment, ReactElement, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
FilterOutlined,
|
FilterOutlined,
|
||||||
SearchOutlined,
|
SearchOutlined,
|
||||||
@@ -16,6 +16,7 @@ import {
|
|||||||
useReactTable,
|
useReactTable,
|
||||||
RowSelectionState,
|
RowSelectionState,
|
||||||
} from '@tanstack/react-table';
|
} from '@tanstack/react-table';
|
||||||
|
import ModalValidate from './_components/modal-validate';
|
||||||
|
|
||||||
type TransactionStatus = 'valid' | 'invalid' | 'unchecked';
|
type TransactionStatus = 'valid' | 'invalid' | 'unchecked';
|
||||||
|
|
||||||
@@ -38,6 +39,17 @@ const mockTransactions: Transaction[] = Array.from({ length: 20 }, (_, i) => ({
|
|||||||
: 'valid') as TransactionStatus,
|
: 'valid') as TransactionStatus,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
export const Components: FC = (): ReactElement => {
|
||||||
|
const [showModalValidate, setShowModalValidate] = useState(false);
|
||||||
|
|
||||||
|
const [pagination, setPagination] = React.useState<PaginationState>({
|
||||||
|
pageIndex: 0,
|
||||||
|
pageSize: 9,
|
||||||
|
});
|
||||||
|
|
||||||
|
const [rowSelection, setRowSelection] = React.useState<RowSelectionState>({});
|
||||||
|
const [showFilter, setShowFilter] = useState(false);
|
||||||
|
|
||||||
const columns: ColumnDef<Transaction>[] = [
|
const columns: ColumnDef<Transaction>[] = [
|
||||||
{
|
{
|
||||||
id: 'select',
|
id: 'select',
|
||||||
@@ -102,7 +114,7 @@ const columns: ColumnDef<Transaction>[] = [
|
|||||||
size="sm"
|
size="sm"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
// handleUpdate(row.id);
|
setShowModalValidate(true);
|
||||||
}}
|
}}
|
||||||
className="flex items-center gap-2 w-full"
|
className="flex items-center gap-2 w-full"
|
||||||
>
|
>
|
||||||
@@ -112,15 +124,6 @@ const columns: ColumnDef<Transaction>[] = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export const Components: FC = (): ReactElement => {
|
|
||||||
const [pagination, setPagination] = React.useState<PaginationState>({
|
|
||||||
pageIndex: 0,
|
|
||||||
pageSize: 9,
|
|
||||||
});
|
|
||||||
|
|
||||||
const [rowSelection, setRowSelection] = React.useState<RowSelectionState>({});
|
|
||||||
const [showFilter, setShowFilter] = useState(false);
|
|
||||||
|
|
||||||
const table = useReactTable({
|
const table = useReactTable({
|
||||||
data: mockTransactions,
|
data: mockTransactions,
|
||||||
columns,
|
columns,
|
||||||
@@ -138,6 +141,7 @@ export const Components: FC = (): ReactElement => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<Fragment>
|
||||||
<main className="w-full px-[48px] py-[40px] flex flex-col gap-8">
|
<main className="w-full px-[48px] py-[40px] flex flex-col gap-8">
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
<header className="bg-white py-4 px-8 rounded-lg shadow p-4">
|
<header className="bg-white py-4 px-8 rounded-lg shadow p-4">
|
||||||
@@ -180,6 +184,17 @@ export const Components: FC = (): ReactElement => {
|
|||||||
<DataTable data={mockTransactions} columns={columns} table={table} />
|
<DataTable data={mockTransactions} columns={columns} table={table} />
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
|
<ModalValidate
|
||||||
|
isOpen={showModalValidate}
|
||||||
|
onClose={() => setShowModalValidate(false)}
|
||||||
|
handleValid={() => {
|
||||||
|
console.log('Action ketika user klik Valid');
|
||||||
|
}}
|
||||||
|
handleInvalid={() => {
|
||||||
|
console.log('Action ketika user klik Tidak Valid');
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Fragment>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user