frontend/app/composables/Note.ts
2025-08-28 07:41:51 +02:00

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;
};