Compare commits

..

8 Commits

Author SHA1 Message Date
victorAnumudu 2eb39b773a loan started list display 2024-05-03 10:48:00 +01:00
victorAnumudu 4e97119644 initial commit 2024-05-03 04:49:59 +01:00
ameye 7bc39a449c Merge branch 'login-new-api' of DigiFi/digifi-bko into master 2024-05-02 16:59:18 +00:00
victorAnumudu f7f728c066 added new login API 2024-05-02 14:00:57 +01:00
CHIEFSOFT\ameye 3845ecbefe env 2024-05-02 05:44:34 -04:00
ameye 43b0e60db2 Merge branch 'get-loan-started' of DigiFi/digifi-bko into master 2024-05-02 09:21:44 +00:00
victorAnumudu 51e06716e5 get loan started API added 2024-05-02 10:19:38 +01:00
ameye 9d7605ebfe Merge branch 'table-headers' of DigiFi/digifi-bko into master 2024-05-01 23:52:03 +00:00
18 changed files with 132 additions and 78 deletions
+9 -9
View File
@@ -1,17 +1,17 @@
PORT=3011 PORT=3011
VITE_APP_BASE_LAYOUT_CONFIG_KEY='metronic-react-demo1-8150' VITE_APP_BASE_LAYOUT_CONFIG_KEY='digifi-agent'
VITE_APP_API_URL=https://preview.keenthemes.com/metronic8/laravel/api VITE_APP_API_URL=https://dev-agents.digifi.com
VITE_APP_VERSION=v8.2.3 VITE_APP_VERSION=v8.2.3
VITE_APP_THEME_NAME=WrenchBoard VITE_APP_THEME_NAME=digifi
VITE_APP_THEME_DEMO=demo1 VITE_APP_THEME_DEMO=digifi
VITE_APP_BOOTSTRAP_DOCS_LINK=https://getbootstrap.com/docs/5.0 VITE_APP_BOOTSTRAP_DOCS_LINK=https://getbootstrap.com/docs/5.0
VITE_APP_SASS_PATH=src/_digifi/assets/sass/core/components VITE_APP_SASS_PATH=src/_digifi/assets/sass/core/components
VITE_APP_SASS_VARIABLES_PATH=src/_digifi/assets/sass/core/components/_variables.scss VITE_APP_SASS_VARIABLES_PATH=src/_digifi/assets/sass/core/components/_variables.scss
VITE_APP_PURCHASE_URL=https://themeforest.net/item/metronic-responsive-admin-dashboard-template/4021469 VITE_APP_PURCHASE_URL=https://www.digifi.com/
VITE_APP_PREVIEW_URL=https://preview.keenthemes.com/metronic8/react/demo1/ VITE_APP_PREVIEW_URL=https://www.digifi.com/demo1/
VITE_APP_PREVIEW_REACT_URL=https://preview.keenthemes.com/metronic8/react VITE_APP_PREVIEW_REACT_URL=https://www.digifi.com
VITE_APP_PREVIEW_DOCS_URL=https://preview.keenthemes.com/metronic8/react/docs VITE_APP_PREVIEW_DOCS_URL=https://www.digifi.com/
VITE_APP_THEME_API_URL=https://preview.keenthemes.com/theme-api/api VITE_APP_THEME_API_URL=https://api.digifi/api/api
# CUSTOM ENV VARIABLES ADDED # CUSTOM ENV VARIABLES ADDED
VITE_APP_USER_ENDPOINT=https://digifi-apidev.chiefsoft.net/digibko/v1 VITE_APP_USER_ENDPOINT=https://digifi-apidev.chiefsoft.net/digibko/v1
+9 -9
View File
@@ -1,17 +1,17 @@
PORT=3011 PORT=3011
VITE_APP_BASE_LAYOUT_CONFIG_KEY='metronic-react-demo1-8150' VITE_APP_BASE_LAYOUT_CONFIG_KEY='digifi-agent'
VITE_APP_API_URL=https://preview.keenthemes.com/metronic8/laravel/api VITE_APP_API_URL=https://dev-agents.digifi.com
VITE_APP_VERSION=v8.2.3 VITE_APP_VERSION=v8.2.3
VITE_APP_THEME_NAME=DigiFi VITE_APP_THEME_NAME=digifi
VITE_APP_THEME_DEMO=demo1 VITE_APP_THEME_DEMO=digifi
VITE_APP_BOOTSTRAP_DOCS_LINK=https://getbootstrap.com/docs/5.0 VITE_APP_BOOTSTRAP_DOCS_LINK=https://getbootstrap.com/docs/5.0
VITE_APP_SASS_PATH=src/_digifi/assets/sass/core/components VITE_APP_SASS_PATH=src/_digifi/assets/sass/core/components
VITE_APP_SASS_VARIABLES_PATH=src/_digifi/assets/sass/core/components/_variables.scss VITE_APP_SASS_VARIABLES_PATH=src/_digifi/assets/sass/core/components/_variables.scss
VITE_APP_PURCHASE_URL=https://themeforest.net/item/metronic-responsive-admin-dashboard-template/4021469 VITE_APP_PURCHASE_URL=https://www.digifi.com/
VITE_APP_PREVIEW_URL=https://preview.keenthemes.com/metronic8/react/demo1/ VITE_APP_PREVIEW_URL=https://www.digifi.com/demo1/
VITE_APP_PREVIEW_REACT_URL=https://preview.keenthemes.com/metronic8/react VITE_APP_PREVIEW_REACT_URL=https://www.digifi.com
VITE_APP_PREVIEW_DOCS_URL=https://preview.keenthemes.com/metronic8/react/docs VITE_APP_PREVIEW_DOCS_URL=https://www.digifi.com/
VITE_APP_THEME_API_URL=https://preview.keenthemes.com/theme-api/api VITE_APP_THEME_API_URL=https://api.digifi/api/api
# CUSTOM ENV VARIABLES ADDED # CUSTOM ENV VARIABLES ADDED
VITE_APP_USER_ENDPOINT=https://digifi-apidev.chiefsoft.net/digibko/v1 VITE_APP_USER_ENDPOINT=https://digifi-apidev.chiefsoft.net/digibko/v1
+2 -2
View File
@@ -75,7 +75,7 @@ function groupingOnSelect(
function groupingOnSelectAll<T>( function groupingOnSelectAll<T>(
isAllSelected: boolean, isAllSelected: boolean,
setSelected: Dispatch<SetStateAction<Array<ID>>>, setSelected: Dispatch<SetStateAction<Array<ID>>>,
data?: Array<T & {id?: ID}> data?: Array<T & {uid?: ID}>
) { ) {
if (isAllSelected) { if (isAllSelected) {
setSelected([]) setSelected([])
@@ -86,7 +86,7 @@ function groupingOnSelectAll<T>(
return return
} }
setSelected(data.filter((item) => item.id).map((item) => item.id)) setSelected(data.filter((item) => item.uid).map((item) => item.uid))
} }
// Hook // Hook
+2 -1
View File
@@ -1,6 +1,6 @@
import {Dispatch, SetStateAction} from 'react' import {Dispatch, SetStateAction} from 'react'
export type ID = undefined | null | number export type ID = undefined | null | number | string
export type PaginationState = { export type PaginationState = {
page: number page: number
@@ -23,6 +23,7 @@ export type SearchState = {
export type Response<T> = { export type Response<T> = {
data?: T data?: T
records?: Array<any>
payload?: { payload?: {
message?: string message?: string
errors?: { errors?: {
+18
View File
@@ -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;
}
@@ -54,7 +54,7 @@ const useQueryResponseData = () => {
return [] return []
} }
return response?.data || [] return response?.records || []
} }
const useQueryResponsePagination = () => { const useQueryResponsePagination = () => {
@@ -4,20 +4,20 @@ import { User, UsersQueryResponse } from "./_models";
const API_URL = import.meta.env.VITE_APP_THEME_API_URL; const API_URL = import.meta.env.VITE_APP_THEME_API_URL;
const USER_URL = `${API_URL}/user`; const USER_URL = `${API_URL}/user`;
const GET_USERS_URL = `${API_URL}/users/query`; // const GET_USERS_URL = `${API_URL}/users/query`;
// const NEW_USER_ENDPOINT = import.meta.env.VITE_APP_USER_ENDPOINT const NEW_USER_ENDPOINT = import.meta.env.VITE_APP_USER_ENDPOINT
const getStartedUsers = (query: string): Promise<UsersQueryResponse> => {
return axios
.get(`${GET_USERS_URL}?${query}`)
.then((d: AxiosResponse<UsersQueryResponse>) => d.data);
};
// const getStartedUsers = (query: string): Promise<UsersQueryResponse> => { // const getStartedUsers = (query: string): Promise<UsersQueryResponse> => {
// return axios // return axios
// .get(`${NEW_USER_ENDPOINT}/loan/started`) // .get(`${GET_USERS_URL}?${query}`)
// .then((d: AxiosResponse<UsersQueryResponse>) => d.data); // .then((d: AxiosResponse<UsersQueryResponse>) => d.data);
// }; // };
const getStartedUsers = (query: string): Promise<UsersQueryResponse> => { // FUNCTION TO GET USERS THAT HAVE STARTED LOAN APPLICATION
return axios
.get(`${NEW_USER_ENDPOINT}/loan/started`)
.then((d: AxiosResponse<UsersQueryResponse>) => d.data);
};
const getUserById = (id: ID): Promise<User | undefined> => { const getUserById = (id: ID): Promise<User | undefined> => {
return axios return axios
@@ -11,7 +11,7 @@ import {KTCardBody} from '../../../../../../_digifi/helpers'
const UsersTable = () => { const UsersTable = () => {
const users = useQueryResponseData() const users = useQueryResponseData()
console.log('users', users) // console.log('users', users)
const isLoading = useQueryResponseLoading() const isLoading = useQueryResponseLoading()
const data = useMemo(() => users, [users]) const data = useMemo(() => users, [users])
const columns = useMemo(() => usersColumns, []) const columns = useMemo(() => usersColumns, [])
@@ -0,0 +1,12 @@
import {FC} from 'react'
import { NewDateTimeFormatter } from '../../../../../../../_digifi/lib/NewDateTimeFormatter'
type Props = {
added?: string
}
const AddedCell: FC<Props> = ({added}) => (
<div className='badge badge-light fw-bolder'>{NewDateTimeFormatter((added))}</div>
)
export {AddedCell}
@@ -0,0 +1,11 @@
import {FC} from 'react'
type Props = {
agent?: string
}
const AgentCell: FC<Props> = ({agent}) => (
<> {agent && <div className='badge badge-light-success fw-bolder'>{agent}</div>}</>
)
export {AgentCell}
@@ -25,14 +25,14 @@ const UserInfoCell: FC<Props> = ({user}) => (
`text-${user.initials?.state}` `text-${user.initials?.state}`
)} )}
> >
{user.initials?.label} {user.firstname?.substring(0,1).toUpperCase()} {user.lastname?.substring(0,1).toUpperCase()}
</div> </div>
)} )}
</a> </a>
</div> </div>
<div className='d-flex flex-column'> <div className='d-flex flex-column'>
<a href='#' className='text-gray-800 text-hover-primary mb-1'> <a href='#' className='text-gray-800 text-hover-primary mb-1'>
{user.name} {user.firstname} {user.lastname}
</a> </a>
<span>{user.email}</span> <span>{user.email}</span>
</div> </div>
@@ -1,11 +1,11 @@
import {FC} from 'react' import {FC} from 'react'
type Props = { type Props = {
last_login?: string payment_month?: string
} }
const UserLastLoginCell: FC<Props> = ({last_login}) => ( const PaymentMonthCell: FC<Props> = ({payment_month}) => (
<div className='badge badge-light fw-bolder'>{last_login}</div> <div className='badge badge-light fw-bolder'>{payment_month}</div>
) )
export {UserLastLoginCell} export {PaymentMonthCell}
@@ -1,11 +0,0 @@
import {FC} from 'react'
type Props = {
two_steps?: boolean
}
const UserTwoStepsCell: FC<Props> = ({two_steps}) => (
<> {two_steps && <div className='badge badge-light-success fw-bolder'>Enabled</div>}</>
)
export {UserTwoStepsCell}
@@ -1,55 +1,57 @@
import {Column} from 'react-table' import {Column} from 'react-table'
import {UserInfoCell} from './UserInfoCell' import {UserInfoCell} from './UserInfoCell'
import {UserLastLoginCell} from './UserLastLoginCell' import { PaymentMonthCell } from './UserLastLoginCell'
import {UserTwoStepsCell} from './UserTwoStepsCell' import {AgentCell} from './AgentCell'
import {UserActionsCell} from './UserActionsCell' import {UserActionsCell} from './UserActionsCell'
import {UserSelectionCell} from './UserSelectionCell' import {UserSelectionCell} from './UserSelectionCell'
import {UserCustomHeader} from './UserCustomHeader' import {UserCustomHeader} from './UserCustomHeader'
import {UserSelectionHeader} from './UserSelectionHeader' import {UserSelectionHeader} from './UserSelectionHeader'
import {User} from '../../core/_models' import {User} from '../../core/_models'
import { AddedCell } from './AddedCell'
const usersColumns: ReadonlyArray<Column<User>> = [ const usersColumns: ReadonlyArray<Column<User>> = [
{ {
Header: (props) => <UserSelectionHeader tableProps={props} />, Header: (props) => <UserSelectionHeader tableProps={props} />,
id: 'selection', id: 'selection',
Cell: ({...props}) => <UserSelectionCell id={props.data[props.row.index].id} />, Cell: ({...props}) => <UserSelectionCell id={props.data[props.row.index].uid} />,
}, },
{ {
Header: (props) => <UserCustomHeader tableProps={props} title='Name' className='min-w-125px' />, Header: (props) => <UserCustomHeader tableProps={props} title='Name' className='min-w-125px' />,
id: 'name', id: 'firstname',
Cell: ({...props}) => <UserInfoCell user={props.data[props.row.index]} />, Cell: ({...props}) => <UserInfoCell user={props.data[props.row.index]} />,
}, },
{ {
Header: (props) => <UserCustomHeader tableProps={props} title='Amount' className='min-w-125px' />, Header: (props) => <UserCustomHeader tableProps={props} title='Amount' className='min-w-125px' />,
accessor: 'role', accessor: 'loan_amount',
}, },
{ {
Header: (props) => ( Header: (props) => (
<UserCustomHeader tableProps={props} title='Payment Terms' className='min-w-125px' /> <UserCustomHeader tableProps={props} title='Payment Terms' className='min-w-125px' />
), ),
id: 'last_login', id: 'payment_month',
Cell: ({...props}) => <UserLastLoginCell last_login={props.data[props.row.index].last_login} />, Cell: ({...props}) => <PaymentMonthCell payment_month={props.data[props.row.index].payment_month} />,
}, },
{ {
Header: (props) => ( Header: (props) => (
<UserCustomHeader tableProps={props} title='Agent' className='min-w-125px' /> <UserCustomHeader tableProps={props} title='Agent' className='min-w-125px' />
), ),
id: 'two_steps', id: 'sales_agent',
Cell: ({...props}) => <UserTwoStepsCell two_steps={props.data[props.row.index].two_steps} />, Cell: ({...props}) => <AgentCell agent={props.data[props.row.index].sales_agent} />,
}, },
{ {
Header: (props) => ( Header: (props) => (
<UserCustomHeader tableProps={props} title='Added' className='min-w-125px' /> <UserCustomHeader tableProps={props} title='Added' className='min-w-125px' />
), ),
accessor: 'joined_day', id: 'added',
Cell: ({...props}) => <AddedCell added={props.data[props.row.index].added} />,
}, },
{ {
Header: (props) => ( Header: (props) => (
<UserCustomHeader tableProps={props} title='Actions' className='text-end min-w-100px' /> <UserCustomHeader tableProps={props} title='Actions' className='text-end min-w-100px' />
), ),
id: 'actions', id: 'actions',
Cell: ({...props}) => <UserActionsCell id={props.data[props.row.index].id} />, Cell: ({...props}) => <UserActionsCell id={props.data[props.row.index].uid} />,
}, },
] ]
export {usersColumns} export {usersColumns}
+3 -3
View File
@@ -53,9 +53,9 @@ export function setupAxios(axios: any) {
axios.interceptors.request.use( axios.interceptors.request.use(
(config: {headers: {Authorization: string}}) => { (config: {headers: {Authorization: string}}) => {
const auth = getAuth() const auth = getAuth()
if (auth && auth.api_token) { // if (auth && auth.api_token) {
config.headers.Authorization = `Bearer ${auth.api_token}` // config.headers.Authorization = `Bearer ${auth.api_token}`
} // }
return config return config
}, },
+2 -2
View File
@@ -1,12 +1,12 @@
import axios from "axios"; import axios from "axios";
export function postAuxEnd(uri:string, reqData:any):Promise<any> { export function postAuxEnd(uri:string, reqData:any):Promise<any> {
// const endPoint = process.env.REACT_APP_USERS_ENDPOINT + uri; const endPoint = import.meta.env.VITE_APP_USER_ENDPOINT + uri;
const formData = new FormData(); const formData = new FormData();
for (let value in reqData) { for (let value in reqData) {
formData.append(value, reqData[value]); formData.append(value, reqData[value]);
} }
return axios.post(uri, reqData) return axios.post(endPoint, formData)
.then((response) => { .then((response) => {
console.log(response); console.log(response);
// if (response.data.internal_return == "-9999") { // if (response.data.internal_return == "-9999") {
+21
View File
@@ -1,6 +1,18 @@
export interface AuthModel { export interface AuthModel {
api_token: string api_token: string
refreshToken?: string refreshToken?: string
message?: string
call_return?: string
username: string
token?: string
id?: string
first_name?: string
last_name?: string
email?: string
email_verified_at?: string
created_at?: string
updated_at?: string
} }
export interface UserAddressModel { export interface UserAddressModel {
@@ -64,4 +76,13 @@ export interface UserModel {
communication?: UserCommunicationModel communication?: UserCommunicationModel
address?: UserAddressModel address?: UserAddressModel
socialNetworks?: UserSocialNetworksModel socialNetworks?: UserSocialNetworksModel
api_token: string
refreshToken?: string
message?: string
call_return?: string
token?: string
email_verified_at?: string
created_at?: string
updated_at?: string
} }
+13 -13
View File
@@ -5,9 +5,11 @@ import { postAuxEnd } from "./AxiosCallHelper";
const API_URL = import.meta.env.VITE_APP_API_URL; const API_URL = import.meta.env.VITE_APP_API_URL;
export const GET_USER_BY_ACCESSTOKEN_URL = `${API_URL}/verify_token`; // export const GET_USER_BY_ACCESSTOKEN_URL = `${API_URL}/verify_token`;
export const LOGIN_URL = `${API_URL}/login`; // export const LOGIN_URL = `${API_URL}/login`;
// export const LOGIN_URL = 'https://digifi-apidev.chiefsoft.net/digibko/v1/identity/token'
export const GET_USER_BY_ACCESSTOKEN_URL = '/identity/verify_token'
export const LOGIN_URL = '/identity/token'
export const REGISTER_URL = `${API_URL}/register`; export const REGISTER_URL = `${API_URL}/register`;
export const REQUEST_PASSWORD_URL = `${API_URL}/forgot_password`; export const REQUEST_PASSWORD_URL = `${API_URL}/forgot_password`;
@@ -17,13 +19,7 @@ export function login(email: string, password: string) {
// email, // email,
// password, // password,
// }); // });
return postAuxEnd(LOGIN_URL, {username:email, pass:password})
// let formData = new FormData()
// formData.append('username', email)
// formData.append('pass', password)
// return axios.post<AuthModel>(LOGIN_URL, formData);
return postAuxEnd(LOGIN_URL, {email, password})
} }
// Server should return AuthModel // Server should return AuthModel
@@ -50,8 +46,12 @@ export function requestPassword(email: string) {
}); });
} }
// export function getUserByToken(token: string) {
// return axios.post<UserModel>(GET_USER_BY_ACCESSTOKEN_URL, {
// api_token: token,
// });
// }
export function getUserByToken(token: string) { export function getUserByToken(token: string) {
return axios.post<UserModel>(GET_USER_BY_ACCESSTOKEN_URL, { return postAuxEnd(GET_USER_BY_ACCESSTOKEN_URL, {token})
api_token: token,
});
} }