Skip to content

Commit

Permalink
Merge pull request #179 from suvarnakale/release-1.0.0
Browse files Browse the repository at this point in the history
Issue #PS-0000 chore: request body changes for event list API
  • Loading branch information
itsvick authored Aug 23, 2024
2 parents 09edbf7 + f8e38b5 commit f426def
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 48 deletions.
20 changes: 11 additions & 9 deletions public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,8 @@
"THIS_SESSION": "This session",
"FOLLOWING_SESSIONS": "This and following sessions",
"MODE_OF_SESSION": "Mode of Session",
"OFFLINE": "Offline",
"ONLINE": "Online",
"OFFLINE": "offline",
"ONLINE": "online",
"SUBJECT": "Subject",
"MEETING_LINK": "Meeting Link",
"MEETING_PASSCODE": "Meeting Passcode (if applicable)",
Expand Down Expand Up @@ -367,17 +367,19 @@
"SUBJECT_OPTIONAL": "Subject (Optional)",
"RECURRING_ONLINE": "Recurring online",
"RECURRING_OFFLINE": "Recurring offline",
"EXTRA_ONLINE": "Extra online",
"EXTRA_OFFLINE": "Extra offline",
"ENTER_VALID_MEETING_LINK": "Please enter a valid Zoom or Google Meet link.",
"ZOOM": "Zoom",
"GOOGLEMEET": "GoogleMeet",
"SET_UP": "Set-Up",
"EDIT_THIS_SESSION":" Edit this session",
"EDIT_FOLLOWING_SESSIONS":" Edit this and following sessions",
"DELETE_SESSION_MSG":"Are you sure you want to delete this session?",
"DELETE_ALL_SESSION_MSG":"Are you sure you want to delete all sessions in this series?",
"DELETE_THIS_SESSION":"Delete this session",
"DELETE_FOLLOWING_SESSION":"Delete this and following sessions",
"UPDATE_CHANGES":"Are you sure you want to update the changes?"
"EDIT_THIS_SESSION": " Edit this session",
"EDIT_FOLLOWING_SESSIONS": " Edit this and following sessions",
"DELETE_SESSION_MSG": "Are you sure you want to delete this session?",
"DELETE_ALL_SESSION_MSG": "Are you sure you want to delete all sessions in this series?",
"DELETE_THIS_SESSION": "Delete this session",
"DELETE_FOLLOWING_SESSION": "Delete this and following sessions",
"UPDATE_CHANGES": "Are you sure you want to update the changes?"
},
"MANAGE_USERS": {
"CENTERS_REQUESTED_SUCCESSFULLY": "Center Requested Successfully",
Expand Down
45 changes: 12 additions & 33 deletions src/components/PlannedSession.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const PlannedSession: React.FC<PlannedModalProps> = ({
onEventDeleted,
}) => {
const [mode, setMode] = useState<mode>(sessionMode.OFFLINE);
const [eventType, setEventType] = useState<type>(sessionType.REPEATING);
const [eventType, setEventType] = useState<type>(sessionType.JUST);
const [link, setLink] = useState('');
const [linkError, setLinkError] = useState('');
const [selectedWeekDays, setSelectedWeekDays] = useState<string[]>();
Expand Down Expand Up @@ -555,16 +555,9 @@ const PlannedSession: React.FC<PlannedModalProps> = ({
: t('CENTER_SESSION.RECURRING_OFFLINE');
} else if (clickedBox === 'EXTRA_SESSION') {
title =
eventType === t('CENTER_SESSION.JUST') &&
mode === t('CENTER_SESSION.ONLINE')
? t('CENTER_SESSION.NON_RECURRING_ONLINE')
: eventType === t('CENTER_SESSION.REAPEATING') &&
mode === t('CENTER_SESSION.ONLINE')
? t('CENTER_SESSION.ONLINE')
: eventType === t('CENTER_SESSION.JUST') &&
mode === t('CENTER_SESSION.OFFLINE')
? t('CENTER_SESSION.NON_RECURRING_OFFLINE')
: t('CENTER_SESSION.RECURRING_ONLINE');
? t('CENTER_SESSION.EXTRA_ONLINE')
: t('CENTER_SESSION.EXTRA_OFFLINE');
}

// Create API bodies
Expand Down Expand Up @@ -807,7 +800,9 @@ const PlannedSession: React.FC<PlannedModalProps> = ({
id="demo-simple-select"
label={t('CENTER_SESSION.SUBJECT')}
style={{ borderRadius: '4px' }}
onChange={(event: any) => handleSubjectChange(block?.id, event)}
onChange={(event: any) =>
handleSubjectChange(block?.id, event)
}
value={selectedSubject}
>
{subjects?.map((subject: string) => (
Expand All @@ -816,10 +811,9 @@ const PlannedSession: React.FC<PlannedModalProps> = ({
</MenuItem>
))}
<MenuItem key="other" value="other">
{t('FORM.OTHER')}
{t('FORM.OTHER')}
</MenuItem>
</Select>

</FormControl>
</Box>

Expand All @@ -834,14 +828,11 @@ const PlannedSession: React.FC<PlannedModalProps> = ({
}}
/>
</Box>

</>
)}

{block?.sessionMode === sessionMode.ONLINE && (
<>


{/* <Box
sx={{
fontSize: '14px',
Expand All @@ -853,7 +844,6 @@ const PlannedSession: React.FC<PlannedModalProps> = ({
{t('CENTER_SESSION.SET_UP')}
</Box> */}


<Box sx={{ mt: 2 }}>
<TextField
id="outlined-basic"
Expand Down Expand Up @@ -975,12 +965,7 @@ const PlannedSession: React.FC<PlannedModalProps> = ({
label={t('CENTER_SESSION.START_TIME')}
value={block?.sessionStartTime || startTime}
onChange={(newValue) =>
handleChange(
block?.id,
newValue,
'start',
'time'
)
handleChange(block?.id, newValue, 'start', 'time')
}
sx={{ borderRadius: '4px', fontSize: '2px' }}
/>
Expand All @@ -1003,12 +988,10 @@ const PlannedSession: React.FC<PlannedModalProps> = ({
</Grid>
</Grid>
</Box>

</Box>
</>
)}
{clickedBox !== 'EXTRA_SESSION' && (

<Box sx={{ mt: 2 }}>
<Box sx={{ overflow: 'none' }}>
<Typography variant="h2" component="h2">
Expand Down Expand Up @@ -1110,10 +1093,7 @@ const PlannedSession: React.FC<PlannedModalProps> = ({
</Grid>
</Grid>
</Box>

)
}

)}

{editSession && (
<Box>
Expand All @@ -1135,10 +1115,9 @@ const PlannedSession: React.FC<PlannedModalProps> = ({
}}
onClick={handleOpenModel}
>
{

editSelection === 'EDIT_SESSION' ? t('CENTER_SESSION.DELETE_THIS_SESSION') : t('CENTER_SESSION.DELETE_FOLLOWING_SESSION')
}
{editSelection === 'EDIT_SESSION'
? t('CENTER_SESSION.DELETE_THIS_SESSION')
: t('CENTER_SESSION.DELETE_FOLLOWING_SESSION')}
</Box>
<DeleteOutlineIcon
sx={{ fontSize: '18px', color: theme?.palette?.error.main }}
Expand Down
20 changes: 16 additions & 4 deletions src/pages/centers/[cohortId]/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import {
formatSelectedDate,
getAfterDate,
getBeforeDate,
getMonthName,
getTodayDate,
shortDateFormat,
Expand Down Expand Up @@ -53,7 +55,6 @@ import reassignLearnerStore from '@/store/reassignLearnerStore';
import { Role } from '@/utils/app.constant';
import { showToastMessage } from '@/components/Toastify';
import { getEventList } from '@/services/EventService';

import manageUserStore from '@/store/manageUserStore';
import { modifyAttendanceLimit, eventDaysLimit } from '../../../../app.config';

Expand Down Expand Up @@ -198,10 +199,15 @@ const CohortPage = () => {
useEffect(() => {
const getSessionsData = async () => {
try {
const afterDate = getAfterDate(selectedDate);
const beforeDate = getBeforeDate(selectedDate);
const limit = 0;
const offset = 0;
const filters = {
date: selectedDate,
date: {
after: afterDate,
before: beforeDate,
},
cohortId: cohortId,
status: ['live'],
};
Expand Down Expand Up @@ -232,11 +238,17 @@ const CohortPage = () => {
date.setDate(date.getDate() + modifyAttendanceLimit)
);
const endDate = shortDateFormat(lastDate);
const afterDate = getAfterDate(startDate);
const beforeDate = getBeforeDate(endDate);
const limit = 0;
const offset = 0;
const filters = {
startDate: startDate,
endDate: endDate,
startDate: {
after: afterDate,
},
endDate: {
before: beforeDate,
},
cohortId: cohortId,
status: ['live'],
};
Expand Down
20 changes: 18 additions & 2 deletions src/utils/Helper.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Role, Status, labelsToExtractForMiniProfile } from './app.constant';

import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import FingerprintJS from 'fingerprintjs2';
import { CustomField, UpdateCustomField } from './Interfaces';
dayjs.extend(utc);

export const ATTENDANCE_ENUM = {
PRESENT: 'present',
Expand Down Expand Up @@ -405,5 +407,19 @@ export const getEmailPattern = (): string => {
};

export const translateString = (t: any, label: string) => {
return t(`FORM.${label}`) === `FORM.${label}` ? toPascalCase(label) : t(`FORM.${label}`);
return t(`FORM.${label}`) === `FORM.${label}`
? toPascalCase(label)
: t(`FORM.${label}`);
};

export const getAfterDate = (selectedDate: string) => {
const selected = dayjs.utc(selectedDate, 'YYYY-MM-DD');
const afterDate = selected.subtract(1, 'day').hour(18).minute(30).second(0);
return afterDate.format('YYYY-MM-DDTHH:mm:ss[Z]');
};

export const getBeforeDate = (selectedDate: string) => {
const selected = dayjs.utc(selectedDate, 'YYYY-MM-DD');
const beforeDate = selected.hour(18).minute(29).second(59);
return beforeDate.format('YYYY-MM-DDTHH:mm:ss[Z]');
};

0 comments on commit f426def

Please sign in to comment.