Skip to content

Commit

Permalink
Merge pull request #97 from upendraTekdi/shiksha-2.0
Browse files Browse the repository at this point in the history
fixed: resolve mediaQuery error when create build.
  • Loading branch information
itsvick authored May 10, 2024
2 parents 6690e57 + 286f1ff commit 4dbc5b2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/components/ExtraSessionsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ContentCopyRoundedIcon from '@mui/icons-material/ContentCopyRounded';
import { useTranslation } from 'react-i18next';
import { truncateURL } from '@/utils/Helper';
import { ExtraSessionsCardProps } from '@/utils/Interfaces';

import { useMediaQuery } from '@mui/material';
const ExtraSessionsCard: React.FC<ExtraSessionsCardProps> = ({
subject,
instructor,
Expand All @@ -16,6 +16,8 @@ const ExtraSessionsCard: React.FC<ExtraSessionsCardProps> = ({
}) => {
const { t } = useTranslation();

const isMobile = useMediaQuery('(max-width:600px)');

return (
<Box>
<Card
Expand Down Expand Up @@ -62,7 +64,7 @@ const ExtraSessionsCard: React.FC<ExtraSessionsCardProps> = ({
display={'flex'}
justifyContent={'space-between'}
>
<Typography>{truncateURL(meetingURL, 30)}</Typography>
<Typography>{truncateURL(meetingURL, 30, isMobile)}</Typography>
{onCopyClick && (
<ContentCopyRoundedIcon
onClick={onCopyClick}
Expand Down
8 changes: 5 additions & 3 deletions src/utils/Helper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useMediaQuery } from '@mui/material';

export const ATTENDANCE_ENUM = {
PRESENT: 'present',
Expand Down Expand Up @@ -65,8 +64,11 @@ export const getMonthName = () => {
};

// Function to truncate URL if it's too long
export const truncateURL = (url: string, maxLength: number) => {
const isMobile = useMediaQuery('(max-width:600px)');
export const truncateURL = (
url: string,
maxLength: number,
isMobile: boolean
) => {
if (isMobile) {
return url.length > maxLength ? `${url.substring(0, maxLength)} ...` : url;
}
Expand Down

0 comments on commit 4dbc5b2

Please sign in to comment.