routing fix
This commit is contained in:
parent
6ee055b691
commit
e0a8e503b9
2 changed files with 10 additions and 11 deletions
|
|
@ -24,7 +24,7 @@ const getFolderTree = async () => {
|
||||||
const encryptionKey = useAuthStore.getState().encryptionKey;
|
const encryptionKey = useAuthStore.getState().encryptionKey;
|
||||||
if (!encryptionKey) throw new Error("Not authenticated");
|
if (!encryptionKey) throw new Error("Not authenticated");
|
||||||
|
|
||||||
const { data, error } = await client.GET("/api/folders/tree", {});
|
const { data, error } = await client.GET("/folders/tree", {});
|
||||||
|
|
||||||
const newData = data as unknown as FolderTreeResponse;
|
const newData = data as unknown as FolderTreeResponse;
|
||||||
|
|
||||||
|
|
@ -36,7 +36,7 @@ const getFolderTree = async () => {
|
||||||
const updateFolder = async (id: number, folder: FolderUpdate) => {
|
const updateFolder = async (id: number, folder: FolderUpdate) => {
|
||||||
console.log(`Updating folder ${id} with:`, folder);
|
console.log(`Updating folder ${id} with:`, folder);
|
||||||
try {
|
try {
|
||||||
const response = await client.PATCH("/api/folders/{folder_id}", {
|
const response = await client.PATCH("/folders/{folder_id}", {
|
||||||
params: { path: { folder_id: id } },
|
params: { path: { folder_id: id } },
|
||||||
body: folder,
|
body: folder,
|
||||||
});
|
});
|
||||||
|
|
@ -50,11 +50,10 @@ const updateFolder = async (id: number, folder: FolderUpdate) => {
|
||||||
|
|
||||||
export const folderApi = {
|
export const folderApi = {
|
||||||
tree: () => getFolderTree(),
|
tree: () => getFolderTree(),
|
||||||
list: () => client.GET("/api/folders/", {}),
|
list: () => client.GET("/folders/", {}),
|
||||||
create: (folder: FolderCreate) =>
|
create: (folder: FolderCreate) => client.POST("/folders/", { body: folder }),
|
||||||
client.POST("/api/folders/", { body: folder }),
|
|
||||||
delete: (id: number) =>
|
delete: (id: number) =>
|
||||||
client.DELETE("/api/folders/{folder_id}", {
|
client.DELETE("/folders/{folder_id}", {
|
||||||
params: { path: { folder_id: id } },
|
params: { path: { folder_id: id } },
|
||||||
}),
|
}),
|
||||||
update: (id: number, updateData: FolderUpdate) =>
|
update: (id: number, updateData: FolderUpdate) =>
|
||||||
|
|
|
||||||
|
|
@ -26,13 +26,13 @@ const createNote = async (note: NoteCreate) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log(encryptedNote);
|
console.log(encryptedNote);
|
||||||
return client.POST(`/api/notes/`, { body: encryptedNote });
|
return client.POST(`/notes/`, { body: encryptedNote });
|
||||||
};
|
};
|
||||||
const fetchNotes = async () => {
|
const fetchNotes = async () => {
|
||||||
const encryptionKey = useAuthStore.getState().encryptionKey;
|
const encryptionKey = useAuthStore.getState().encryptionKey;
|
||||||
if (!encryptionKey) throw new Error("Not authenticated");
|
if (!encryptionKey) throw new Error("Not authenticated");
|
||||||
|
|
||||||
const { data, error } = await client.GET(`/api/notes/`);
|
const { data, error } = await client.GET(`/notes/`);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
throw new Error(error);
|
throw new Error(error);
|
||||||
|
|
@ -74,7 +74,7 @@ const updateNote = async (id: number, note: Partial<NoteRead>) => {
|
||||||
encryptedNote.folderId = note.folderId;
|
encryptedNote.folderId = note.folderId;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data, error } = await client.PATCH(`/api/notes/{note_id}`, {
|
const { data, error } = await client.PATCH(`/notes/{note_id}`, {
|
||||||
body: encryptedNote,
|
body: encryptedNote,
|
||||||
params: {
|
params: {
|
||||||
path: {
|
path: {
|
||||||
|
|
@ -94,7 +94,7 @@ const updateNote = async (id: number, note: Partial<NoteRead>) => {
|
||||||
export const notesApi = {
|
export const notesApi = {
|
||||||
list: () => fetchNotes(),
|
list: () => fetchNotes(),
|
||||||
get: (id: number) =>
|
get: (id: number) =>
|
||||||
client.GET(`/api/notes/{note_id}`, {
|
client.GET(`/notes/{note_id}`, {
|
||||||
params: {
|
params: {
|
||||||
path: {
|
path: {
|
||||||
note_id: id,
|
note_id: id,
|
||||||
|
|
@ -104,7 +104,7 @@ export const notesApi = {
|
||||||
create: (note: NoteCreate) => createNote(note),
|
create: (note: NoteCreate) => createNote(note),
|
||||||
update: (id: number, note: Partial<NoteRead>) => updateNote(id, note),
|
update: (id: number, note: Partial<NoteRead>) => updateNote(id, note),
|
||||||
delete: (id: number) =>
|
delete: (id: number) =>
|
||||||
client.DELETE(`/api/notes/{note_id}`, {
|
client.DELETE(`/notes/{note_id}`, {
|
||||||
params: {
|
params: {
|
||||||
path: {
|
path: {
|
||||||
note_id: id,
|
note_id: id,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue