mirror of
https://github.com/versia-pub/frontend.git
synced 2025-12-06 00:18:20 +01:00
24 lines
607 B
TypeScript
24 lines
607 B
TypeScript
import type { Status } from "@versia/client/schemas";
|
|
import type { z } from "zod";
|
|
|
|
export const useNote = (noteId: MaybeRef<string | null>) => {
|
|
if (!toValue(noteId)) {
|
|
return ref(null as z.infer<typeof Status> | null);
|
|
}
|
|
|
|
const authStore = useAuthStore();
|
|
|
|
const output = ref(null as z.infer<typeof Status> | null);
|
|
|
|
watchEffect(() => {
|
|
toValue(noteId) &&
|
|
authStore.client
|
|
.getStatus(toValue(noteId) as string)
|
|
.then((res) => {
|
|
output.value = res.data;
|
|
});
|
|
});
|
|
|
|
return output;
|
|
};
|