forge
Explore
Log in

Don't you dare go Hollow

🐛 align user search with backend contract

Browse files at this commit

87b406448833878bead57f9ff12c9fa486f8281aBurak BoduroğluParent: 5ed887e
  • fix
    • 🐛 align user search with backend contract
Show full message
fix: 🐛 align user search with backend contract

- remove unsupported role query parameter from /users/search

- simplify the reusable user search select source shape

- drop role props from course enrollment and marks lookup pickers
src/api/getUserSearch.tsmodified+2 -3
@@ -1,8 +1,7 @@
1 import { client } from "./client";1 import { client } from "./client";
2-import type { PersonRef, Role } from "./types";2+import type { PersonRef } from "./types";
3 3
4-export function getUserSearch(query: string, role?: Role, signal?: AbortSignal): Promise<PersonRef[]> {4+export function getUserSearch(query: string, signal?: AbortSignal): Promise<PersonRef[]> {
5 const params = new URLSearchParams({ q: query });5 const params = new URLSearchParams({ q: query });
6- if (role) params.set("role", role);
7 return client<PersonRef[]>(`/users/search?${params.toString()}`, { signal });6 return client<PersonRef[]>(`/users/search?${params.toString()}`, { signal });
8 }7 }
src/components/users/user-search-select.tsxmodified+2 -4
@@ -1,6 +1,5 @@
1 import { For, Show, createMemo, createResource, createSignal } from "solid-js";1 import { For, Show, createMemo, createResource, createSignal } from "solid-js";
2 import { getUserSearch } from "@/api/getUserSearch";2 import { getUserSearch } from "@/api/getUserSearch";
3-import type { Role } from "@/api/types";
4 import { Input } from "@/components/ui/input";3 import { Input } from "@/components/ui/input";
5 import { Label } from "@/components/ui/label";4 import { Label } from "@/components/ui/label";
6 import { Select } from "@/components/ui/select";5 import { Select } from "@/components/ui/select";
@@ -12,7 +11,6 @@ export function UserSearchSelect(props: {
12 value: string;11 value: string;
13 onChange: (value: string) => void;12 onChange: (value: string) => void;
14 label?: string;13 label?: string;
15- role?: Role;
16 excludeIds?: string[];14 excludeIds?: string[];
17 placeholder?: string;15 placeholder?: string;
18 disabled?: boolean;16 disabled?: boolean;
@@ -23,11 +21,11 @@ export function UserSearchSelect(props: {
23 const search = createMemo(() => {21 const search = createMemo(() => {
24 const q = query().trim();22 const q = query().trim();
25 if (q.length < 2) return null;23 if (q.length < 2) return null;
26- return { q, role: props.role };24+ return q;
27 });25 });
28 const [users] = createResource(search, async (source) => {26 const [users] = createResource(search, async (source) => {
29 if (!source) return [];27 if (!source) return [];
30- return getUserSearch(source.q, source.role);28+ return getUserSearch(source);
31 });29 });
32 const options = createMemo(() => {30 const options = createMemo(() => {
33 const excluded = new Set(props.excludeIds ?? []);31 const excluded = new Set(props.excludeIds ?? []);
src/pages/course-detail-page.tsxmodified+0 -1
@@ -394,7 +394,6 @@ function CourseDetailContent() {
394 <UserSearchSelect394 <UserSearchSelect
395 id="course-enroll-user"395 id="course-enroll-user"
396 value={enrollUserId()}396 value={enrollUserId()}
397- role="student"
398 excludeIds={enrolledUserIds()}397 excludeIds={enrolledUserIds()}
399 placeholder={t("form.selectStudent")}398 placeholder={t("form.selectStudent")}
400 onChange={setEnrollUserId}399 onChange={setEnrollUserId}
src/pages/student-marks-page.tsxmodified+0 -1
@@ -53,7 +53,6 @@ function StudentMarksContent() {
53 <UserSearchSelect53 <UserSearchSelect
54 id="student-marks-user"54 id="student-marks-user"
55 label={t("marks.userIdentity")}55 label={t("marks.userIdentity")}
56- role="student"
57 placeholder={t("marks.userIdentity")}56 placeholder={t("marks.userIdentity")}
58 value={userId()}57 value={userId()}
59 allowManualValue58 allowManualValue