-
Tokens
-
-
+
-
-
-
)
}
diff --git a/frontend/pages/users/update/queries.tsx b/frontend/pages/users/update/queries.tsx
index a6a2792..11ae905 100644
--- a/frontend/pages/users/update/queries.tsx
+++ b/frontend/pages/users/update/queries.tsx
@@ -2,10 +2,10 @@
import { useMutation } from '@tanstack/react-query'
import { UserUpdate } from './types';
-const fetchGraphQlUsersUpdate = async (record: UserUpdate, uuid: string): Promise<{ data: UserUpdate | null; status: number }> => {
+const fetchGraphQlUsersUpdate = async (record: UserUpdate, uuid: string, selectedBuildIDS: string[], selectedCompanyIDS: string[], defaultSelection: string, refetchTable: () => void): Promise<{ data: UserUpdate | null; status: number }> => {
console.log('Fetching test data from local API');
try {
- const res = await fetch(`/api/users/update?uuid=${uuid || ''}`, { method: 'POST', cache: 'no-store', credentials: "include", body: JSON.stringify(record) });
+ const res = await fetch(`/api/users/update?uuid=${uuid || ''}`, { method: 'POST', cache: 'no-store', credentials: "include", body: JSON.stringify({ ...record, selectedBuildIDS, selectedCompanyIDS, defaultSelection }) });
if (!res.ok) { const errorText = await res.text(); console.error('Test data API error:', errorText); throw new Error(`API error: ${res.status} ${res.statusText}`) }
const data = await res.json();
return { data: data.data, status: res.status }
@@ -14,7 +14,9 @@ const fetchGraphQlUsersUpdate = async (record: UserUpdate, uuid: string): Promis
export function useUpdateUserMutation() {
return useMutation({
- mutationFn: ({ data, uuid }: { data: UserUpdate, uuid: string }) => fetchGraphQlUsersUpdate(data, uuid),
+ mutationFn: (
+ { data, uuid, selectedBuildIDS, selectedCompanyIDS, defaultSelection, refetchTable }: { data: UserUpdate, uuid: string, selectedBuildIDS: string[], selectedCompanyIDS: string[], defaultSelection: string, refetchTable: () => void }
+ ) => fetchGraphQlUsersUpdate(data, uuid, selectedBuildIDS, selectedCompanyIDS, defaultSelection, refetchTable),
onSuccess: () => { console.log("User updated successfully") },
onError: (error) => { console.error("Update user failed:", error) },
})
diff --git a/frontend/pages/users/update/schema.ts b/frontend/pages/users/update/schema.ts
index d4ffa95..df7548a 100644
--- a/frontend/pages/users/update/schema.ts
+++ b/frontend/pages/users/update/schema.ts
@@ -1,14 +1,5 @@
import { z } from "zod"
-export const tokenSchema = z.object({
- prefix: z.string().min(1, "Prefix is required"),
- token: z.string().min(1, "Token is required"),
-})
-
-export const collectionTokensSchema = z.object({
- default: z.string().optional(),
- tokens: z.array(tokenSchema)
-})
export const userUpdateSchema = z.object({
expiryStarts: z.string().optional(),
@@ -17,11 +8,11 @@ export const userUpdateSchema = z.object({
isConfirmed: z.boolean(),
isNotificationSend: z.boolean(),
+ password: z.string().min(6),
+ rePassword: z.string().min(6),
tag: z.string().optional(),
email: z.string().email(),
phone: z.string().min(5),
-
- collectionTokens: collectionTokensSchema,
})
export type UserUpdate = z.infer