From b8c2d0ff3c4b7192a0d30359a05514668296bc09 Mon Sep 17 00:00:00 2001 From: Wikzyy Date: Wed, 9 Apr 2025 15:16:36 +0700 Subject: [PATCH 01/29] update edit provider - add field currency --- src/pages/master/wallet/blocks/EditDialog.tsx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/pages/master/wallet/blocks/EditDialog.tsx b/src/pages/master/wallet/blocks/EditDialog.tsx index adce821..14a3574 100644 --- a/src/pages/master/wallet/blocks/EditDialog.tsx +++ b/src/pages/master/wallet/blocks/EditDialog.tsx @@ -53,11 +53,13 @@ const EditDialog = () => { name: string; description: string; status: string; + currency_id: string; group: string[]; } = { name: '', description: '', status: '', + currency_id: '', group: [] }; const [formField, setFormField] = useState(initialState); @@ -164,6 +166,8 @@ const EditDialog = () => { } }; + const selectedCurrency = currencies.find((currency) => currency.ID === formField.currency_id); + const selectedGroupNames = groups .filter((g) => formField.group.includes(g.id)) .map((g) => g.name) @@ -257,6 +261,21 @@ const EditDialog = () => { +
+
+ +
+ +
+
+
+
From 203b2f204e152b179ff21704caeb1f4c57a2276d Mon Sep 17 00:00:00 2001 From: Wikzyy Date: Wed, 9 Apr 2025 16:58:11 +0700 Subject: [PATCH 02/29] fix create Wallet - change `currency_id` to `id_currency` --- src/pages/master/wallet/blocks/AddDialog.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pages/master/wallet/blocks/AddDialog.tsx b/src/pages/master/wallet/blocks/AddDialog.tsx index b6be0ff..ffe8e54 100644 --- a/src/pages/master/wallet/blocks/AddDialog.tsx +++ b/src/pages/master/wallet/blocks/AddDialog.tsx @@ -55,13 +55,13 @@ const AddDialog = () => { description: string; status: string; group: string[]; - currency_id: string; + id_currency: string; } = { name: '', description: '', status: '', group: [], - currency_id: '' + id_currency: '' }; const [formField, setFormField] = useState(initialState); const [currencies, setCurrencies] = useState([]); @@ -126,7 +126,7 @@ const AddDialog = () => { formField.description.trim() === '' || formField.status.trim() === '' || formField.group.length === 0 || - formField.currency_id.trim() === '' + formField.id_currency.trim() === '' ) { setAlert({ show: true, message: 'Please fill in all required fields.' }); return; @@ -251,8 +251,8 @@ const AddDialog = () => { Currency* @@ -294,56 +304,67 @@ const AddDialog = () => {
-
-
- - - - - - - - - { - e.currentTarget.scrollTop += e.deltaY; - }} + {formField.type === 'agent' ? ( +
+
+ + + + + + + + + { + e.currentTarget.scrollTop += e.deltaY; + }} + > + No Agent found. + + {customers.map((customer) => ( + { + setFormField({ + ...formField, + agent: customer.id + }); + setOpen(false); + }} + > + {customer.username} + + ))} + + + + + +
-
+ ) : ( +
+
+ + +
+
+ )}
-
-
- - - - - - - - - { - e.currentTarget.scrollTop += e.deltaY; - }} + {formField.type === 'agent' ? ( +
+
+ + + + + + + + + { + e.currentTarget.scrollTop += e.deltaY; + }} + > + No Agent found. + + {customers.map((customer) => ( + { + setFormField({ + ...formField, + agent: customer.id + }); + setOpen(false); + }} + > + {customer.username} + + ))} + + + + + +
-
+ ) : ( +
+
+ + +
+
+ )}
From 0c049086e9116c910e3a30da0e89ef9281b6def6 Mon Sep 17 00:00:00 2001 From: Wikzyy Date: Thu, 10 Apr 2025 13:55:00 +0700 Subject: [PATCH 06/29] fix field Wallet and Wallet Rule - sync form field with response field - sync group with wallet on create Wallet Rule --- .../wallet/hooks/ManageWalletContext.tsx | 12 ++--- .../master/walletRule/blocks/AddDialog.tsx | 44 ++++++++++++++----- .../hooks/ManageWalletRuleContext.tsx | 2 +- 3 files changed, 39 insertions(+), 19 deletions(-) diff --git a/src/pages/master/wallet/hooks/ManageWalletContext.tsx b/src/pages/master/wallet/hooks/ManageWalletContext.tsx index 0142fb8..e6592d3 100644 --- a/src/pages/master/wallet/hooks/ManageWalletContext.tsx +++ b/src/pages/master/wallet/hooks/ManageWalletContext.tsx @@ -73,7 +73,7 @@ const ManageWalletContextProvider = ({ children }: { children: React.ReactNode } const columns = useMemo[]>( () => [ { - accessorFn: (row) => row.Wallet_name, + accessorFn: (row) => row.name, id: 'name', header: ({ column }) => , enableSorting: true, @@ -83,7 +83,7 @@ const ManageWalletContextProvider = ({ children }: { children: React.ReactNode } } }, { - accessorFn: (row) => row.Wallet_description, + accessorFn: (row) => row.description, id: 'description', header: ({ column }) => , enableSorting: true, @@ -93,13 +93,13 @@ const ManageWalletContextProvider = ({ children }: { children: React.ReactNode } } }, { - accessorFn: (row) => row.Wallet_status, + accessorFn: (row) => row.status, id: 'status', header: ({ column }) => , enableSorting: true, enableHiding: false, cell: ({ row }) => { - const isActive = row.original.Wallet_status === 'Y'; + const isActive = row.original.status === 'Y'; return ( } layout={{ card: true }} - sorting={[{ id: 'created_at', desc: true }]} + sorting={[{ id: 'wallets.created_at', desc: true }]} serverSide={true} onFetchData={({ pageIndex, pageSize, sorting, columnFilters }) => getWalletLists(pageIndex, pageSize, sorting, columnFilters) diff --git a/src/pages/master/walletRule/blocks/AddDialog.tsx b/src/pages/master/walletRule/blocks/AddDialog.tsx index 6bdd088..108901c 100644 --- a/src/pages/master/walletRule/blocks/AddDialog.tsx +++ b/src/pages/master/walletRule/blocks/AddDialog.tsx @@ -40,14 +40,24 @@ interface GroupProps { status: string; } -interface WalletProps { - ID: string; +interface WalletGroupProps { + id: string; name: string; - id_currency: string; + description: string; status: string; } +interface WalletProps { + id: string; + name: string; + id_currency: string; + status: string; + group: WalletGroupProps[]; +} + const API_URL_WALLET = apiConfig.service_wallet; +const API_URL_MASTERDATA = apiConfig.service_master_data; + const AddDialog = () => { const { showAddDialog, handleAddDialog, selectedWalletRule } = useManageWalletRuleContext(); const { reload } = useDataGrid(); @@ -143,7 +153,7 @@ const AddDialog = () => { const getWalletLists = async (sorting: any) => { try { - const response = await GetData(`${API_URL_WALLET}/dashboard/wallet`, { + const response = await GetData(`${API_URL_MASTERDATA}/wallet/list`, { limit: 100, page: 1, with_deleted: false, @@ -158,8 +168,11 @@ const AddDialog = () => { } }; + const selectedWallet = wallets.find((wallet) => wallet.id === formField.id_wallet); + const filteredGroups = selectedWallet ? selectedWallet.group : []; + useEffect(() => { - getWalletLists([{ id: 'name', desc: false }]); + getWalletLists([{ id: 'wallets.name', desc: false }]); getGroupLists([{ id: 'name', desc: false }]); }, []); @@ -193,14 +206,16 @@ const AddDialog = () => { setFormField({ ...formField, id_group: value })} + disabled={filteredGroups.length === 0} > - {groups.map((group) => ( - - {group.name} - - ))} + {filteredGroups.length > 0 ? ( + filteredGroups.map((group) => ( + + {group.name} + + )) + ) : ( + No groups available + )}
diff --git a/src/pages/master/walletRule/hooks/ManageWalletRuleContext.tsx b/src/pages/master/walletRule/hooks/ManageWalletRuleContext.tsx index 9b7385b..14e66c3 100644 --- a/src/pages/master/walletRule/hooks/ManageWalletRuleContext.tsx +++ b/src/pages/master/walletRule/hooks/ManageWalletRuleContext.tsx @@ -222,7 +222,7 @@ const ManageWalletRuleContextProvider = ({ children }: { children: React.ReactNo order_direction: sorting[0].desc == false ? 'ASC' : 'DESC', filter: JSON.stringify(filter) }); - console.log(response?.data); + // console.log(response?.data); setWalletRules(response?.data.list); return { data: response?.data.list, totalCount: response?.data.total_count }; } catch (error) { From 317d160c0743fbcfda1066f763fdb1f588c4bc79 Mon Sep 17 00:00:00 2001 From: Wikzyy Date: Thu, 10 Apr 2025 14:01:06 +0700 Subject: [PATCH 07/29] fix remove Wallet Rule - remove function get list group --- .../master/walletRule/blocks/AddDialog.tsx | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/src/pages/master/walletRule/blocks/AddDialog.tsx b/src/pages/master/walletRule/blocks/AddDialog.tsx index 108901c..0e5ce46 100644 --- a/src/pages/master/walletRule/blocks/AddDialog.tsx +++ b/src/pages/master/walletRule/blocks/AddDialog.tsx @@ -87,7 +87,6 @@ const AddDialog = () => { status: '' }; const [formField, setFormField] = useState(initialState); - const [groups, setGroups] = useState([]); const [wallets, setWallets] = useState([]); const resetForm = () => { @@ -134,23 +133,6 @@ const AddDialog = () => { setAlert({ show: false, message: '' }); }; - const getGroupLists = async (sorting: any) => { - try { - const response = await GetData(`${API_URL_WALLET}/dashboard/group`, { - limit: 100, - page: 1, - with_deleted: false, - order_field: sorting[0].id, - order_direction: sorting[0].desc == false ? 'ASC' : 'DESC' - }); - - // console.log('GROUPS: ', response?.data); - setGroups(response?.data.list); - } catch (error) { - console.error('Error fetching groups', error); - } - }; - const getWalletLists = async (sorting: any) => { try { const response = await GetData(`${API_URL_MASTERDATA}/wallet/list`, { @@ -173,7 +155,6 @@ const AddDialog = () => { useEffect(() => { getWalletLists([{ id: 'wallets.name', desc: false }]); - getGroupLists([{ id: 'name', desc: false }]); }, []); useEffect(() => { From e39b4754951bd3105869c6ed4d30a9be11e9d329 Mon Sep 17 00:00:00 2001 From: Wikzyy Date: Thu, 10 Apr 2025 16:03:29 +0700 Subject: [PATCH 08/29] fix edit Wallet to sync variable formfield with response --- src/pages/master/wallet/blocks/EditDialog.tsx | 6 +++--- .../master/wallet/hooks/ManageWalletContext.tsx | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/pages/master/wallet/blocks/EditDialog.tsx b/src/pages/master/wallet/blocks/EditDialog.tsx index 14a3574..d8ff501 100644 --- a/src/pages/master/wallet/blocks/EditDialog.tsx +++ b/src/pages/master/wallet/blocks/EditDialog.tsx @@ -76,7 +76,7 @@ const EditDialog = () => { // e.preventDefault(); const response = await PutData( - `${API_URL_MASTER_DATA}/wallet/update/${selectedWallet?.Wallet_id}`, + `${API_URL_MASTER_DATA}/wallet/update/${selectedWallet?.id}`, payload ); @@ -87,7 +87,7 @@ const EditDialog = () => { const createActivity = { module: 'Manage Wallet', - description: `Edit Wallet => ${selectedWallet?.Wallet_id} - ${selectedWallet?.Wallet_name}`, + description: `Edit Wallet => ${selectedWallet?.id} - ${selectedWallet?.name}`, action: 'U' }; @@ -188,7 +188,7 @@ const EditDialog = () => { // currency_id: selectedWallet?.Wallet_currency_id, // group: selectedWallet?.Wallet_group // })); - doFetchData(selectedWallet?.Wallet_id); + doFetchData(selectedWallet?.id); } }, [selectedWallet]); diff --git a/src/pages/master/wallet/hooks/ManageWalletContext.tsx b/src/pages/master/wallet/hooks/ManageWalletContext.tsx index e6592d3..28a5a96 100644 --- a/src/pages/master/wallet/hooks/ManageWalletContext.tsx +++ b/src/pages/master/wallet/hooks/ManageWalletContext.tsx @@ -7,12 +7,12 @@ import { Toaster } from 'sonner'; import ListToolbar from '../blocks/ListToolbar'; interface WalletProps { - Wallet_id: string; - Wallet_name: string; - Wallet_status: string; - Wallet_description: string; - Wallet_group: string[]; - Wallet_currency_id: string; + id: string; + name: string; + status: string; + description: string; + group: string[]; + currency_id: string; } interface ContextProps { @@ -155,7 +155,7 @@ const ManageWalletContextProvider = ({ children }: { children: React.ReactNode } order_direction: sorting[0].desc == false ? 'ASC' : 'DESC', filter: JSON.stringify(filter) }); - console.log(response?.data); + // console.log(response?.data); setWallets(response?.data.list); return { data: response?.data.list, totalCount: response?.data.total_count }; } catch (error) { From b042f3174b5ee14f738317c0295e3a331c35dd8a Mon Sep 17 00:00:00 2001 From: bagusajisaputroo Date: Thu, 10 Apr 2025 16:33:19 +0700 Subject: [PATCH 09/29] fixing AddDialog + Managetransfertype on transactiontype --- .../transfertype/blocks/AddDialog.tsx | 114 +++--------------- .../hooks/ManageTransferTypeContext.tsx | 20 --- 2 files changed, 17 insertions(+), 117 deletions(-) diff --git a/src/pages/transfer/transfertype/blocks/AddDialog.tsx b/src/pages/transfer/transfertype/blocks/AddDialog.tsx index 5a3bfbf..ed5576f 100644 --- a/src/pages/transfer/transfertype/blocks/AddDialog.tsx +++ b/src/pages/transfer/transfertype/blocks/AddDialog.tsx @@ -41,8 +41,8 @@ import { } from '@/components/ui/command'; interface WalletProps { - Wallet_id: string; - Wallet_name: string; + id: string; + name: string; } interface CustomerProps { @@ -74,8 +74,8 @@ const AddDialog = () => { description: '', wallet_origin: '', wallet_destination: '', - wallet_fee_destination: '', - customer_fee_destination: '', + + minimum_amount: 0, maximum_amount: 0, max_transaction_per_day: 0, @@ -102,8 +102,6 @@ const AddDialog = () => { 'description', 'wallet_origin', 'wallet_destination', - 'wallet_fee_destination', - 'customer_fee_destination', 'status', 'status_approval' ]; @@ -216,13 +214,11 @@ const AddDialog = () => { limit: 100, page: 1, with_deleted: false, - order_field: 'name', + order_field: 'wallets.name', order_direction: 'ASC', - filter: JSON.stringify({ - status: 'Y' - }) }; const response = await GetData(`${API_URL_MASTERDATA}/wallet/list`, params); + console.log(response) if (response?.status && response?.data) { setWallets(response.data.list); } else { @@ -262,9 +258,11 @@ const AddDialog = () => {
{alert.show && ( - -

{alert.message}

-
+
+ +

{alert.message}

+
+
)}
@@ -396,8 +394,8 @@ const AddDialog = () => { {wallets.map((wallet, idx) => ( - - {wallet.Wallet_name} + + {wallet.name} ))} @@ -424,8 +422,8 @@ const AddDialog = () => { {wallets.map((wallet, idx) => ( - - {wallet.Wallet_name} + + {wallet.name} ))} @@ -433,86 +431,8 @@ const AddDialog = () => {
-
-
- -
- -
-
-
-
-
- -
- - - - - - - - { - e.currentTarget.scrollTop += e.deltaY; - }} - > - No Customer found. - - {customers.map((customer) => ( - { - setFormField({ - ...formField, - customer_fee_destination: customer.id - }); - setOpen(false); - }} - > - {customer.username} - - ))} - - - - - -
-
-
+ +
@@ -300,19 +317,19 @@ const AddDialog = () => { - { - const value = parseFloat(e.target.value); - setFormField({ - ...formField, - cashback_cash: isNaN(value) ? 0 : value - }); + value={formField.cashback_cash ?? ''} + thousandSeparator="." + decimalSeparator="," + allowNegative={false} + onValueChange={(values) => { + setFormField((prev) => ({ + ...prev, + cashback_cash: values.floatValue !== undefined ? values.floatValue : '' + })); }} + placeholder="Enter Cashback Cash" /> From 8ff29fc1b76670c258dd07f94a071d87477230db Mon Sep 17 00:00:00 2001 From: Wikzyy Date: Thu, 10 Apr 2025 17:51:07 +0700 Subject: [PATCH 13/29] fix create Wallet Rule - add validation empty input --- src/pages/master/walletRule/blocks/AddDialog.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/pages/master/walletRule/blocks/AddDialog.tsx b/src/pages/master/walletRule/blocks/AddDialog.tsx index 0e5ce46..043f766 100644 --- a/src/pages/master/walletRule/blocks/AddDialog.tsx +++ b/src/pages/master/walletRule/blocks/AddDialog.tsx @@ -123,7 +123,16 @@ const AddDialog = () => { const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); - if (formField.id_group.trim() === '' || formField.status.trim() === '') { + if ( + formField.id_group.trim() === '' || + formField.status.trim() === '' || + formField.id_wallet.trim() === '' || + formField.max_transaction_per_day === null || + formField.balance_minimum === null || + formField.balance_maximum === null || + formField.credit_limit === null || + formField.monthly_limit === null + ) { setAlert({ show: true, message: 'Please fill in all required fields.' }); return; } From 5a89a80d97e501c91f89834b73201bb222e2899d Mon Sep 17 00:00:00 2001 From: bagusajisaputroo Date: Thu, 10 Apr 2025 21:03:12 +0700 Subject: [PATCH 14/29] fixing DeleteDialog on transfertype --- src/pages/transfer/transfertype/blocks/DeleteDialog.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/transfer/transfertype/blocks/DeleteDialog.tsx b/src/pages/transfer/transfertype/blocks/DeleteDialog.tsx index 421e7e5..8262c45 100644 --- a/src/pages/transfer/transfertype/blocks/DeleteDialog.tsx +++ b/src/pages/transfer/transfertype/blocks/DeleteDialog.tsx @@ -37,7 +37,7 @@ const DeleteDialog = () => { setTimeout(() => toast.success('Success Delete Transaction Type'), 0); } else { setAlert({ show: true, message: response?.message }); - setTimeout(() => toast.error('Failed Delete Product'), 0); + // setTimeout(() => toast.error('Failed Delete Product'), 0); } }, [selectedTransferType, DeleteData, handleDeleteDialog, reload]); return ( From 1bfe3d47ff92653ac7104469700295a2a90d9464 Mon Sep 17 00:00:00 2001 From: bagusajisaputroo Date: Thu, 10 Apr 2025 21:15:29 +0700 Subject: [PATCH 15/29] Trying delete without hit api on Transfertype --- .../transfer/transfertype/blocks/DeleteDialog.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/pages/transfer/transfertype/blocks/DeleteDialog.tsx b/src/pages/transfer/transfertype/blocks/DeleteDialog.tsx index 8262c45..5b41295 100644 --- a/src/pages/transfer/transfertype/blocks/DeleteDialog.tsx +++ b/src/pages/transfer/transfertype/blocks/DeleteDialog.tsx @@ -19,7 +19,9 @@ const DeleteDialog = () => { message: '' }); - const doDeleteTransferType = useCallback(async () => { + + + const doDeleteTransferType = useCallback(async (id:string) => { if (!selectedTransferType) { toast.error('No Transfer Type selected'); return; @@ -40,6 +42,11 @@ const DeleteDialog = () => { // setTimeout(() => toast.error('Failed Delete Product'), 0); } }, [selectedTransferType, DeleteData, handleDeleteDialog, reload]); + + const handleDelete = ((id:string) => { + console.log(id); + // doDeleteTransferType(id); + }) return ( handleDeleteDialog(open, null)}> @@ -60,7 +67,7 @@ const DeleteDialog = () => { - From 8b399496033fc2f2c5dfe941e2106261f7bbf0d6 Mon Sep 17 00:00:00 2001 From: Wikzyy Date: Thu, 10 Apr 2025 21:40:50 +0700 Subject: [PATCH 16/29] fix create update Provider - set default value agent to null --- src/pages/master/provider/blocks/AddDialog.tsx | 4 ++-- src/pages/master/provider/blocks/EditDialog.tsx | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/pages/master/provider/blocks/AddDialog.tsx b/src/pages/master/provider/blocks/AddDialog.tsx index c49d056..875b6b7 100644 --- a/src/pages/master/provider/blocks/AddDialog.tsx +++ b/src/pages/master/provider/blocks/AddDialog.tsx @@ -68,7 +68,7 @@ const AddDialog = () => { type: string; status: string; transaction_type: string; - agent: string; + agent: string | null; created_by: string; created_at: string; } = { @@ -77,7 +77,7 @@ const AddDialog = () => { type: '', status: '', transaction_type: '', - agent: '', + agent: null, created_by: '', created_at: '' }; diff --git a/src/pages/master/provider/blocks/EditDialog.tsx b/src/pages/master/provider/blocks/EditDialog.tsx index 31af42b..f1ce287 100644 --- a/src/pages/master/provider/blocks/EditDialog.tsx +++ b/src/pages/master/provider/blocks/EditDialog.tsx @@ -58,7 +58,7 @@ const EditDialog = () => { type: string; status: string; transaction_type: string; - agent: string; + agent: string | null; updated_by: string; updated_at: string; } = { @@ -67,7 +67,7 @@ const EditDialog = () => { type: '', status: '', transaction_type: '', - agent: '', + agent: null, updated_by: '', updated_at: '' }; @@ -169,8 +169,7 @@ const EditDialog = () => { formField.description.trim() === '' || formField.type.trim() === '' || formField.status.trim() === '' || - formField.transaction_type.trim() === '' || - formField.agent.trim() === '' + formField.transaction_type.trim() === '' ) { setAlert({ show: true, message: 'Please fill in all required fields.' }); return; From 5640472e4a31dabe91cbb21f9cd2606eb642e14f Mon Sep 17 00:00:00 2001 From: wayanrivan Date: Fri, 11 Apr 2025 09:12:21 +0700 Subject: [PATCH 17/29] update title in sign in & forgot password, change name in transaction to transaction type --- src/auth/pages/jwt/Login.tsx | 194 +++++++++--------- .../jwt/reset-password/ResetPassword.tsx | 126 ++++++------ .../hooks/ApprovalTransactionContext.tsx | 2 +- .../hooks/TransactionContext.tsx | 2 +- 4 files changed, 168 insertions(+), 156 deletions(-) diff --git a/src/auth/pages/jwt/Login.tsx b/src/auth/pages/jwt/Login.tsx index 28a283f..f8c0a64 100644 --- a/src/auth/pages/jwt/Login.tsx +++ b/src/auth/pages/jwt/Login.tsx @@ -9,6 +9,7 @@ import { useAuthContext } from '@/auth'; import { useLayout } from '@/providers'; import { Alert } from '@/components'; import moment from 'moment'; +import { Helmet } from 'react-helmet'; const loginSchema = Yup.object().shape({ username: Yup.string().required('Username is required'), @@ -76,101 +77,106 @@ const Login = () => { }; return ( -
- -
-

Sign in

-
- {formik.status && {formik.status}} -
- - - {formik.touched.username && formik.errors.username && ( - - {formik.errors.username} - - )} -
- -
-
- -
- - {formik.touched.password && formik.errors.password && ( - - {formik.errors.password} - - )} -
- -
- - - Forgot Password? - -
- - -
-

- Copyright {moment().year()} © Telkomcel All rights reserved. -

-
- -
+
+

Sign in

+
+ {formik.status && {formik.status}} +
+ + + {formik.touched.username && formik.errors.username && ( + + {formik.errors.username} + + )} +
+ +
+
+ +
+ + {formik.touched.password && formik.errors.password && ( + + {formik.errors.password} + + )} +
+ +
+ + + Forgot Password? + +
+ + +
+

+ Copyright {moment().year()} © Telkomcel All rights reserved. +

+
+ + + ); }; diff --git a/src/auth/pages/jwt/reset-password/ResetPassword.tsx b/src/auth/pages/jwt/reset-password/ResetPassword.tsx index f8db220..857219c 100644 --- a/src/auth/pages/jwt/reset-password/ResetPassword.tsx +++ b/src/auth/pages/jwt/reset-password/ResetPassword.tsx @@ -9,6 +9,7 @@ import { useAuthContext } from '@/auth/useAuthContext'; import { Alert, KeenIcon } from '@/components'; import { useLayout } from '@/providers'; import { AxiosError } from 'axios'; +import { Helmet } from 'react-helmet'; const initialValues = { email: '' @@ -64,70 +65,75 @@ const ResetPassword = () => { } }); return ( -
-
-
-

Your Email

- - Enter your email to reset password - -
- - {hasErrors && {formik.status}} - - {hasErrors === false && ( - - Password reset link sent. Please check your email to proceed - - )} - -
- - - {formik.touched.email && formik.errors.email && ( - - {formik.errors.email} + <> + + TPAY | Reset Password + +
+ +
+

Your Email

+ + Enter your email to reset password +
+ + {hasErrors && {formik.status}} + + {hasErrors === false && ( + + Password reset link sent. Please check your email to proceed + )} -
-
- +
+ + + {formik.touched.email && formik.errors.email && ( + + {formik.errors.email} + + )} +
- - - Back to Login - -
- -
+
+ + + + + Back to Login + +
+ +
+ ); }; diff --git a/src/pages/transaction/approval-transaction/hooks/ApprovalTransactionContext.tsx b/src/pages/transaction/approval-transaction/hooks/ApprovalTransactionContext.tsx index 5564f0d..fb4536c 100644 --- a/src/pages/transaction/approval-transaction/hooks/ApprovalTransactionContext.tsx +++ b/src/pages/transaction/approval-transaction/hooks/ApprovalTransactionContext.tsx @@ -155,7 +155,7 @@ const ApprovalTransactionProvider = ({ children }: { children: React.ReactNode } }, { accessorKey: 'type.name', - header: ({ column }) => , + header: ({ column }) => , enableSorting: false, enableHiding: false, meta: { diff --git a/src/pages/transaction/history-transaction/hooks/TransactionContext.tsx b/src/pages/transaction/history-transaction/hooks/TransactionContext.tsx index 5e28d8f..273dd4f 100644 --- a/src/pages/transaction/history-transaction/hooks/TransactionContext.tsx +++ b/src/pages/transaction/history-transaction/hooks/TransactionContext.tsx @@ -157,7 +157,7 @@ const TransactionProvider = ({ children }: { children: React.ReactNode }) => { }, { accessorKey: 'type.name', - header: ({ column }) => , + header: ({ column }) => , enableSorting: false, enableHiding: false, meta: { From adfc42644292e6116ea4b8a524c334c10b034b58 Mon Sep 17 00:00:00 2001 From: bagusajisaputroo Date: Fri, 11 Apr 2025 10:11:12 +0700 Subject: [PATCH 18/29] Fixing add, delete, and managetransfertype on transfertype --- src/pages/transfer/transfertype/blocks/AddDialog.tsx | 4 ++-- src/pages/transfer/transfertype/blocks/DeleteDialog.tsx | 7 ++++--- .../transfertype/hooks/ManageTransferTypeContext.tsx | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/pages/transfer/transfertype/blocks/AddDialog.tsx b/src/pages/transfer/transfertype/blocks/AddDialog.tsx index ed5576f..19760af 100644 --- a/src/pages/transfer/transfertype/blocks/AddDialog.tsx +++ b/src/pages/transfer/transfertype/blocks/AddDialog.tsx @@ -218,7 +218,7 @@ const AddDialog = () => { order_direction: 'ASC', }; const response = await GetData(`${API_URL_MASTERDATA}/wallet/list`, params); - console.log(response) + // console.log(response) if (response?.status && response?.data) { setWallets(response.data.list); } else { @@ -230,7 +230,7 @@ const AddDialog = () => { if (!showAddDialog) return; fetchWallets(); }, [showAddDialog]); - + // console.log(formField) return ( handleAddDialog(open)}> diff --git a/src/pages/transfer/transfertype/blocks/DeleteDialog.tsx b/src/pages/transfer/transfertype/blocks/DeleteDialog.tsx index 5b41295..ce6a1b8 100644 --- a/src/pages/transfer/transfertype/blocks/DeleteDialog.tsx +++ b/src/pages/transfer/transfertype/blocks/DeleteDialog.tsx @@ -21,7 +21,7 @@ const DeleteDialog = () => { - const doDeleteTransferType = useCallback(async (id:string) => { + const doDeleteTransferType = useCallback(async (id:string|null) => { if (!selectedTransferType) { toast.error('No Transfer Type selected'); return; @@ -43,10 +43,11 @@ const DeleteDialog = () => { } }, [selectedTransferType, DeleteData, handleDeleteDialog, reload]); - const handleDelete = ((id:string) => { + const handleDelete = ((id:string|null) => { console.log(id); - // doDeleteTransferType(id); + doDeleteTransferType(id); }) + return ( handleDeleteDialog(open, null)}> diff --git a/src/pages/transfer/transfertype/hooks/ManageTransferTypeContext.tsx b/src/pages/transfer/transfertype/hooks/ManageTransferTypeContext.tsx index 416eef0..f5fcd14 100644 --- a/src/pages/transfer/transfertype/hooks/ManageTransferTypeContext.tsx +++ b/src/pages/transfer/transfertype/hooks/ManageTransferTypeContext.tsx @@ -70,8 +70,8 @@ const ManageTransferTypeContextProvider = ({ children }: { children: React.React }, []); const handleDeleteDialog = useCallback((show: boolean, selected_transfertype: string | null) => { - setShowDeleteDialog(show); setSelectedTransferType(show ? selected_transfertype : null); + setShowDeleteDialog(show); }, []); const columns = useMemo[]>( From a1572ae9c84d7918ac9a0cb0ddb8325b39fcfb42 Mon Sep 17 00:00:00 2001 From: Raja Oktafrianto Date: Fri, 11 Apr 2025 10:12:33 +0700 Subject: [PATCH 19/29] fixing update type reward & user --- src/pages/master/reward/blocks/AddDialog.tsx | 35 ++++++++++++++----- src/pages/master/reward/blocks/EditDialog.tsx | 32 +++++++++++++---- .../reward/hooks/ManageRewardContext.tsx | 2 +- .../user/manage-user/blocks/AddDialog.tsx | 14 +++++--- .../manage-user/hooks/ManageUserContext.tsx | 2 +- 5 files changed, 64 insertions(+), 21 deletions(-) diff --git a/src/pages/master/reward/blocks/AddDialog.tsx b/src/pages/master/reward/blocks/AddDialog.tsx index 9f44be0..cb74206 100644 --- a/src/pages/master/reward/blocks/AddDialog.tsx +++ b/src/pages/master/reward/blocks/AddDialog.tsx @@ -55,6 +55,13 @@ const AddDialog = () => { setAlert({ show: false, message: '' }); }; + const RewardType = { + 'Daily Check in': 'D', + Referal: 'R' + } as const; + + type RewardTypeValue = (typeof RewardType)[keyof typeof RewardType]; + const doCreateReward = useCallback( async (e: React.FormEvent) => { e.preventDefault(); @@ -140,15 +147,25 @@ const AddDialog = () => { Type* - - setFormField((prev) => ({ ...prev, type: target.value })) - } - /> +
+ +
- setFormField({ ...formField, type: e.target.value })} - /> +
+ +
)} From ebc1037143492557f10fe2e038e4c7c36bb794ec Mon Sep 17 00:00:00 2001 From: Raja Oktafrianto Date: Fri, 11 Apr 2025 10:39:00 +0700 Subject: [PATCH 24/29] update type reward --- src/pages/master/reward/blocks/AddDialog.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pages/master/reward/blocks/AddDialog.tsx b/src/pages/master/reward/blocks/AddDialog.tsx index cb74206..6e32603 100644 --- a/src/pages/master/reward/blocks/AddDialog.tsx +++ b/src/pages/master/reward/blocks/AddDialog.tsx @@ -57,7 +57,9 @@ const AddDialog = () => { const RewardType = { 'Daily Check in': 'D', - Referal: 'R' + Referal: 'R', + 'Level Pro': 'P', + 'Level Prioritas': 'L' } as const; type RewardTypeValue = (typeof RewardType)[keyof typeof RewardType]; From cb9b0e96a40a286ee385bf73d4fb9cbe77e602ad Mon Sep 17 00:00:00 2001 From: bagusajisaputroo Date: Fri, 11 Apr 2025 11:31:43 +0700 Subject: [PATCH 25/29] Trying add reload page in DeleteDialog on transfertype --- .../transfertype/blocks/DeleteDialog.tsx | 59 +++++++++++-------- 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/src/pages/transfer/transfertype/blocks/DeleteDialog.tsx b/src/pages/transfer/transfertype/blocks/DeleteDialog.tsx index ce6a1b8..d6fbe7f 100644 --- a/src/pages/transfer/transfertype/blocks/DeleteDialog.tsx +++ b/src/pages/transfer/transfertype/blocks/DeleteDialog.tsx @@ -19,34 +19,48 @@ const DeleteDialog = () => { message: '' }); - - - const doDeleteTransferType = useCallback(async (id:string|null) => { + const doDeleteTransferType = useCallback(async () => { if (!selectedTransferType) { toast.error('No Transfer Type selected'); return; } - // Kirim enforce=false untuk memastikan soft delete - const response = await DeleteData(`${API_URL}/transactiontype/delete/${selectedTransferType}/false`, { - id: selectedTransferType - }); + try { + // Kirim enforce=false untuk memastikan soft delete + const response = await DeleteData(`${API_URL}/transactiontype/delete/${selectedTransferType}/false`, { + id: selectedTransferType + }); - if (response?.status) { - setAlert({ show: false, message: '' }); - handleDeleteDialog(false, null); - reload(); - setTimeout(() => toast.success('Success Delete Transaction Type'), 0); - } else { - setAlert({ show: true, message: response?.message }); - // setTimeout(() => toast.error('Failed Delete Product'), 0); + console.log("status", response?.status) + + if (response?.status) { + setAlert({ show: false, message: '' }); + handleDeleteDialog(false, null); + + // First reload the data grid + reload(); + + // Show success toast + toast.success('Success Delete Transaction Type'); + + // Then reload the entire page after a short delay + setTimeout(() => { + window.location.reload(); + }, 300); // Small delay to ensure the toast is visible + } else { + setAlert({ show: true, message: response?.message || 'Failed to delete transaction type' }); + } + } catch (error) { + console.error('Delete error:', error); + setAlert({ show: true, message: 'An error occurred while deleting' }); } }, [selectedTransferType, DeleteData, handleDeleteDialog, reload]); - const handleDelete = ((id:string|null) => { - console.log(id); - doDeleteTransferType(id); - }) + const handleDelete = () => { + doDeleteTransferType(); + }; + + console.log('selectedTransferType:', selectedTransferType); return ( handleDeleteDialog(open, null)}> @@ -65,10 +79,10 @@ const DeleteDialog = () => { )} - - @@ -77,5 +91,4 @@ const DeleteDialog = () => { ); }; -export default DeleteDialog; -export { DeleteDialog }; +export default DeleteDialog; \ No newline at end of file From 45d251368a7a6e0300a111eb32bf6ac1aee3b56b Mon Sep 17 00:00:00 2001 From: bagusajisaputroo Date: Fri, 11 Apr 2025 11:41:14 +0700 Subject: [PATCH 26/29] trying fix delete issue on transfer type --- .../transfer/transfertype/TransferType.tsx | 4 +- .../transfertype/blocks/DeleteDialog.tsx | 53 ++++++------------- 2 files changed, 17 insertions(+), 40 deletions(-) diff --git a/src/pages/transfer/transfertype/TransferType.tsx b/src/pages/transfer/transfertype/TransferType.tsx index 49d7abe..ab79eca 100644 --- a/src/pages/transfer/transfertype/TransferType.tsx +++ b/src/pages/transfer/transfertype/TransferType.tsx @@ -5,7 +5,7 @@ import { } from './hooks/ManageTransferTypeContext'; import AddDialog from './blocks/AddDialog'; import { Breadcrumbs, Link } from '@mui/material'; -import { DeleteDialog } from './blocks/DeleteDialog'; +import DeleteDialog from './blocks/DeleteDialog'; import { EditDialog } from './blocks/EditDialog'; import { Helmet } from 'react-helmet'; @@ -37,7 +37,7 @@ const TransferType = () => { - + {/* */} diff --git a/src/pages/transfer/transfertype/blocks/DeleteDialog.tsx b/src/pages/transfer/transfertype/blocks/DeleteDialog.tsx index d6fbe7f..19e4d78 100644 --- a/src/pages/transfer/transfertype/blocks/DeleteDialog.tsx +++ b/src/pages/transfer/transfertype/blocks/DeleteDialog.tsx @@ -25,43 +25,20 @@ const DeleteDialog = () => { return; } - try { - // Kirim enforce=false untuk memastikan soft delete - const response = await DeleteData(`${API_URL}/transactiontype/delete/${selectedTransferType}/false`, { - id: selectedTransferType - }); + const response = await DeleteData(`${API_URL}/transactiontype/delete/${selectedTransferType}/false`, { + id: selectedTransferType + }); - console.log("status", response?.status) - - if (response?.status) { - setAlert({ show: false, message: '' }); - handleDeleteDialog(false, null); - - // First reload the data grid - reload(); - - // Show success toast - toast.success('Success Delete Transaction Type'); - - // Then reload the entire page after a short delay - setTimeout(() => { - window.location.reload(); - }, 300); // Small delay to ensure the toast is visible - } else { - setAlert({ show: true, message: response?.message || 'Failed to delete transaction type' }); - } - } catch (error) { - console.error('Delete error:', error); - setAlert({ show: true, message: 'An error occurred while deleting' }); + if (response?.status) { + setAlert({ show: false, message: '' }); + handleDeleteDialog(false, null); + reload(); + // setTimeout(() => toast.success('Success Delete Transaction Type'), 0); + } else { + setAlert({ show: true, message: response?.message }); + // setTimeout(() => toast.error('Failed Delete Product'), 0); } - }, [selectedTransferType, DeleteData, handleDeleteDialog, reload]); - - const handleDelete = () => { - doDeleteTransferType(); - }; - - console.log('selectedTransferType:', selectedTransferType); - + }, [selectedTransferType]); return ( handleDeleteDialog(open, null)}> @@ -79,10 +56,10 @@ const DeleteDialog = () => { )} - - @@ -91,4 +68,4 @@ const DeleteDialog = () => { ); }; -export default DeleteDialog; \ No newline at end of file +export default DeleteDialog; From 9109b9d688e2f3e75bde6892e81e30b97e83229f Mon Sep 17 00:00:00 2001 From: bagusajisaputroo Date: Fri, 11 Apr 2025 13:45:37 +0700 Subject: [PATCH 27/29] Fixing "amount" on table wallet history --- .../hooks/ManageWalletHistoryContext.tsx | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/pages/wallet/wallet-history/hooks/ManageWalletHistoryContext.tsx b/src/pages/wallet/wallet-history/hooks/ManageWalletHistoryContext.tsx index 95b7aca..e2b2edd 100644 --- a/src/pages/wallet/wallet-history/hooks/ManageWalletHistoryContext.tsx +++ b/src/pages/wallet/wallet-history/hooks/ManageWalletHistoryContext.tsx @@ -82,7 +82,7 @@ const ManageWalletContextProvider = ({ children }: { children: React.ReactNode } }, { accessorKey: 'amount' , - header: ({ column }) => , + header: ({ column }) => , enableSorting: false, enableHiding: false, meta: { @@ -108,8 +108,10 @@ const ManageWalletContextProvider = ({ children }: { children: React.ReactNode } } }, { - accessorKey: 'CreatedAt' , - header: ({ column }) => , + accessorKey: 'CreatedAt', + header: ({ column }) => ( + + ), cell: ({ row }) => new Date(row.original.CreatedAt).toLocaleString('id-ID', { day: '2-digit', @@ -118,7 +120,7 @@ const ManageWalletContextProvider = ({ children }: { children: React.ReactNode } hour: '2-digit', minute: '2-digit', }), - enableSorting: false, + enableSorting: false, enableHiding: false, meta: { headerClassName: 'w-[200px]' @@ -174,26 +176,24 @@ const ManageWalletContextProvider = ({ children }: { children: React.ReactNode } headerClassName: 'w-[200px]' } } - ], [] ); - - const getWalletLists = async (page: number, limit: number, sorting: any, filter: any) => { try { - sorting = sorting.length == 0 ? [{ id: 'name', desc: false }] : sorting; + const sortField = 'CreatedAt'; + const sortDirection = 'ASC'; + filter = filter.length == 0 ? {} : { name: filter[0].value?.toLowerCase() }; const response = await GetData(`${API_URL_WALLET}/dashboard/balance/`, { limit, page: page + 1, with_deleted: false, - order_field: sorting[0].id, - order_direction: sorting[0].desc == false ? 'ASC' : 'DESC', + order_field: sortField, + order_direction: sortDirection, // filter: JSON.stringify(filter) }); - // console.log(response?.data); setWallets(response?.data.list); return { data: response?.data.list, totalCount: response?.data.total_count }; } catch (error) { @@ -221,7 +221,7 @@ const ManageWalletContextProvider = ({ children }: { children: React.ReactNode } pagination={{ size: 10 }} toolbar={} layout={{ card: true }} - sorting={[{ id: 'id', desc: false }]} + // sorting={[{ id: 'created_at', desc: true }]} serverSide={true} onFetchData={({ pageIndex, pageSize, sorting, columnFilters }) => getWalletLists(pageIndex, pageSize, sorting, columnFilters) @@ -234,4 +234,4 @@ const ManageWalletContextProvider = ({ children }: { children: React.ReactNode } }; export { ManageWalletContext, ManageWalletContextProvider }; -export type { WalletProps }; +export type { WalletProps }; \ No newline at end of file From f959a477f191b77d32c366345a33ca437292cb58 Mon Sep 17 00:00:00 2001 From: wayanrivan Date: Fri, 11 Apr 2025 14:22:20 +0700 Subject: [PATCH 28/29] Update approval transaction --- .../blocks/ApprovalDialog.tsx | 83 +++++-- .../blocks/DetailApprovalTransaction.tsx | 233 ++++++++++++------ .../blocks/ListToolbar.tsx | 8 +- .../hooks/ApprovalTransactionContext.tsx | 43 ++-- .../blocks/DetailTransaction.tsx | 188 ++++++++------ .../blocks/ListToolbar.tsx | 8 +- .../hooks/TransactionContext.tsx | 56 +++-- 7 files changed, 395 insertions(+), 224 deletions(-) diff --git a/src/pages/transaction/approval-transaction/blocks/ApprovalDialog.tsx b/src/pages/transaction/approval-transaction/blocks/ApprovalDialog.tsx index 6108b50..779e189 100644 --- a/src/pages/transaction/approval-transaction/blocks/ApprovalDialog.tsx +++ b/src/pages/transaction/approval-transaction/blocks/ApprovalDialog.tsx @@ -1,14 +1,13 @@ import { useTransactionContext } from '../hooks/useApprovalTransactionContext'; import { useCallApi } from '@/hooks'; import { apiConfig } from '@/config/api.config'; -import { useCallback, useEffect, useRef, useState } from 'react'; +import { useCallback, useEffect, useState } from 'react'; import { Dialog, DialogBody, DialogContent, - DialogDescription, DialogHeader, - DialogTitle + DialogTitle, } from '@/components/ui/dialog'; import { Button } from '@/components/ui/button'; import { @@ -16,9 +15,9 @@ import { SelectContent, SelectItem, SelectTrigger, - SelectValue + SelectValue, } from '@/components/ui/select'; -import { Alert, KeenIcon, useDataGrid } from '@/components'; +import { Alert, useDataGrid } from '@/components'; import { doSaveLogActivity } from '@/actions/GlobalActions'; import { toast } from 'sonner'; import { Input } from '@/components/ui/input'; @@ -27,11 +26,11 @@ const API_URL = apiConfig.transaction; const ApprovalDialog = () => { const { GetData, PostData } = useCallApi(); - // const { reload } = useDataGrid(); + const { showApprovalDialog, setShowApprovalDialog, - selectedTransactionIdForApproval + selectedTransactionIdForApproval, } = useTransactionContext(); const [transactionDetails, setTransactionDetails] = useState(null); @@ -39,12 +38,12 @@ const ApprovalDialog = () => { const [formField, setFormField] = useState({ transaction_code: '', status: '', - notes: '' + notes: '', }); const [alert, setAlert] = useState({ show: false, - message: '' + message: '', }); const doApproval = useCallback( @@ -60,39 +59,51 @@ const ApprovalDialog = () => { toast.error('Please select a status.'); return; } - const response = await PostData(`${API_URL}/transaction/set-approval`, { - transaction_code: transactionDetails.id, + id_transaction: transactionDetails.id, status: formField.status, - notes: formField.notes + notes: formField.notes, }); if (response?.status) { - setAlert((prev) => ({ ...prev, show: false, message: '' })); + setAlert({ show: false, message: '' }); toast.success('Success Update Position'); const createActivity = { module: 'Approval Transaction', description: `Change status approve for transaction => ${transactionDetails.code}`, - action: 'U' + action: 'U', }; doSaveLogActivity(createActivity); - setShowApprovalDialog(false); // optionally close dialog + setShowApprovalDialog(false); } else { - setAlert((prev) => ({ ...prev, show: true, message: response?.message })); + setAlert({ show: true, message: response?.message }); } }, [formField, transactionDetails] ); + useEffect(() => { + if (showApprovalDialog) { + // Reset form fields when dialog opens + setFormField({ + transaction_code: '', + status: '', + notes: '', + }); + setTransactionDetails(null); // Optional reset + } + }, [showApprovalDialog]); + useEffect(() => { const fetchTransactionDetails = async () => { if (selectedTransactionIdForApproval) { try { - const response = await GetData(`${API_URL}/transaction/history/detail/${selectedTransactionIdForApproval}`, { - id: selectedTransactionIdForApproval - }); - // console.log(response?.data.code); - // console.log(selectedTransactionIdForApproval); + const response = await GetData( + `${API_URL}/transaction/history/detail/${selectedTransactionIdForApproval}`, + { + id: selectedTransactionIdForApproval, + } + ); setTransactionDetails(response?.data); } catch (error) { console.error('Error fetching transaction', error); @@ -105,6 +116,15 @@ const ApprovalDialog = () => { } }, [showApprovalDialog, selectedTransactionIdForApproval, GetData]); + // Set formField.transaction_code once details are fetched + useEffect(() => { + if (transactionDetails) { + setFormField((prev) => ({ + ...prev, + transaction_code: transactionDetails.id ?? '', + })); + } + }, [transactionDetails]); return ( @@ -113,7 +133,7 @@ const ApprovalDialog = () => { Approval Transaction -
+
@@ -122,7 +142,9 @@ const ApprovalDialog = () => {
+ onChange={(e) => + setFormField((prev) => ({ + ...prev, + notes: e.target.value, + })) + } + />
)} @@ -164,4 +193,4 @@ const ApprovalDialog = () => { ); }; -export default ApprovalDialog; +export default ApprovalDialog; \ No newline at end of file diff --git a/src/pages/transaction/approval-transaction/blocks/DetailApprovalTransaction.tsx b/src/pages/transaction/approval-transaction/blocks/DetailApprovalTransaction.tsx index e0d0ecc..e032a94 100644 --- a/src/pages/transaction/approval-transaction/blocks/DetailApprovalTransaction.tsx +++ b/src/pages/transaction/approval-transaction/blocks/DetailApprovalTransaction.tsx @@ -66,6 +66,24 @@ const DetailApprovalTransaction = () => { > Origin Customer + + +

Status

-

+

{(() => { let status; + let badgeClass; if (transactionDetails?.status === 'C') { status = 'COMPLETE'; + badgeClass = 'bg-green-100 text-green-800'; } else if (transactionDetails?.status === 'F') { status = 'FAILED'; + badgeClass = 'bg-red-100 text-red-800'; } else if (transactionDetails?.status === 'O') { status = 'ON PROCESS'; + badgeClass = 'bg-blue-100 text-blue-800'; } else { status = 'PENDING'; + badgeClass = 'bg-gray-100 text-gray-800'; } - return status; + + return ( + + {status} + + ); })()} -

+
+

Transaction Type

@@ -172,14 +201,7 @@ const DetailApprovalTransaction = () => {
-
-

Name

-

{transactionDetails?.origin_wallet.name}

-
-
-

Description

-

{transactionDetails?.origin_wallet.description}

-
+

@@ -208,8 +230,54 @@ const DetailApprovalTransaction = () => {

)} + {activeTab === 'detail' && transactionDetails?.kind === 'P' && ( +
+

+ Product Information + + Product Info + +

+
+
+

Product Name

+

{transactionDetails?.purchase.product.name}

+
+
+

Price Cash

+ {new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(transactionDetails?.purchase.product.price_cash)} +
+
+

Price Point

+

{transactionDetails?.purchase.product.price_point}

+
+
+

Product Type

+

{transactionDetails?.purchase.product.type}

+
+
+

Provider Name

+

{transactionDetails?.purchase.product.provider.description}

+
+
+

Provider Type

+

+ {(() => { + let providertype; + if (transactionDetails?.purchase.product.provider.type === 'h2h') { + providertype = 'HOST TO HOST'; + } else if (transactionDetails?.purchase.product.provider.type === 'agent') { + providertype = 'AGENT'; + } + return providertype; + })()} +

+
+
+
+ )} - {activeTab === 'detail' && transactionDetails?.kind != 'P' && transactionDetails?.transfer!=null && ( + {activeTab === 'detail' && transactionDetails?.kind != 'P' && transactionDetails?.transfer != null && (

Transaction Information @@ -291,69 +359,9 @@ const DetailApprovalTransaction = () => {

{transactionDetails?.transfer.destination_iban}

- -

- Destination Wallet - - Wallet - -

-
-
-

Name

-

{transactionDetails?.transfer.destination_wallet.name}

-
-
-

Description

-

{transactionDetails?.transfer.destination_wallet.description}

-
-
- -

- Destination Customer - - Destination Customer - -

-
-
-

Name

-

{transactionDetails?.transfer.destination_customer.fullname}

-
-
-

MSISDN

-

{transactionDetails?.transfer.destination_customer.msisdn}

-
-
-

Email

-

{transactionDetails?.transfer.destination_customer.email}

-
-
-

MSISDN

-

{transactionDetails?.transfer.destination_customer.username}

-
-
- -

- Origin Wallet - - Wallet - -

-
-
-

Name

-

{transactionDetails?.origin_wallet.name}

-
-
-

Description

-

{transactionDetails?.origin_wallet.description}

-
-
)} - {activeTab === 'origincustomer' && (

Origin Customer

@@ -378,6 +386,68 @@ const DetailApprovalTransaction = () => {
)} + {activeTab === 'destinationcustomer' && ( +
+

Destination Customer

+
+
+

Name

+

{transactionDetails?.transfer.destination_customer.fullname}

+
+
+

MSISDN

+

{transactionDetails?.transfer.destination_customer.msisdn}

+
+
+

Email

+

{transactionDetails?.transfer.destination_customer.email}

+
+
+

Username

+

{transactionDetails?.transfer.destination_customer.username}

+
+
+
+ )} + + {activeTab === 'originwallet' && ( +
+

Origin Wallet

+
+
+

Name

+

{transactionDetails?.origin_wallet.name}

+
+
+

Description

+

{transactionDetails?.origin_wallet.description}

+
+
+
+ )} + + {activeTab === 'destinationwallet' && ( +
+

Destination Wallet

+ + {!transactionDetails?.transfer ? ( +
No Data available
+ ) : ( +
+
+

Name

+

{transactionDetails.transfer.destination_wallet.name}

+
+
+

Description

+

{transactionDetails.transfer.destination_wallet.description}

+
+
+ )} +
+ )} + + {activeTab === 'log' && (

Transaction Logs

@@ -443,8 +513,8 @@ const DetailApprovalTransaction = () => { Status - Created At - Updated At + Date + {/* Updated At */} @@ -466,8 +536,19 @@ const DetailApprovalTransaction = () => { return status; })()} - {log.created_at} - {log.updated_at} + + {new Date(log.created_at).toLocaleString('sv-SE', { + timeZone: 'Asia/Jakarta', // kalau kamu mau waktu lokal (optional) + year: 'numeric', + month: '2-digit', + day: '2-digit', + hour: '2-digit', + minute: '2-digit', + second: '2-digit', + hour12: false, + }).replace(' ', ' ')} + + {/* {log.updated_at} */} )) ) : ( diff --git a/src/pages/transaction/approval-transaction/blocks/ListToolbar.tsx b/src/pages/transaction/approval-transaction/blocks/ListToolbar.tsx index 3247955..3a82db3 100644 --- a/src/pages/transaction/approval-transaction/blocks/ListToolbar.tsx +++ b/src/pages/transaction/approval-transaction/blocks/ListToolbar.tsx @@ -18,12 +18,10 @@ const ListToolbar = () => { // useEffect to set the default date values useEffect(() => { const today = new Date(); - const nextWeek = new Date(today); - nextWeek.setDate(today.getDate() + 7); - + const firstDayOfMonth = new Date(today.getFullYear(), today.getMonth(), 1); settrxDate({ - from: formatDate(today), // Set 'from' to today - to: formatDate(nextWeek), // Set 'to' to 7 days later + from: formatDate(firstDayOfMonth), + to: formatDate(today), }); }, []); diff --git a/src/pages/transaction/approval-transaction/hooks/ApprovalTransactionContext.tsx b/src/pages/transaction/approval-transaction/hooks/ApprovalTransactionContext.tsx index fb4536c..c8b5854 100644 --- a/src/pages/transaction/approval-transaction/hooks/ApprovalTransactionContext.tsx +++ b/src/pages/transaction/approval-transaction/hooks/ApprovalTransactionContext.tsx @@ -155,7 +155,7 @@ const ApprovalTransactionProvider = ({ children }: { children: React.ReactNode } }, { accessorKey: 'type.name', - header: ({ column }) => , + header: ({ column }) => , enableSorting: false, enableHiding: false, meta: { @@ -163,22 +163,35 @@ const ApprovalTransactionProvider = ({ children }: { children: React.ReactNode } }, }, { - accessorFn: (row) => { - switch (row.status_approve) { - case 'W': return 'WAITING APPROVAL'; - case 'Y': return 'APPROVED'; - case 'N': return 'REJECTED'; - default: return 'PENDING'; + accessorKey: 'status_approve', + header: 'Status', + cell: ({ row }) => { + const statusCode = row.original.status_approve; + let label = ''; + let badgeClass = ''; + + switch (statusCode) { + case 'Y': + label = 'APPROVED'; + badgeClass = 'bg-green-100 text-green-800'; + break; + case 'N': + label = 'REJECTED'; + badgeClass = 'bg-red-100 text-red-800'; + break; + case 'W': + label = 'WAITING APPROVAL'; + badgeClass = 'bg-gray-100 text-gray-800'; + break; } + + return ( + + {label} + + ); }, - id: 'status_approve', - header: ({ column }) => , - enableSorting: false, - enableHiding: false, - meta: { - headerClassName: 'w-[250px]', - }, - }, + }, { id: 'actions', header: ({ column }) => , diff --git a/src/pages/transaction/history-transaction/blocks/DetailTransaction.tsx b/src/pages/transaction/history-transaction/blocks/DetailTransaction.tsx index 6b44bdc..55db0a0 100644 --- a/src/pages/transaction/history-transaction/blocks/DetailTransaction.tsx +++ b/src/pages/transaction/history-transaction/blocks/DetailTransaction.tsx @@ -30,7 +30,6 @@ const DetailTransaction = () => { const response = await GetData(`${API_URL}/transaction/history/detail/${selectedTransactionId}`, { id: selectedTransactionId }); - // console.log(response?.data); setTransactionDetails(response?.data); } catch (error) { console.error('Error fetching transaction', error); @@ -66,6 +65,24 @@ const DetailTransaction = () => { > Origin Customer + + +

Status

-

+

{(() => { let status; + let badgeClass; if (transactionDetails?.status === 'C') { status = 'COMPLETE'; + badgeClass = 'bg-green-100 text-green-800'; } else if (transactionDetails?.status === 'F') { status = 'FAILED'; + badgeClass = 'bg-red-100 text-red-800'; } else if (transactionDetails?.status === 'O') { status = 'ON PROCESS'; + badgeClass = 'bg-blue-100 text-blue-800'; } else { status = 'PENDING'; + badgeClass = 'bg-gray-100 text-gray-800'; } - return status; + + return ( + + {status} + + ); })()} -

+
+

Transaction Type

@@ -172,14 +200,7 @@ const DetailTransaction = () => {
-
-

Name

-

{transactionDetails?.origin_wallet.name}

-
-
-

Description

-

{transactionDetails?.origin_wallet.description}

-
+

@@ -246,7 +267,7 @@ const DetailTransaction = () => { providertype = 'HOST TO HOST'; } else if (transactionDetails?.purchase.product.provider.type === 'agent') { providertype = 'AGENT'; - } + } return providertype; })()}

@@ -337,69 +358,9 @@ const DetailTransaction = () => {

{transactionDetails?.transfer.destination_iban}

- -

- Destination Wallet - - Wallet - -

-
-
-

Name

-

{transactionDetails?.transfer.destination_wallet.name}

-
-
-

Description

-

{transactionDetails?.transfer.destination_wallet.description}

-
-
- -

- Destination Customer - - Destination Customer - -

-
-
-

Name

-

{transactionDetails?.transfer.destination_customer.fullname}

-
-
-

MSISDN

-

{transactionDetails?.transfer.destination_customer.msisdn}

-
-
-

Email

-

{transactionDetails?.transfer.destination_customer.email}

-
-
-

MSISDN

-

{transactionDetails?.transfer.destination_customer.username}

-
-
- -

- Origin Wallet - - Wallet - -

-
-
-

Name

-

{transactionDetails?.origin_wallet.name}

-
-
-

Description

-

{transactionDetails?.origin_wallet.description}

-
-
)} - {activeTab === 'origincustomer' && (

Origin Customer

@@ -424,6 +385,68 @@ const DetailTransaction = () => {
)} + {activeTab === 'destinationcustomer' && ( +
+

Destination Customer

+
+
+

Name

+

{transactionDetails?.transfer.destination_customer.fullname}

+
+
+

MSISDN

+

{transactionDetails?.transfer.destination_customer.msisdn}

+
+
+

Email

+

{transactionDetails?.transfer.destination_customer.email}

+
+
+

Username

+

{transactionDetails?.transfer.destination_customer.username}

+
+
+
+ )} + + {activeTab === 'originwallet' && ( +
+

Origin Wallet

+
+
+

Name

+

{transactionDetails?.origin_wallet.name}

+
+
+

Description

+

{transactionDetails?.origin_wallet.description}

+
+
+
+ )} + + {activeTab === 'destinationwallet' && ( +
+

Destination Wallet

+ + {!transactionDetails?.transfer ? ( +
No Data available
+ ) : ( +
+
+

Name

+

{transactionDetails.transfer.destination_wallet.name}

+
+
+

Description

+

{transactionDetails.transfer.destination_wallet.description}

+
+
+ )} +
+ )} + + {activeTab === 'log' && (

Transaction Logs

@@ -489,8 +512,8 @@ const DetailTransaction = () => { Status - Created At - Updated At + Date + {/* Updated At */} @@ -512,8 +535,19 @@ const DetailTransaction = () => { return status; })()} - {log.created_at} - {log.updated_at} + + {new Date(log.created_at).toLocaleString('sv-SE', { + timeZone: 'Asia/Jakarta', // kalau kamu mau waktu lokal (optional) + year: 'numeric', + month: '2-digit', + day: '2-digit', + hour: '2-digit', + minute: '2-digit', + second: '2-digit', + hour12: false, + }).replace(' ', ' ')} + + {/* {log.updated_at} */} )) ) : ( diff --git a/src/pages/transaction/history-transaction/blocks/ListToolbar.tsx b/src/pages/transaction/history-transaction/blocks/ListToolbar.tsx index afc8ac5..e0a15c3 100644 --- a/src/pages/transaction/history-transaction/blocks/ListToolbar.tsx +++ b/src/pages/transaction/history-transaction/blocks/ListToolbar.tsx @@ -18,12 +18,10 @@ const ListToolbar = () => { // useEffect to set the default date values useEffect(() => { const today = new Date(); - const nextWeek = new Date(today); - nextWeek.setDate(today.getDate() + 7); - + const firstDayOfMonth = new Date(today.getFullYear(), today.getMonth(), 1); settrxDate({ - from: formatDate(today), // Set 'from' to today - to: formatDate(nextWeek), // Set 'to' to 7 days later + from: formatDate(firstDayOfMonth), + to: formatDate(today), }); }, []); diff --git a/src/pages/transaction/history-transaction/hooks/TransactionContext.tsx b/src/pages/transaction/history-transaction/hooks/TransactionContext.tsx index 273dd4f..6a39771 100644 --- a/src/pages/transaction/history-transaction/hooks/TransactionContext.tsx +++ b/src/pages/transaction/history-transaction/hooks/TransactionContext.tsx @@ -84,7 +84,7 @@ const TransactionProvider = ({ children }: { children: React.ReactNode }) => { }); return formattedDateTime; // Format DD-MM-YYYY HH:MM:SS (menggunakan waktu yang sudah ada) } - }, + }, { accessorKey: 'origin_customer.fullname', header: ({ column }) => , @@ -125,19 +125,6 @@ const TransactionProvider = ({ children }: { children: React.ReactNode }) => { }, }, { - accessorFn: (row) => { - let status; - if (row.status === 'C') { - status = 'COMPLETE'; - } else if (row.status === 'F') { - status = 'FAILED'; - } else if (row.status === 'O') { - status = 'ON PROCESS'; - } else { - status = 'PENDING'; - } - return status; - }, accessorKey: 'status', header: ({ column }) => , enableSorting: false, @@ -145,7 +132,37 @@ const TransactionProvider = ({ children }: { children: React.ReactNode }) => { meta: { headerClassName: 'w-[250px]', }, - }, + cell: ({ row }) => { + const statusCode = row.original.status; + let label = ''; + let badgeClass = ''; + + switch (statusCode) { + case 'C': + label = 'COMPLETE'; + badgeClass = 'bg-green-100 text-green-800'; + break; + case 'F': + label = 'FAILED'; + badgeClass = 'bg-red-100 text-red-800'; + break; + case 'O': + label = 'ON PROCESS'; + badgeClass = 'bg-blue-100 text-blue-800'; + break; + default: + label = 'PENDING'; + badgeClass = 'bg-gray-100 text-gray-800'; + break; + } + + return ( + + {label} + + ); + }, + }, { accessorKey: 'description', header: ({ column }) => , @@ -201,11 +218,12 @@ const TransactionProvider = ({ children }: { children: React.ReactNode }) => { if (filter == undefined || filter.length == 0) { const today = new Date(); - const nextWeek = new Date(); - nextWeek.setDate(today.getDate() + 7); - startdate = today.toISOString().split('T')[0]; - enddate = nextWeek.toISOString().split('T')[0]; + // Tanggal 1 di bulan sekarang + const firstDayOfMonth = new Date(today.getFullYear(), today.getMonth(), 1); + + startdate = firstDayOfMonth.toISOString().split('T')[0]; + enddate = today.toISOString().split('T')[0]; } else if (filter != undefined || filter.length != 0) { startdate = filter[0].value.from; enddate = filter[0].value.to; From 7eb3de9f7a9e7c4c5c5eccc959d92398a4cfbd10 Mon Sep 17 00:00:00 2001 From: wayanrivan Date: Fri, 11 Apr 2025 15:25:39 +0700 Subject: [PATCH 29/29] update --- .../approval-transaction/hooks/ApprovalTransactionContext.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/transaction/approval-transaction/hooks/ApprovalTransactionContext.tsx b/src/pages/transaction/approval-transaction/hooks/ApprovalTransactionContext.tsx index c8b5854..5c74f68 100644 --- a/src/pages/transaction/approval-transaction/hooks/ApprovalTransactionContext.tsx +++ b/src/pages/transaction/approval-transaction/hooks/ApprovalTransactionContext.tsx @@ -155,7 +155,7 @@ const ApprovalTransactionProvider = ({ children }: { children: React.ReactNode } }, { accessorKey: 'type.name', - header: ({ column }) => , + header: ({ column }) => , enableSorting: false, enableHiding: false, meta: {