import { api } from "./api.ts";
import { Nullable } from "./apiTypes.ts";
import * as users from "./users.ts";

// Typescript: TSEndpoint= path=/admin/users; name=listUsers; method=POST; request=admin.ListUsersRequest; response=users.[]User
// internal/admin/routes.go Line: 12
export const listUsers = async (
  data: ListUsersRequest,
): Promise<{ data: users.User[]; error: Nullable<string> }> => {
  return (await api.POST("/admin/users", data)) as {
    data: users.User[];
    error: Nullable<string>;
  };
};

// Typescript: TSEndpoint= path=/admin/users/:uuid/block; name=blockUser; method=PUT; request=admin.BlockUserRequest; response=users.User
// internal/admin/routes.go Line: 16
export const blockUser = async (
  data: BlockUserRequest,
): Promise<{ data: users.User; error: Nullable<string> }> => {
  return (await api.PUT("/admin/users/:uuid/block", data)) as {
    data: users.User;
    error: Nullable<string>;
  };
};

export interface BlockUserRequest {
  action: string;
}

export interface ListUsersRequest {
  page: number;
  pageSize: number;
}
