diff --git a/src/_digifi/helpers/crud-helper/models.ts b/src/_digifi/helpers/crud-helper/models.ts index 3f36d9f..e1996de 100644 --- a/src/_digifi/helpers/crud-helper/models.ts +++ b/src/_digifi/helpers/crud-helper/models.ts @@ -1,6 +1,6 @@ import {Dispatch, SetStateAction} from 'react' -export type ID = undefined | null | number +export type ID = undefined | null | number | string export type PaginationState = { page: number @@ -23,6 +23,7 @@ export type SearchState = { export type Response = { data?: T + records?: Array payload?: { message?: string errors?: { diff --git a/src/_digifi/lib/NewDateTimeFormatter.ts b/src/_digifi/lib/NewDateTimeFormatter.ts new file mode 100644 index 0000000..18da0e7 --- /dev/null +++ b/src/_digifi/lib/NewDateTimeFormatter.ts @@ -0,0 +1,18 @@ + +export function NewDateTimeFormatter(isoDateString:any, addHour = true) { + const date = new Date(isoDateString); + if (addHour) { + date.setTime(date.getTime() + 1 * 60 * 60 * 1000); + } + const formattedDate = date.toLocaleDateString("en-US", { + year: "numeric", + month: "numeric", + day: "numeric", + hour: "2-digit", + minute: "2-digit", + // second: "2-digit", + hour12: true, + timeZone: "UTC", + }); + return formattedDate; + } \ No newline at end of file diff --git a/src/app/modules/apps/user-management/users-list/core/QueryResponseProvider.tsx b/src/app/modules/apps/user-management/users-list/core/QueryResponseProvider.tsx index 98e2213..3f7cffe 100644 --- a/src/app/modules/apps/user-management/users-list/core/QueryResponseProvider.tsx +++ b/src/app/modules/apps/user-management/users-list/core/QueryResponseProvider.tsx @@ -54,7 +54,7 @@ const useQueryResponseData = () => { return [] } - return response?.data || [] + return response?.records || [] } const useQueryResponsePagination = () => { diff --git a/src/app/modules/apps/user-management/users-list/table/UsersTable.tsx b/src/app/modules/apps/user-management/users-list/table/UsersTable.tsx index 5898f4c..f48b4b4 100644 --- a/src/app/modules/apps/user-management/users-list/table/UsersTable.tsx +++ b/src/app/modules/apps/user-management/users-list/table/UsersTable.tsx @@ -11,7 +11,7 @@ import {KTCardBody} from '../../../../../../_digifi/helpers' const UsersTable = () => { const users = useQueryResponseData() - console.log('users', users) + // console.log('users', users) const isLoading = useQueryResponseLoading() const data = useMemo(() => users, [users]) const columns = useMemo(() => usersColumns, []) diff --git a/src/app/modules/apps/user-management/users-list/table/columns/AddedCell.tsx b/src/app/modules/apps/user-management/users-list/table/columns/AddedCell.tsx new file mode 100644 index 0000000..6f5bc2b --- /dev/null +++ b/src/app/modules/apps/user-management/users-list/table/columns/AddedCell.tsx @@ -0,0 +1,12 @@ +import {FC} from 'react' +import { NewDateTimeFormatter } from '../../../../../../../_digifi/lib/NewDateTimeFormatter' + +type Props = { + added?: string +} + +const AddedCell: FC = ({added}) => ( +
{NewDateTimeFormatter((added))}
+) + +export {AddedCell} \ No newline at end of file diff --git a/src/app/modules/apps/user-management/users-list/table/columns/AgentCell.tsx b/src/app/modules/apps/user-management/users-list/table/columns/AgentCell.tsx new file mode 100644 index 0000000..063ade5 --- /dev/null +++ b/src/app/modules/apps/user-management/users-list/table/columns/AgentCell.tsx @@ -0,0 +1,11 @@ +import {FC} from 'react' + +type Props = { + agent?: string +} + +const AgentCell: FC = ({agent}) => ( + <> {agent &&
{agent}
} +) + +export {AgentCell} diff --git a/src/app/modules/apps/user-management/users-list/table/columns/UserInfoCell.tsx b/src/app/modules/apps/user-management/users-list/table/columns/UserInfoCell.tsx index 0627582..1840fef 100644 --- a/src/app/modules/apps/user-management/users-list/table/columns/UserInfoCell.tsx +++ b/src/app/modules/apps/user-management/users-list/table/columns/UserInfoCell.tsx @@ -25,14 +25,14 @@ const UserInfoCell: FC = ({user}) => ( `text-${user.initials?.state}` )} > - {user.initials?.label} + {user.firstname?.substring(0,1).toUpperCase()} {user.lastname?.substring(0,1).toUpperCase()} )} diff --git a/src/app/modules/apps/user-management/users-list/table/columns/UserLastLoginCell.tsx b/src/app/modules/apps/user-management/users-list/table/columns/UserLastLoginCell.tsx index 30f3f32..a8a0ebe 100644 --- a/src/app/modules/apps/user-management/users-list/table/columns/UserLastLoginCell.tsx +++ b/src/app/modules/apps/user-management/users-list/table/columns/UserLastLoginCell.tsx @@ -1,11 +1,11 @@ import {FC} from 'react' type Props = { - last_login?: string + payment_month?: string } -const UserLastLoginCell: FC = ({last_login}) => ( -
{last_login}
+const PaymentMonthCell: FC = ({payment_month}) => ( +
{payment_month}
) -export {UserLastLoginCell} +export {PaymentMonthCell} diff --git a/src/app/modules/apps/user-management/users-list/table/columns/UserTwoStepsCell.tsx b/src/app/modules/apps/user-management/users-list/table/columns/UserTwoStepsCell.tsx deleted file mode 100644 index 9656332..0000000 --- a/src/app/modules/apps/user-management/users-list/table/columns/UserTwoStepsCell.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import {FC} from 'react' - -type Props = { - two_steps?: boolean -} - -const UserTwoStepsCell: FC = ({two_steps}) => ( - <> {two_steps &&
Enabled
} -) - -export {UserTwoStepsCell} diff --git a/src/app/modules/apps/user-management/users-list/table/columns/_columns.tsx b/src/app/modules/apps/user-management/users-list/table/columns/_columns.tsx index 13821a4..897f37a 100644 --- a/src/app/modules/apps/user-management/users-list/table/columns/_columns.tsx +++ b/src/app/modules/apps/user-management/users-list/table/columns/_columns.tsx @@ -1,55 +1,57 @@ import {Column} from 'react-table' import {UserInfoCell} from './UserInfoCell' -import {UserLastLoginCell} from './UserLastLoginCell' -import {UserTwoStepsCell} from './UserTwoStepsCell' +import { PaymentMonthCell } from './UserLastLoginCell' +import {AgentCell} from './AgentCell' import {UserActionsCell} from './UserActionsCell' import {UserSelectionCell} from './UserSelectionCell' import {UserCustomHeader} from './UserCustomHeader' import {UserSelectionHeader} from './UserSelectionHeader' import {User} from '../../core/_models' +import { AddedCell } from './AddedCell' const usersColumns: ReadonlyArray> = [ { Header: (props) => , id: 'selection', - Cell: ({...props}) => , + Cell: ({...props}) => , }, { Header: (props) => , - id: 'name', + id: 'firstname', Cell: ({...props}) => , }, { Header: (props) => , - accessor: 'role', + accessor: 'loan_amount', }, { Header: (props) => ( ), - id: 'last_login', - Cell: ({...props}) => , + id: 'payment_month', + Cell: ({...props}) => , }, { Header: (props) => ( ), - id: 'two_steps', - Cell: ({...props}) => , + id: 'sales_agent', + Cell: ({...props}) => , }, { Header: (props) => ( ), - accessor: 'joined_day', + id: 'added', + Cell: ({...props}) => , }, { Header: (props) => ( ), id: 'actions', - Cell: ({...props}) => , + Cell: ({...props}) => , }, ] -export {usersColumns} +export {usersColumns} \ No newline at end of file