edit loan modal added, employer verify api added
This commit was merged in pull request #32.
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import axios, { AxiosResponse } from "axios";
|
import axios, { AxiosResponse } from "axios";
|
||||||
import { ID, Response } from "../../../../_digifi/helpers"
|
import { ID, Response } from "../../../../_digifi/helpers"
|
||||||
import { User, UsersQueryResponse } from "./_models";
|
import { User, UsersQueryResponse } from "./_models";
|
||||||
|
import { postAuxEnd } from "../../auth/core/AxiosCallHelper";
|
||||||
|
|
||||||
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`;
|
||||||
@@ -43,6 +44,10 @@ const getApprovedUsers = (query: string): Promise<UsersQueryResponse> => { // FU
|
|||||||
.then((d: AxiosResponse<UsersQueryResponse>) => d.data);
|
.then((d: AxiosResponse<UsersQueryResponse>) => d.data);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const employersVerify = (uid: ID): Promise<UsersQueryResponse> => { // FUNCTION FOR EMPLOYERS VERIFICATION
|
||||||
|
return postAuxEnd('/employers/verify', {employer_uid:uid})
|
||||||
|
};
|
||||||
|
|
||||||
const getUserById = (id: ID): Promise<User | undefined> => {
|
const getUserById = (id: ID): Promise<User | undefined> => {
|
||||||
return axios
|
return axios
|
||||||
.get(`${USER_URL}/${id}`)
|
.get(`${USER_URL}/${id}`)
|
||||||
@@ -79,6 +84,7 @@ export {
|
|||||||
getPendingUsers,
|
getPendingUsers,
|
||||||
getReadyUsers,
|
getReadyUsers,
|
||||||
getApprovedUsers,
|
getApprovedUsers,
|
||||||
|
employersVerify,
|
||||||
deleteUser,
|
deleteUser,
|
||||||
deleteSelectedUsers,
|
deleteSelectedUsers,
|
||||||
getUserById,
|
getUserById,
|
||||||
|
|||||||
@@ -79,7 +79,8 @@ const UserEditModalForm: FC<Props> = ({ user, isUserLoading }) => {
|
|||||||
>
|
>
|
||||||
{/* begin::Scroll */}
|
{/* begin::Scroll */}
|
||||||
<div
|
<div
|
||||||
className="d-flex flex-column scroll-y me-n7 pe-7"
|
// className="d-flex flex-column scroll-y me-n7 pe-7"
|
||||||
|
className="d-none flex-column scroll-y me-n7 pe-7"
|
||||||
id="kt_modal_add_user_scroll"
|
id="kt_modal_add_user_scroll"
|
||||||
data-kt-scroll="true"
|
data-kt-scroll="true"
|
||||||
data-kt-scroll-activate="{default: false, lg: true}"
|
data-kt-scroll-activate="{default: false, lg: true}"
|
||||||
@@ -396,11 +397,11 @@ const UserEditModalForm: FC<Props> = ({ user, isUserLoading }) => {
|
|||||||
<button
|
<button
|
||||||
type="reset"
|
type="reset"
|
||||||
onClick={() => cancel()}
|
onClick={() => cancel()}
|
||||||
className="btn btn-light me-3"
|
className="btn btn-danger me-3"
|
||||||
data-kt-users-modal-action="cancel"
|
data-kt-users-modal-action="cancel"
|
||||||
disabled={formik.isSubmitting || isUserLoading}
|
disabled={formik.isSubmitting || isUserLoading}
|
||||||
>
|
>
|
||||||
Discard
|
Cancel
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { useQuery } from "react-query";
|
|||||||
import { UserEditModalForm } from "./UserEditModalForm";
|
import { UserEditModalForm } from "./UserEditModalForm";
|
||||||
import { isNotEmpty, QUERIES } from "../../../../../_digifi/helpers";
|
import { isNotEmpty, QUERIES } from "../../../../../_digifi/helpers";
|
||||||
import { useListView } from "../core/ListViewProvider";
|
import { useListView } from "../core/ListViewProvider";
|
||||||
import { getUserById } from "../../core/_requests";
|
import { getUserById, getApprovedUsers } from "../../core/_requests";
|
||||||
|
|
||||||
const UserEditModalFormWrapper = () => {
|
const UserEditModalFormWrapper = () => {
|
||||||
const { itemIdForUpdate, setItemIdForUpdate } = useListView();
|
const { itemIdForUpdate, setItemIdForUpdate } = useListView();
|
||||||
@@ -14,7 +14,8 @@ const UserEditModalFormWrapper = () => {
|
|||||||
} = useQuery(
|
} = useQuery(
|
||||||
`${QUERIES.READY_LIST}-user-${itemIdForUpdate}`,
|
`${QUERIES.READY_LIST}-user-${itemIdForUpdate}`,
|
||||||
() => {
|
() => {
|
||||||
return getUserById(itemIdForUpdate);
|
// return getUserById(itemIdForUpdate);
|
||||||
|
return getApprovedUsers('');
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
cacheTime: 0,
|
cacheTime: 0,
|
||||||
@@ -33,7 +34,10 @@ const UserEditModalFormWrapper = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!isLoading && !error && user) {
|
if (!isLoading && !error && user) {
|
||||||
return <UserEditModalForm isUserLoading={isLoading} user={user} />;
|
// return <UserEditModalForm isUserLoading={isLoading} user={user} />;
|
||||||
|
// REMOVE LATER AND ALLOW UP ALONE
|
||||||
|
let newUser:any = user?.records
|
||||||
|
return <UserEditModalForm isUserLoading={isLoading} user={newUser} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -4,17 +4,21 @@ import { MenuComponent } from "../../../../../../_digifi/assets/ts/components";
|
|||||||
import { ID, KTIcon, QUERIES } from "../../../../../../_digifi/helpers";
|
import { ID, KTIcon, QUERIES } from "../../../../../../_digifi/helpers";
|
||||||
import { useListView } from "../../core/ListViewProvider";
|
import { useListView } from "../../core/ListViewProvider";
|
||||||
import { useQueryResponse } from "../../core/QueryResponseProvider";
|
import { useQueryResponse } from "../../core/QueryResponseProvider";
|
||||||
import { deleteUser } from "../../../core/_requests";
|
import { employersVerify } from "../../../core/_requests";
|
||||||
|
import { User } from "../../../core/_models";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
id: ID;
|
id: ID;
|
||||||
|
data?: Array<User> | any
|
||||||
};
|
};
|
||||||
|
|
||||||
const UserActionsCell: FC<Props> = ({ id }) => {
|
const UserActionsCell: FC<Props> = ({ id, data }) => {
|
||||||
const { setItemIdForUpdate } = useListView();
|
const { setItemIdForUpdate } = useListView();
|
||||||
const { query } = useQueryResponse();
|
const { query } = useQueryResponse();
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
let selectedUser = data?.filter((item:User) => item.uid == id)[0]
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
MenuComponent.reinitialization();
|
MenuComponent.reinitialization();
|
||||||
}, []);
|
}, []);
|
||||||
@@ -23,14 +27,21 @@ const UserActionsCell: FC<Props> = ({ id }) => {
|
|||||||
setItemIdForUpdate(id);
|
setItemIdForUpdate(id);
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteItem = useMutation(() => deleteUser(id), {
|
const empsVerify = useMutation(() => employersVerify(selectedUser?.employer_uid), {
|
||||||
// 💡 response of the mutation is passed to onSuccess
|
// 💡 response of the mutation is passed to onSuccess
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
// ✅ update detail view directly
|
// ✅ update detail view directly
|
||||||
queryClient.invalidateQueries([`${QUERIES.USERS_LIST}-${query}`]);
|
queryClient.invalidateQueries([`${QUERIES.READY_LIST}-${query}`]);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const resendVerification = async () => { // FUNCTION TO RESEND VERIFICATION
|
||||||
|
let cont = confirm('Are you sure, you want to send resend verification?')
|
||||||
|
if(cont){
|
||||||
|
await empsVerify.mutateAsync()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<a
|
<a
|
||||||
@@ -60,7 +71,7 @@ const UserActionsCell: FC<Props> = ({ id }) => {
|
|||||||
<a
|
<a
|
||||||
className="menu-link px-3"
|
className="menu-link px-3"
|
||||||
data-kt-users-table-filter="delete_row"
|
data-kt-users-table-filter="delete_row"
|
||||||
onClick={async () => await deleteItem.mutateAsync()}
|
onClick={async () => resendVerification()}
|
||||||
>
|
>
|
||||||
Resend Verification
|
Resend Verification
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ const usersColumns: ReadonlyArray<Column<User>> = [
|
|||||||
<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].uid} />,
|
Cell: ({...props}) => <UserActionsCell id={props.data[props.row.index].uid} data={props?.data} />,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user