bug fix
This commit is contained in:
@@ -12,7 +12,7 @@ export const user_api = {
|
||||
return res;
|
||||
},
|
||||
|
||||
async update({ body, id }: { id: string; body: UserCreateReq }) {
|
||||
async update({ body, id }: { id: string | number; body: UserCreateReq }) {
|
||||
const res = await httpClient.patch(`${API_URLS.UserUpdate(id)}`, body);
|
||||
return res;
|
||||
},
|
||||
@@ -22,7 +22,7 @@ export const user_api = {
|
||||
return res;
|
||||
},
|
||||
|
||||
async delete({ id }: { id: string }) {
|
||||
async delete({ id }: { id: string | number }) {
|
||||
const res = await httpClient.delete(`${API_URLS.UserDelete(id)}`);
|
||||
return res;
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export interface UserData {
|
||||
id: 3;
|
||||
id: number;
|
||||
username: string;
|
||||
first_name: string;
|
||||
last_name: string;
|
||||
@@ -21,13 +21,7 @@ export interface UserListRes {
|
||||
}
|
||||
|
||||
export interface UserCreateReq {
|
||||
id: 3;
|
||||
username: string;
|
||||
first_name: string;
|
||||
last_name: string;
|
||||
middle_name: null | string;
|
||||
gender: "M" | "F" | null;
|
||||
region: null | string;
|
||||
address: null | string;
|
||||
created_at: string;
|
||||
password: string;
|
||||
is_superuser: boolean;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ const AddUsers = ({ initialData, setDialogOpen }: UserFormProps) => {
|
||||
const form = useForm<z.infer<typeof AddedUser>>({
|
||||
resolver: zodResolver(AddedUser),
|
||||
defaultValues: {
|
||||
is_superuser: initialData?.is_superuser ? "true" : "false",
|
||||
password: "",
|
||||
username: initialData?.username || "",
|
||||
},
|
||||
@@ -43,7 +42,7 @@ const AddUsers = ({ initialData, setDialogOpen }: UserFormProps) => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const { mutate: update } = useMutation({
|
||||
mutationFn: ({ body, id }: { id: string; body: UserCreateReq }) =>
|
||||
mutationFn: ({ body, id }: { id: string | number; body: UserCreateReq }) =>
|
||||
user_api.update({ body, id }),
|
||||
onSuccess: () => {
|
||||
queryClient.refetchQueries({ queryKey: ["user_list"] });
|
||||
|
||||
@@ -31,7 +31,7 @@ const DeleteUser = ({
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const { mutate: deleteUser, isPending } = useMutation({
|
||||
mutationFn: ({ id }: { id: string }) => user_api.delete({ id }),
|
||||
mutationFn: ({ id }: { id: string | number }) => user_api.delete({ id }),
|
||||
|
||||
onSuccess: () => {
|
||||
queryClient.refetchQueries({ queryKey: ["user_list"] });
|
||||
|
||||
Reference in New Issue
Block a user