diff --git a/src/api/patchCourseById.ts b/src/api/patchCourseById.ts index bc6f1be..e68669c 100644 --- a/src/api/patchCourseById.ts +++ b/src/api/patchCourseById.ts @@ -2,8 +2,8 @@ import { client } from "./client"; import type { Course } from "./types"; export type PatchCourseBody = { - title?: string; - description?: string; + title?: string | null; + description?: string | null; }; export function patchCourseById(id: string, body: PatchCourseBody): Promise { diff --git a/src/api/patchEventById.ts b/src/api/patchEventById.ts index c6d8c10..b766f33 100644 --- a/src/api/patchEventById.ts +++ b/src/api/patchEventById.ts @@ -3,8 +3,8 @@ import type { Event } from "./types"; /** Omitted time fields keep their value; explicit null clears them. */ export type PatchEventBody = { - title?: string; - description?: string; + title?: string | null; + description?: string | null; starts_at?: number | null; ends_at?: number | null; }; diff --git a/src/api/patchExamById.ts b/src/api/patchExamById.ts index 208798f..064f869 100644 --- a/src/api/patchExamById.ts +++ b/src/api/patchExamById.ts @@ -2,10 +2,10 @@ import { client } from "./client"; import type { Exam } from "./types"; export type PatchExamBody = { - title?: string; - description?: string; - kind?: string; - weight?: number; + title?: string | null; + description?: string | null; + kind?: string | null; + weight?: number | null; mode?: string | null; starts_at?: number | null; ends_at?: number | null; diff --git a/src/api/patchExamQuestionById.ts b/src/api/patchExamQuestionById.ts index e8d51d1..263e123 100644 --- a/src/api/patchExamQuestionById.ts +++ b/src/api/patchExamQuestionById.ts @@ -2,9 +2,9 @@ import { client } from "./client"; import type { ExamQuestion, QuestionKind } from "./types"; export type PatchExamQuestionBody = { - text?: string; - kind?: QuestionKind; - points?: number; + text?: string | null; + kind?: QuestionKind | null; + points?: number | null; choices?: string[] | null; correct?: number | null; }; diff --git a/src/api/patchMe.ts b/src/api/patchMe.ts index 605ca53..5e30af3 100644 --- a/src/api/patchMe.ts +++ b/src/api/patchMe.ts @@ -1,6 +1,6 @@ import { client } from "@/api/client"; -import type { ProfileUpdate } from "@/api/types"; +import type { ProfileUpdate, User } from "@/api/types"; -export async function patchMe(body: ProfileUpdate): Promise { - await client("/auth/me", { method: "PATCH", body }); +export function patchMe(body: ProfileUpdate): Promise { + return client("/users/me", { method: "PATCH", body }); } diff --git a/src/api/patchNoteById.ts b/src/api/patchNoteById.ts index b77a592..e1b9601 100644 --- a/src/api/patchNoteById.ts +++ b/src/api/patchNoteById.ts @@ -2,8 +2,8 @@ import { client } from "./client"; import type { Note } from "./types"; export type PatchNoteBody = { - title?: string; - content?: string; + title?: string | null; + content?: string | null; }; export function patchNoteById(id: string, body: PatchNoteBody): Promise { diff --git a/src/api/patchUserProfile.ts b/src/api/patchUserProfile.ts index 5b33acf..ce60259 100644 --- a/src/api/patchUserProfile.ts +++ b/src/api/patchUserProfile.ts @@ -1,6 +1,6 @@ import { client } from "@/api/client"; -import type { ProfileUpdate } from "@/api/types"; +import type { ProfileUpdate, User } from "@/api/types"; -export async function patchUserProfile(id: string, body: ProfileUpdate): Promise { - await client(`/users/${encodeURIComponent(id)}/profile`, { method: "PATCH", body }); +export function patchUserProfile(id: string, body: ProfileUpdate): Promise { + return client(`/users/${encodeURIComponent(id)}/profile`, { method: "PATCH", body }); } diff --git a/src/api/postCourse.ts b/src/api/postCourse.ts index ac62db1..762040f 100644 --- a/src/api/postCourse.ts +++ b/src/api/postCourse.ts @@ -3,7 +3,7 @@ import type { Course } from "./types"; export type PostCourseBody = { title: string; - description?: string; + description?: string | null; }; export function postCourse(body: PostCourseBody): Promise { diff --git a/src/api/postCourseExam.ts b/src/api/postCourseExam.ts index 18aa7d5..5c45d45 100644 --- a/src/api/postCourseExam.ts +++ b/src/api/postCourseExam.ts @@ -3,7 +3,7 @@ import type { Exam } from "./types"; export type PostCourseExamBody = { title: string; - description?: string; + description?: string | null; kind: string; weight: number; mode?: string | null; diff --git a/src/api/postEvent.ts b/src/api/postEvent.ts index e0c2a8f..a3c4d0e 100644 --- a/src/api/postEvent.ts +++ b/src/api/postEvent.ts @@ -3,7 +3,7 @@ import type { Event } from "./types"; export type PostEventBody = { title: string; - description?: string; + description?: string | null; starts_at?: number | null; ends_at?: number | null; }; diff --git a/src/api/postEventAttendance.ts b/src/api/postEventAttendance.ts index efd3c95..cca0ace 100644 --- a/src/api/postEventAttendance.ts +++ b/src/api/postEventAttendance.ts @@ -3,7 +3,7 @@ import type { Attendance, AttendanceStatus } from "./types"; export type PostEventAttendanceBody = { status: AttendanceStatus; - user_id?: string; + user_id?: string | null; }; export function postEventAttendance( diff --git a/src/api/postNote.ts b/src/api/postNote.ts index 0564b1c..f5bf6a3 100644 --- a/src/api/postNote.ts +++ b/src/api/postNote.ts @@ -3,7 +3,7 @@ import type { Note } from "./types"; export type PostNoteBody = { title: string; - content?: string; + content?: string | null; }; export function postNote(body: PostNoteBody): Promise { diff --git a/src/components/users/profile-form.tsx b/src/components/users/profile-form.tsx index 43de9bc..6b5e61f 100644 --- a/src/components/users/profile-form.tsx +++ b/src/components/users/profile-form.tsx @@ -47,11 +47,11 @@ export function ProfileForm(props: { user: User; onSaved: () => void }) { const e = email().trim(); const p = phone().trim(); const d = birthDate().trim(); - if (n !== (props.user.name ?? "")) b.name = n || null; - if (s !== (props.user.surname ?? "")) b.surname = s || null; - if (e !== (props.user.email ?? "")) b.email = e || null; - if (p !== (props.user.phone ?? "")) b.phone = p || null; - if (d !== (props.user.birth_date ?? "")) b.birth_date = d || null; + if (n !== (props.user.name ?? "")) b.name = n; + if (s !== (props.user.surname ?? "")) b.surname = s; + if (e !== (props.user.email ?? "")) b.email = e; + if (p !== (props.user.phone ?? "")) b.phone = p; + if (d !== (props.user.birth_date ?? "")) b.birth_date = d; return b; };