edit loan modal added, employer verify api added

This commit was merged in pull request #32.
This commit is contained in:
victorAnumudu
2024-06-13 19:56:17 +01:00
parent 8a96b10e4b
commit 98454e2c80
5 changed files with 34 additions and 12 deletions
@@ -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} />,
},
]