From a6c6f944a6ff120614e47ae778e4df1bb4574c77 Mon Sep 17 00:00:00 2001 From: Camille Moussu Date: Thu, 21 Aug 2025 11:02:38 +0200 Subject: [PATCH] [#50] fixed mailto duplication --- src/features/Calendars/CalendarSlice.ts | 4 ++-- src/features/User/userAPI.ts | 2 +- src/features/User/userSlice.ts | 8 +++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/features/Calendars/CalendarSlice.ts b/src/features/Calendars/CalendarSlice.ts index 3c87908..6b1422f 100644 --- a/src/features/Calendars/CalendarSlice.ts +++ b/src/features/Calendars/CalendarSlice.ts @@ -2,7 +2,7 @@ import { createAsyncThunk, createSlice, PayloadAction } from "@reduxjs/toolkit"; import { Calendars } from "./CalendarTypes"; import { CalendarEvent } from "../Events/EventsTypes"; import { getCalendar, getCalendars } from "./CalendarApi"; -import { getOpenPaasUserId } from "../User/userAPI"; +import getOpenPaasUser from "../User/userAPI"; import { parseCalendarEvent } from "../Events/eventUtils"; import { deleteEvent, putEvent } from "../Events/EventApi"; import { formatDateToYYYYMMDDTHHMMSS } from "../../utils/dateUtils"; @@ -12,7 +12,7 @@ export const getCalendarsListAsync = createAsyncThunk< Record // Return type >("calendars/getCalendars", async () => { const importedCalendars: Record = {}; - const user = (await getOpenPaasUserId()) as Record; + const user = (await getOpenPaasUser()) as Record; const calendars = (await getCalendars(user.id)) as Record; const rawCalendars = calendars._embedded["dav:calendar"]; diff --git a/src/features/User/userAPI.ts b/src/features/User/userAPI.ts index 6b54749..4fae660 100644 --- a/src/features/User/userAPI.ts +++ b/src/features/User/userAPI.ts @@ -7,7 +7,7 @@ export default async function getOpenPaasUser() { export async function searchUsers(query: string) { const response: any[] = await api - .post(`api/people/search/`, { + .post(`api/people/search`, { body: JSON.stringify({ limit: 10, objectTypes: ["user", "group", "contact", "ldap"], diff --git a/src/features/User/userSlice.ts b/src/features/User/userSlice.ts index a690407..226a05e 100644 --- a/src/features/User/userSlice.ts +++ b/src/features/User/userSlice.ts @@ -25,7 +25,7 @@ export const userSlice = createSlice({ state.organiserData = {} as userOrganiser; } state.organiserData.cn = action.payload.name; - state.organiserData.cal_address = `mailto:${action.payload.email}`; + state.organiserData.cal_address = action.payload.email; }, setTokens: (state, action) => { state.tokens = action.payload; @@ -39,9 +39,11 @@ export const userSlice = createSlice({ if (!state.organiserData) { state.organiserData = {} as userOrganiser; } - state.organiserData.cn = `${action.payload.firstname} ${action.payload.lastname}`; + if (action.payload.firstname && action.payload.lastname) { + state.organiserData.cn = `${action.payload.firstname} ${action.payload.lastname}`; + } if (action.payload.preferredEmail) { - state.organiserData.cal_address = `mailto:${action.payload.preferredEmail}`; + state.organiserData.cal_address = action.payload.preferredEmail; state.userData.email = action.payload.preferredEmail; } });