edit loan modal added, employer verify api added #32

Merged
ameye merged 1 commits from edit-loan-modal into master 2024-06-13 18:58:53 +00:00
5 changed files with 34 additions and 12 deletions
@@ -1,6 +1,7 @@
import axios, { AxiosResponse } from "axios";
import { ID, Response } from "../../../../_digifi/helpers"
import { User, UsersQueryResponse } from "./_models";
import { postAuxEnd } from "../../auth/core/AxiosCallHelper";
const API_URL = import.meta.env.VITE_APP_THEME_API_URL;
const USER_URL = `${API_URL}/user`;
@@ -43,6 +44,10 @@ const getApprovedUsers = (query: string): Promise<UsersQueryResponse> => { // FU
.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> => {
return axios
.get(`${USER_URL}/${id}`)
@@ -79,6 +84,7 @@ export {
getPendingUsers,
getReadyUsers,
getApprovedUsers,
employersVerify,
deleteUser,
deleteSelectedUsers,
getUserById,
@@ -79,7 +79,8 @@ const UserEditModalForm: FC<Props> = ({ user, isUserLoading }) => {
>
{/* begin::Scroll */}
<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"
data-kt-scroll="true"
data-kt-scroll-activate="{default: false, lg: true}"
@@ -396,11 +397,11 @@ const UserEditModalForm: FC<Props> = ({ user, isUserLoading }) => {
<button
type="reset"
onClick={() => cancel()}
className="btn btn-light me-3"
className="btn btn-danger me-3"
data-kt-users-modal-action="cancel"
disabled={formik.isSubmitting || isUserLoading}
>
Discard
Cancel
</button>
<button
@@ -2,7 +2,7 @@ import { useQuery } from "react-query";
import { UserEditModalForm } from "./UserEditModalForm";
import { isNotEmpty, QUERIES } from "../../../../../_digifi/helpers";
import { useListView } from "../core/ListViewProvider";
import { getUserById } from "../../core/_requests";
import { getUserById, getApprovedUsers } from "../../core/_requests";
const UserEditModalFormWrapper = () => {
const { itemIdForUpdate, setItemIdForUpdate } = useListView();
@@ -14,7 +14,8 @@ const UserEditModalFormWrapper = () => {
} = useQuery(
`${QUERIES.READY_LIST}-user-${itemIdForUpdate}`,
() => {
return getUserById(itemIdForUpdate);
// return getUserById(itemIdForUpdate);
return getApprovedUsers('');
},
{
cacheTime: 0,
@@ -33,7 +34,10 @@ const UserEditModalFormWrapper = () => {
}
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;
@@ -4,17 +4,21 @@ import { MenuComponent } from "../../../../../../_digifi/assets/ts/components";
import { ID, KTIcon, QUERIES } from "../../../../../../_digifi/helpers";
import { useListView } from "../../core/ListViewProvider";
import { useQueryResponse } from "../../core/QueryResponseProvider";
import { deleteUser } from "../../../core/_requests";
import { employersVerify } from "../../../core/_requests";
import { User } from "../../../core/_models";
type Props = {
id: ID;
data?: Array<User> | any
};
const UserActionsCell: FC<Props> = ({ id }) => {
const UserActionsCell: FC<Props> = ({ id, data }) => {
const { setItemIdForUpdate } = useListView();
const { query } = useQueryResponse();
const queryClient = useQueryClient();
let selectedUser = data?.filter((item:User) => item.uid == id)[0]
useEffect(() => {
MenuComponent.reinitialization();
}, []);
@@ -23,14 +27,21 @@ const UserActionsCell: FC<Props> = ({ id }) => {
setItemIdForUpdate(id);
};
const deleteItem = useMutation(() => deleteUser(id), {
const empsVerify = useMutation(() => employersVerify(selectedUser?.employer_uid), {
// 💡 response of the mutation is passed to onSuccess
onSuccess: () => {
// ✅ 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 (
<>
<a
@@ -60,7 +71,7 @@ const UserActionsCell: FC<Props> = ({ id }) => {
<a
className="menu-link px-3"
data-kt-users-table-filter="delete_row"
onClick={async () => await deleteItem.mutateAsync()}
onClick={async () => resendVerification()}
>
Resend Verification
</a>
@@ -58,7 +58,7 @@ const usersColumns: ReadonlyArray<Column<User>> = [
<UserCustomHeader tableProps={props} title='Actions' className='text-end min-w-100px' />
),
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} />,
},
]