Skip to content

Commit

Permalink
Revert "PADV-1762 add delete service (#141)"
Browse files Browse the repository at this point in the history
This reverts commit e66da19.
  • Loading branch information
AuraAlba authored Dec 23, 2024
1 parent e66da19 commit 5996a48
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 81 deletions.
1 change: 0 additions & 1 deletion src/assets/colors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,3 @@ $blue-50: #a6dff7;
// Black
$black: #000;
$black-80: #333;
$black-30: #212529;
38 changes: 3 additions & 35 deletions src/features/Instructors/InstructorsDetailPage/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,13 @@ import {
import { getConfig } from '@edx/frontend-platform';
import { CalendarExpanded } from 'react-paragon-topaz';
import { startOfMonth, endOfMonth } from 'date-fns';
import { logError } from '@edx/frontend-platform/logging';

import Table from 'features/Main/Table';
import { fetchClassesData } from 'features/Classes/data/thunks';
import { resetClassesTable, updateCurrentPage } from 'features/Classes/data/slice';
import { fetchInstructorsData, fetchEventsData, resetEvents } from 'features/Instructors/data';
import { columns } from 'features/Instructors/InstructorDetailTable/columns';
import { initialPage, RequestStatus } from 'features/constants';
import { deleteEvent } from 'features/Instructors/data/api';
import { updateEvents } from 'features/Instructors/data/slice';

import { useInstitutionIdQueryParam } from 'hooks';

Expand Down Expand Up @@ -75,32 +72,6 @@ const InstructorsDetailPage = () => {
dispatch(updateCurrentPage(targetPage));
};

const handleDeleteEvent = async (event) => {
try {
const params = event?.recurrence ? {
delete_occurrence: true,
start_occurrence: event?.start,
} : {};

await deleteEvent(event.id, params);

const newEventsState = events.filter(currentEvent => currentEvent.elementId !== event.elementId);
dispatch(updateEvents(newEventsState));
} catch (error) {
logError(error);
}
};

const handleDeleteMultipleEvents = async (event) => {
try {
await deleteEvent(event.id);
const newEventsState = events.filter(currentEvent => currentEvent.id !== event.id);
dispatch(updateEvents(newEventsState));
} catch (error) {
logError(error);
}
};

useEffect(() => {
if (institution.id) {
dispatch(fetchInstructorsData(institution.id, initialPage, { instructor: instructorUsername }));
Expand All @@ -119,10 +90,7 @@ const InstructorsDetailPage = () => {

useEffect(() => {
if (instructorInfo.instructorId && showInstructorCalendar) {
dispatch(fetchEventsData({
...rangeDates,
instructor_id: instructorInfo.instructorId,
}));
dispatch(fetchEventsData({ ...rangeDates, instructor_id: instructorInfo.instructorId }));
}

return () => {
Expand Down Expand Up @@ -192,8 +160,8 @@ const InstructorsDetailPage = () => {
eventsList={eventsList}
onRangeChange={getRangeDate}
onEdit={() => {}}
onDelete={handleDeleteEvent}
onDeleteMultiple={handleDeleteMultipleEvents}
onDelete={() => {}}
onDeleteMultiple={() => {}}
onEditSinglRec={() => {}}
/>
</div>
Expand Down
5 changes: 0 additions & 5 deletions src/features/Instructors/InstructorsDetailPage/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,4 @@

.container-calendar {
box-shadow: 0px 3px 12px 0px $gray-30;

.pgn__dropdown-item {
text-decoration: none;
color: $black-30;
}
}
22 changes: 0 additions & 22 deletions src/features/Instructors/data/__test__/api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
handleInstructorsEnrollment,
handleNewInstructor,
getEventsByInstructor,
deleteEvent,
} from 'features/Instructors/data/api';

jest.mock('@edx/frontend-platform/auth', () => ({
Expand Down Expand Up @@ -101,25 +100,4 @@ describe('should call getAuthenticatedHttpClient with the correct parameters', (
},
);
});

test('delete event', () => {
const httpClientMock = {
delete: jest.fn(),
};

const eventId = 1;

getAuthenticatedHttpClient.mockReturnValue(httpClientMock);

deleteEvent(eventId);

expect(getAuthenticatedHttpClient).toHaveBeenCalledTimes(1);
expect(getAuthenticatedHttpClient).toHaveBeenCalledWith();

expect(httpClientMock.delete).toHaveBeenCalledTimes(1);
expect(httpClientMock.delete).toHaveBeenCalledWith(
'http://localhost:18000/pearson_course_operation/api/v2/events/',
{ params: { event_id: eventId } },
);
});
});
18 changes: 0 additions & 18 deletions src/features/Instructors/data/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,8 @@ function getEventsByInstructor(params) {
);
}

/**
* Delete event.
*
* @param {number} - Event id to be deleted
* @returns {Promise} - A promise that resolves with the response of the DELETE request.
*/
function deleteEvent(eventId, options = {}) {
const params = {
event_id: eventId,
...options,
};
return getAuthenticatedHttpClient().delete(
`${getConfig().COURSE_OPERATIONS_API_V2_BASE_URL}/events/`,
{ params },
);
}

export {
handleInstructorsEnrollment,
handleNewInstructor,
getEventsByInstructor,
deleteEvent,
};

0 comments on commit 5996a48

Please sign in to comment.