diff --git a/cypress/e2e/profile.cy.tsx b/cypress/e2e/profile.cy.tsx index e3b9f29bd..996992334 100644 --- a/cypress/e2e/profile.cy.tsx +++ b/cypress/e2e/profile.cy.tsx @@ -1,6 +1,7 @@ import {Manager} from "@haapi/typescript-client"; import {toUTC} from "../../src/utils/date"; import {manager1Mock} from "../fixtures/api_mocks/managers-mocks"; +import {statsMocks} from "../fixtures/api_mocks/letters-mocks"; const editedManager1: Required<Manager> = { ...manager1Mock, @@ -28,8 +29,9 @@ describe("Profil test", () => { cy.getByTestid("latitude-input") .click() .type(editedManager1.coordinates.latitude!.toString()); + cy.intercept("GET", `students/letters/stats`, statsMocks).as("getStats"); - cy.intercept("PUT", `/managers/${manager1Mock.id}`, editedManager1).as( + cy.intercept("PUT", `*/managers/${manager1Mock.id}`, editedManager1).as( "modifyProfile" ); diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 85aed1d08..9f00fa9e8 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -60,7 +60,9 @@ Cypress.Commands.add("login", (options: LoginConfig) => { role, }; - cy.intercept(`**/${role.toLowerCase()}s/${user.id}`, user).as("getProfile"); + cy.intercept("GET", `**/${role.toLowerCase()}s/${user.id}`, user).as( + "getProfile" + ); cy.intercept("**/health/db", "OK").as("getHealthDb"); cy.intercept("POST", "https://cognito-idp.eu-west-3.amazonaws.com").as( "postCognito" diff --git a/src/operations/profile/ProfileEdit.tsx b/src/operations/profile/ProfileEdit.tsx index 00b85f91c..6c0c921e6 100644 --- a/src/operations/profile/ProfileEdit.tsx +++ b/src/operations/profile/ProfileEdit.tsx @@ -12,18 +12,20 @@ import {toUTC} from "../../utils/date"; const userToUserApi = ({ birth_date, entrance_datetime, - ending_service, coordinates = {}, ...data }: User & Required<Student>["coordinates"] & Required<StaffMember>) => { const {latitude, longitude} = coordinates; + const {isStaffMember} = useRole(); + + if (isStaffMember() && data.ending_service) { + data.ending_service = toUTC(new Date(data.ending_service!)); + } + return { ...data, birth_date: toUTC(new Date(birth_date!)).toISOString(), entrance_datetime: toUTC(new Date(entrance_datetime!)).toISOString(), - ending_service: ending_service - ? toUTC(new Date(ending_service!)).toISOString() - : null, coordinates: {latitude: +latitude!, longitude: +longitude!}, }; };