Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | 144x 14x 14x 144x 144x 144x | import { TagType } from "@common/Tag";
import { useSelector } from "react-redux";
import { selectUser } from "@redux/slices/auth/auth";
import { toUTCDateFormat } from "@utils/index";
import { IMerchantBankAccount } from "@components/Merchants/MerchantPreview/data.types";
type StatusMessageProps = {
data: IMerchantBankAccount;
};
export const getRenamedStatus: (status: string) => TagType = (status) => {
switch (status) {
case "pending":
return "upload" as TagType;
case "pending_review":
return "pending" as TagType;
default:
return status as TagType;
}
};
export const getMerchantStatusMessage = ({ data }: StatusMessageProps) => {
switch (data.status) {
case "update_requested":
case "upload":
return "Please upload a bank statement.";
case "pending":
return "Bank Account is being reviewed.";
case "approved":
return "Bank Account has been approved.";
case "declined":
return "We apologize but the Bank Account could not be approved at this time.";
default:
return data.status as TagType;
}
};
export const getAcqEntStatusMessage = ({ data }: StatusMessageProps) => {
const { declinedByEmail } = data;
const declinedByName = data.declinedByName?.trim();
switch (data.status) {
case "upload":
return "Bank Statement needs to be uploaded.";
case "pending":
return "Bank Statement uploaded and ready for review.";
case "approved":
return `Approved ${
data.approvedAt ? `on ${toUTCDateFormat(data.approvedAt)}` : ""
} ${data.approvedByName ? `by ${data.approvedByName}` : ""}`;
case "declined":
return `Declined ${
data.declinedAt ? `on ${toUTCDateFormat(data.declinedAt)}` : ""
} ${
declinedByName || declinedByEmail
? `by ${declinedByName || declinedByEmail}`
: ""
}`;
default:
return data.status as TagType;
}
};
export const getStatusMessage = (props: StatusMessageProps) => {
const auth = useSelector(selectUser);
switch (auth?.role) {
case "merchant":
return getMerchantStatusMessage(props);
default:
return getAcqEntStatusMessage(props);
}
};
|