Skip to content

Commit

Permalink
Staging (#2012)
Browse files Browse the repository at this point in the history
  • Loading branch information
madan-ideas2it authored Dec 5, 2024
2 parents d156275 + 4290059 commit 0acafa8
Show file tree
Hide file tree
Showing 56 changed files with 2,126 additions and 711 deletions.
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ ADMIN_LOGIN_USERNAME=
# For local development, use: admin
ADMIN_LOGIN_PASSWORD=


# Revalidate cache API token
# For local development, use: random string
REVALIDATE_API_TOKEN=

# Optional for local development

Expand Down
2 changes: 1 addition & 1 deletion apps/back-office/components/common/loader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import APP_CONSTANTS from '../../utils/constants';
export default function Loader() {
return (
// <div className="relative items-center block max-w-sm p-6 bg-white border border-gray-100 rounded-lg shadow-md dark:bg-gray-800 dark:border-gray-800 dark:hover:bg-gray-700">
<div className="full-body loader absolute flex h-full w-full">
<div className="full-body loader-0 fixed flex h-[100vh] z-[2000] top-0 left-0 w-full overflow-hidden">
{/* <svg aria-hidden="true" className="w-8 h-8 mr-2 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor" /><path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill" /></svg> */}

<div className="z-[1158] flex w-full items-center justify-center bg-white opacity-50">
Expand Down
190 changes: 119 additions & 71 deletions apps/back-office/components/footer-buttons/footer-buttons.tsx
Original file line number Diff line number Diff line change
@@ -1,69 +1,119 @@
import { CheckIcon, XIcon } from '@heroicons/react/outline';
import api from '../../utils/api';
import router from 'next/router';
import Modal from '../modal/modal';
import APP_CONSTANTS, {
API_ROUTE,
ENROLLMENT_TYPE,
ROUTE_CONSTANTS,
} from '../../utils/constants';
import { toast } from 'react-toastify';
import { useState } from 'react';

export function FooterButtons(props) {
const [openModal, setOpenModal] = useState(false);
const saveButtonClassName = props.disableSave
? 'shadow-special-button-default inline-flex w-full justify-center rounded-full bg-slate-400 px-6 py-2 text-base font-semibold leading-6 text-white outline-none'
: 'on-focus leading-3.5 text-md mb-2 mr-2 flex items-center rounded-full border border-blue-600 bg-blue-600 px-4 py-3 text-left font-medium text-white last:mr-0 focus-within:rounded-full hover:border-slate-400 focus:rounded-full focus-visible:rounded-full';
async function handleAprroveOrReject(
id,
type,
referenceUid,
isApproved,
setLoader
) {
async function approvelClickHandler(id: any, status: any, isVerified: any, setLoader) {
const data = {
status: isApproved
? APP_CONSTANTS.APPROVED_FLAG
: APP_CONSTANTS.REJECTED_FLAG,
participantType: type,
...(referenceUid && { referenceUid: referenceUid }),
status: status,
participantType: ENROLLMENT_TYPE.MEMBER,
isVerified,
uid: id,
};
const configuration = {
headers: {
authorization: `Bearer ${props.token}`,
},
};
setLoader(true);
await api
.patch(`${API_ROUTE.PARTICIPANTS_REQUEST}/${id}`, data, configuration)
.then((res) => {
if (res?.data?.code == 1) {
const message = `${
isApproved
? APP_CONSTANTS.APPROVED_LABEL
: APP_CONSTANTS.REJECTED_LABEL
} successfully`;
toast(message);
} else {
toast(res?.data?.message);
}
try {
let message = "";
setLoader(true);
if (props.from === "approved") {
await api.post(`${API_ROUTE.ADMIN_APPROVAL}`, { memberIds: [props.id] }, configuration);
message = `Successfully ${APP_CONSTANTS.VERIFIED_FLAG}`;
} else {
await api.patch(`${API_ROUTE.PARTICIPANTS_REQUEST}/${id}`, data, configuration)
message = status === "REJECTED"
? `Successfully ${APP_CONSTANTS.REJECTED_LABEL}`
: `Successfully ${isVerified ? APP_CONSTANTS.VERIFIED_FLAG : APP_CONSTANTS.UNVERIFIED_FLAG}`;
}
setOpenModal(false)
toast(message);
router.push({
pathname: ROUTE_CONSTANTS.PENDING_LIST,
});
} catch (error: any) {
if (error.response?.status === 500) {
router.push({
pathname: ROUTE_CONSTANTS.PENDING_LIST,
pathname: ROUTE_CONSTANTS.INTERNAL_SERVER_ERROR,
});
})
.catch((e) => {
if (e.response.status === 500) {
router.push({
pathname: ROUTE_CONSTANTS.INTERNAL_SERVER_ERROR,
});
} else if (e.response.status === 400) {
toast(e?.response?.data?.message);
} else {
toast(e?.message);
}
})
.finally(() => setLoader(false));
} else if (error.response?.status === 400) {
toast(error.response?.data?.message || 'Bad request');
} else {
toast(error.message || 'An unexpected error occurred');
}
} finally {
setOpenModal(false)
setLoader(false);
}
}

const handleOpen = () => {
setOpenModal(true);
}

const onClose = () => {
setOpenModal(false);
}

return (
<div className="header">
{openModal &&
<Modal
isOpen={true}
onClose={onClose}
>
<div className="relative h-[21vh] w-[640px] rounded-[8px] bg-white text-[#000000]">
<div className='absolute top-[10px] right-[10px]'>
<button onClick={onClose}>
<img
alt="close"
src="/assets/images/close_gray.svg"
height={20}
width={20}
/>
</button>
</div>
<div className='p-[30px] flex flex-col justify-between '>
<div className='text-2xl font-extrabold leading-8 text-left py-[10px]'>
Are you sure you want to reject?
</div>
<div className='text-sm font-normal leading-5 text-left'>
Clicking reject will remove the member from the list.
</div>

<div className="flex gap-[8px] mt-[25px] justify-end">
<button
onClick={() => setOpenModal(false)}
className={`flex items-center gap-[4px] rounded-[8px] border border-[#CBD5E1] px-[18px] py-[10px] text-[13px] font-[400]`}
>
Cancel
</button>

<button
className={`flex items-center gap-[4px] rounded-[8px] border border-[#CBD5E1] px-[18px] py-[10px] text-[13px] font-[400] text-white bg-[#DD2C5A]`}
onClick={() => approvelClickHandler(props?.id, "REJECTED", false, props?.setLoader)}
>
Reject
</button>
</div>
</div>
</div>
</Modal>
}
<nav className="navbar fixed bottom-0 z-[1157] grid h-[80px] w-full grid-flow-col items-center bg-[white] px-12 only-of-type:shadow-[0_1px_4px_0_#e2e8f0]">
<div className="col-span-4 justify-self-end">
{!props.isEditEnabled ? (
Expand All @@ -85,46 +135,44 @@ export function FooterButtons(props) {
</div>
<div className="col-span-3 justify-self-end">
<div className="flex items-end space-x-3">
<div>
{props.from !== "approved" &&
<button
className={`on-focus leading-3.5 text-md mb-2 mr-2 flex items-center rounded-full border border-slate-300 px-4 py-2 text-left font-medium text-white last:mr-0 focus-within:rounded-full hover:border-slate-400 focus:rounded-full focus-visible:rounded-full ${
props.isEditEnabled && 'bg-slate-400'
} ${!props.isEditEnabled && ' bg-[#D65229]'}`}
onClick={() => approvelClickHandler(props?.id, "APPROVED", false, props?.setLoader)}
disabled={props.isEditEnabled}
onClick={() =>
handleAprroveOrReject(
props?.id,
props?.type,
props?.referenceUid,
false,
props?.setLoader
)
}
className={`flex items-center gap-[4px] rounded-[8px] border border-[#CBD5E1] px-[8px] py-[4px] text-[13px] font-[400] ${props.isEditEnabled && 'bg-slate-400 text-[#FFFFFF]'}`}
>
<XIcon className="stroke-3 h-6 w-6 pr-1" />
<span>Reject</span>
{!props.isEditEnabled ?
<img height={20} width={20} src="assets/images/unverified.svg" alt="verified" /> :
<img height={20} width={20} src="/assets/icons/upgrade-rounded.svg" alt="verified" />}
Unverify
</button>
</div>
<div>
}

<button
className={`flex items-center gap-[4px] rounded-[8px] border border-[#CBD5E1] px-[8px] py-[4px] text-[13px] font-[400] ${props.isEditEnabled && 'bg-slate-400 text-[#FFFFFF]'}`}
disabled={props.isEditEnabled}
onClick={() => approvelClickHandler(props?.id, "APPROVED", true, props?.setLoader)}
>
{!props.isEditEnabled ?
<img height={20} width={20} src="assets/images/verified.svg" alt="verified" /> :
<img height={20} width={20} src="/assets/icons/upgrade-rounded.svg" alt="verified" />
}
Verify
</button>

{props.from !== "approved" &&
<button
className={`on-focus leading-3.5 text-md mb-2 mr-2 flex items-center rounded-full border border-slate-300 px-5 py-2 text-left font-medium text-white last:mr-0 focus-within:rounded-full hover:border-slate-400 focus:rounded-full focus-visible:rounded-full ${
props.isEditEnabled && 'bg-slate-400'
} ${!props.isEditEnabled && 'bg-[#0F9F5A]'}`}
onClick={() => handleOpen()}
disabled={props.isEditEnabled}
onClick={() =>
handleAprroveOrReject(
props?.id,
props?.type,
props?.referenceUid,
true,
props?.setLoader
)
}
className={`flex items-center gap-[4px] rounded-[8px] border border-[#CBD5E1] px-[8px] py-[4px] text-[13px] font-[400] ${props.isEditEnabled && 'bg-slate-400 text-[#FFFFFF]'}`}
>
<CheckIcon className="stroke-3 h-6 w-6 pr-1" />
<span>Approve</span>
{!props.isEditEnabled ?
<img height={20} width={20} src="/assets/images/delete.svg" alt="verified" />
:
<img height={16} width={16} src="assets/icons/TrashIcon.svg" alt="delete" />}
Reject
</button>
</div>
}
</div>
</div>
</nav>
Expand Down
Loading

0 comments on commit 0acafa8

Please sign in to comment.