prettier fixes #16

This commit is contained in:
Michael Dausmann
2023-10-24 21:18:03 +11:00
parent dc9d64ebf5
commit a7f8c37f99
56 changed files with 1706 additions and 935 deletions

View File

@@ -1,6 +1,6 @@
import { Note } from ".prisma/client"
import { defineStore, storeToRefs } from "pinia"
import { Ref } from "vue";
import { Note } from '.prisma/client';
import { defineStore, storeToRefs } from 'pinia';
import { Ref } from 'vue';
/*
Note) the Notes Store needs to be a 'Setup Store' (https://pinia.vuejs.org/core-concepts/#setup-stores)
@@ -9,7 +9,7 @@ If the UI does not need to dynamically respond to a change in the active Account
then an Options store can be used.
*/
export const useNotesStore = defineStore('notes', () => {
const accountStore = useAccountStore()
const accountStore = useAccountStore();
const { activeAccountId } = storeToRefs(accountStore);
let _notes: Ref<Note[]> = ref([]);
@@ -17,37 +17,45 @@ export const useNotesStore = defineStore('notes', () => {
async function fetchNotesForCurrentUser() {
const { $client } = useNuxtApp();
const { notes } = await $client.notes.getForActiveAccount.query();
if(notes){
if (notes) {
_notes.value = notes;
}
}
}
async function createNote(note_text: string) {
const { $client } = useNuxtApp();
const { note } = await $client.notes.createNote.mutate({note_text});
if(note){
const { note } = await $client.notes.createNote.mutate({ note_text });
if (note) {
_notes.value.push(note);
}
}
async function deleteNote(note_id: number) {
const { $client } = useNuxtApp();
const { note } = await $client.notes.deleteNote.mutate({note_id});
if(note){
const { note } = await $client.notes.deleteNote.mutate({ note_id });
if (note) {
_notes.value = _notes.value.filter(n => n.id !== note.id);
}
}
async function generateAINoteFromPrompt(user_prompt: string) {
const { $client } = useNuxtApp();
const { noteText } = await $client.notes.generateAINoteFromPrompt.query({user_prompt});
return noteText?noteText:'';
const { noteText } = await $client.notes.generateAINoteFromPrompt.query({
user_prompt
});
return noteText ? noteText : '';
}
// if the active account changes, fetch notes again (i.e dynamic.. probabl overkill)
watch(activeAccountId, async (val, oldVal)=> {
await fetchNotesForCurrentUser()
watch(activeAccountId, async (val, oldVal) => {
await fetchNotesForCurrentUser();
});
return { notes: _notes, fetchNotesForCurrentUser, createNote, deleteNote, generateAINoteFromPrompt}
return {
notes: _notes,
fetchNotesForCurrentUser,
createNote,
deleteNote,
generateAINoteFromPrompt
};
});