import { motion } from 'framer-motion'; import { FunctionComponent, useMemo } from 'react'; import { ctw } from '../../../../common/utils/ctw/ctw'; import { NavLink, useLocation } from 'react-router-dom'; import { Avatar } from '../../../../common/components/atoms/Avatar'; import { IItemProps } from '../../../Entity/components/Case/interfaces'; import { stringToRGB } from '../../../../common/utils/string-to-rgb/string-to-rgb'; import { ApprovedSvg, RejectedSvg } from '../../../../common/components/atoms/icons'; import { UserAvatar } from '../../../../common/components/atoms/UserAvatar/UserAvatar'; import { createInitials } from '../../../../common/utils/create-initials/create-initials'; import { useEllipsesWithTitle } from '../../../../common/hooks/useEllipsesWithTitle/useEllipsesWithTitle'; import dayjs from 'dayjs'; import { StateTag, valueOrNA } from '@ballerine/common'; /** * @description To be used by {@link Cases}, and be wrapped by {@link Cases.List}. Uses li element with default styling to display a single case's data. Navigates to the selected entity on click by setting the entity id into the path param. * * @see {@link ImageViewer.List} * @see {@link BallerineImage} * @see {@link getTimePastFromNow} - receives createdAt. * * @param props * @param props.id - The id of the entity, passed into the url on click -> /case-management/individuals/:id. * @param props.fullName - The full name of the entity. * @param props.createdAt - Expects an ISO date string to calculate the waiting time using {@link getTimePastFromNow}. * @param props.assignee - Which operator is now on the entity's case. * @param props.entityAvatarUrl - The entity's image url to pass into {@link Avatar} and ${@Link UserAvatar}. * @param props.tags - Whether the case is approved or rejected. * * @constructor */ export const Item: FunctionComponent = ({ id, fullName, createdAt, assignee, tags, entityAvatarUrl, }) => { const entityInitials = createInitials(fullName); const { ref, styles } = useEllipsesWithTitle(); const { search } = useLocation(); const rgb = useMemo(() => stringToRGB(fullName), [fullName]); const isApproved = tags?.includes(StateTag.APPROVED); const isRejected = tags?.includes(StateTag.REJECTED); return (
  • ctw( `flex h-[64px] items-center gap-x-4 rounded-lg px-5 py-4 outline-none active:bg-muted-foreground/30 active:text-foreground`, { 'bg-muted': isActive, }, ) } >
    {/* Early tell if a state has invalids tags and includes both `REJECTED` and `APPROVED` */} {isRejected && } {isApproved && }
    {valueOrNA(fullName)}
    {dayjs(new Date(createdAt)).format('D MMM YYYY HH:mm')}
    {assignee && }
  • ); };