Skip to content

Commit

Permalink
Merge pull request #260 from Rushikesh-Sonawane99/shiksha-2.0
Browse files Browse the repository at this point in the history
Issue #PS-384 chore: Modified props to handle overview card height
  • Loading branch information
itsvick authored Jun 6, 2024
2 parents c664d6a + df2d6fa commit 7531207
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 11 deletions.
44 changes: 35 additions & 9 deletions src/components/OverviewCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@ import { useTheme } from '@mui/material/styles';

interface OverviewCardProps {
label: string;
value: string | number;
value?: string | number;
valuePartOne?: string | number;
valuePartTwo?: string | number | null;
}

const OverviewCard: React.FC<OverviewCardProps> = ({ label, value }) => {
const OverviewCard: React.FC<OverviewCardProps> = ({
label,
value,
valuePartOne,
valuePartTwo,
}) => {
const theme = useTheme<any>();
// const { t } = useTranslation();

Expand All @@ -34,13 +41,32 @@ const OverviewCard: React.FC<OverviewCardProps> = ({ label, value }) => {
>
{label}
</Typography>
<Typography
variant="h2"
sx={{ color: '#1F1B13', fontSize: '16px', fontWeight: '500' }}
fontWeight={500}
>
{value}
</Typography>
{value ? (
<Typography
variant="h2"
sx={{ color: '#1F1B13', fontSize: '16px', fontWeight: '500' }}
fontWeight={500}
>
{value}
</Typography>
) : (
<Box>
<Typography
variant="h2"
sx={{ color: '#1F1B13', fontSize: '16px', fontWeight: '500' }}
fontWeight={500}
>
{valuePartOne}
</Typography>
<Typography
variant="h2"
sx={{ color: '#1F1B13', fontSize: '16px', fontWeight: '500' }}
fontWeight={500}
>
{valuePartTwo}
</Typography>
</Box>
)}
</Box>
</Box>
);
Expand Down
8 changes: 6 additions & 2 deletions src/pages/attendance-overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -711,9 +711,9 @@ const AttendanceOverview: React.FC<AttendanceOverviewProps> = () => {
showBackdrop={false}
/>
))}
value={
valuePartOne={
lowAttendanceLearnerList.length > 2
? `${truncate(lowAttendanceLearnerList[0], 50)}, ${truncate(lowAttendanceLearnerList[1], 10)} ${t('COMMON.AND')} ${lowAttendanceLearnerList.length - 2} ${t('COMMON.MORE')}`
? `${truncate(lowAttendanceLearnerList[0], 50)}, ${truncate(lowAttendanceLearnerList[1], 10)}`
: lowAttendanceLearnerList.length === 2
? `${truncate(lowAttendanceLearnerList[0], 10)}, ${truncate(lowAttendanceLearnerList[1], 10)}`
: lowAttendanceLearnerList.length === 1
Expand All @@ -723,6 +723,10 @@ const AttendanceOverview: React.FC<AttendanceOverviewProps> = () => {
? t('ATTENDANCE.NO_LEARNER_WITH_LOW_ATTENDANCE')
: t('ATTENDANCE.N/A')
}
valuePartTwo={
lowAttendanceLearnerList.length > 2
? `${t('COMMON.AND')} ${lowAttendanceLearnerList.length - 2} ${t('COMMON.MORE')}` : null
}
/>
</Grid>
</Grid>
Expand Down

0 comments on commit 7531207

Please sign in to comment.