2024-08-28 00:23:29 +02:00
|
|
|
import type { Client } from "@versia/client";
|
2025-05-26 11:19:15 +02:00
|
|
|
import type { Account } from "@versia/client/schemas";
|
|
|
|
|
import type { z } from "zod";
|
2024-04-22 09:38:51 +02:00
|
|
|
|
2024-04-27 06:50:30 +02:00
|
|
|
export const useAccountSearch = (
|
2024-08-28 00:23:29 +02:00
|
|
|
client: MaybeRef<Client | null>,
|
2024-04-27 06:50:30 +02:00
|
|
|
q: string,
|
2025-05-26 11:19:15 +02:00
|
|
|
): Ref<z.infer<typeof Account>[] | null> => {
|
|
|
|
|
const output = ref(null as z.infer<typeof Account>[] | null);
|
2024-04-22 09:38:51 +02:00
|
|
|
|
2024-04-27 06:50:30 +02:00
|
|
|
ref(client)
|
|
|
|
|
.value?.searchAccount(q, {
|
2024-04-22 09:38:51 +02:00
|
|
|
resolve: true,
|
|
|
|
|
})
|
2024-04-27 06:50:30 +02:00
|
|
|
.then((res) => {
|
|
|
|
|
output.value = res.data;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return output;
|
2024-04-22 09:38:51 +02:00
|
|
|
};
|