Skip to content

Commit

Permalink
Merge pull request #73 from suvarnakale/release-1.0.0
Browse files Browse the repository at this point in the history
Issue #PS-1600 feat: added service for scheduling events and function…
  • Loading branch information
itsvick authored Aug 1, 2024
2 parents c673dca + ee9c185 commit fc82526
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 5 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
NEXT_PUBLIC_BASE_URL=https://qa.prathamteacherapp.tekdinext.com/user/v1
NEXT_PUBLIC_EVENT_BASE_URL=http://3.109.46.84:4000/event/v1
NEXT_PUBLIC_TELEMETRY_URL=https://qa.prathamteacherapp.tekdinext.com
NEXT_PUBLIC_MEASUREMENT_ID= G-GNMQZ8Z65Z
NEXT_PUBLIC_TRACKING_API_URL=https://tracking-pratham.tekdinext.com
9 changes: 5 additions & 4 deletions src/components/AddLeanerModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,12 @@ const AddLearnerModal: React.FC<AddLearnerModalProps> = ({
onReload?.();
}
} else {
const response = await createUser(apiBody);
showToastMessage(t('LEARNERS.LEARNER_CREATED_SUCCESSFULLY'), 'success');
await createUser(apiBody);
}
onClose();
showToastMessage(t('COMMON.LEARNER_CREATED_SUCCESSFULLY'), 'success');
onLearnerAdded?.();
} catch (error) {
onClose();
showToastMessage(t('COMMON.SOMETHING_WENT_WRONG'), 'error');
setReloadProfile(true);
}
Expand Down Expand Up @@ -275,7 +274,9 @@ const AddLearnerModal: React.FC<AddLearnerModalProps> = ({
open={open}
onClose={onClose}
showFooter={false}
modalTitle={isEditModal ? t('COMMON.EDIT_LEARNER') : t('COMMON.NEW_LEARNER')}
modalTitle={
isEditModal ? t('COMMON.EDIT_LEARNER') : t('COMMON.NEW_LEARNER')
}
>
{formData
? schema &&
Expand Down
15 changes: 15 additions & 0 deletions src/services/EventService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { scheduleEventParam } from '@/utils/Interfaces';
import { post } from './RestClient';

export const AssesmentListService = async ({
filters,
}: scheduleEventParam): Promise<any> => {
const apiUrl: string = `${process.env.NEXT_PUBLIC_EVENT_BASE_URL}/list`;
try {
const response = await post(apiUrl, { filters });
return response?.data;
} catch (error) {
console.error('error in getting event List Service list', error);
return error;
}
};
4 changes: 4 additions & 0 deletions src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -983,3 +983,7 @@ input[type='number']::-webkit-outer-spin-button {
white-space: nowrap;
text-overflow: ellipsis;
}

legend.Mui-focused {
color: inherit !important;
}
30 changes: 29 additions & 1 deletion src/utils/Helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,38 @@ export const generateUsernameAndPassword = (
return { username, password };
};

export const mapFieldIdToValue = (fields: CustomField[]): { [key: string]: string } => {
export const mapFieldIdToValue = (
fields: CustomField[]
): { [key: string]: string } => {
return fields.reduce((acc: { [key: string]: string }, field: CustomField) => {
acc[field.fieldId] = field.value;
return acc;
}, {});
};

export const convertUTCToIST = (utcDateTime: any) => {
const utcDate = new Date(utcDateTime);

const utcYear = utcDate.getUTCFullYear();
const utcMonth = (utcDate.getUTCMonth() + 1).toString().padStart(2, '0'); // Months are zero-based
const utcDateDay = utcDate.getUTCDate().toString().padStart(2, '0');

let utcHours = utcDate.getUTCHours();
const utcMinutes = utcDate.getUTCMinutes().toString().padStart(2, '0');
const utcSeconds = utcDate.getUTCSeconds().toString().padStart(2, '0');

const ampm = utcHours >= 12 ? 'PM' : 'AM';
utcHours = utcHours % 12;
utcHours = utcHours ? utcHours : 12;

const dateString = `${utcYear}-${utcMonth}-${utcDateDay}`;
const timeString = `${utcHours.toString().padStart(2, '0')}:${utcMinutes}:${utcSeconds} ${ampm}`;

return { dateString, timeString };
};

export const convertLocalToUTC = (localDateTime: any) => {
const localDate = new Date(localDateTime);
const utcDateTime = localDate.toISOString();
return utcDateTime;
};
15 changes: 15 additions & 0 deletions src/utils/Interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,3 +422,18 @@ export interface CoursePlannerCardsProps {
title: string;
subtitle: string;
}

export interface scheduleEventParam {
limit: number;
page: number;
filters: eventFilters;
}

export interface eventFilters {
date?: string;
startDate?: string;
endDate?: string;
eventType?: [];
title?: string;
status?: [];
}

0 comments on commit fc82526

Please sign in to comment.