Lint frontend (#131)
* Add lint-fix npm target * Sync eslint+plugins with backend * Add prettier * Ignore no-explicit-any lint rule for now * Silence eslint react warning * Format frontend via prettier * Lint frontend. --------- Co-authored-by: antanst <>
This commit is contained in:
parent
f433dbffe3
commit
220bc92b4a
114 changed files with 30271 additions and 48239 deletions
|
|
@ -1,50 +1,53 @@
|
|||
import { Note } from "../entities/Note";
|
||||
import { handleAuthResponse, getDefaultHeaders, getPostHeaders } from "./authUtils";
|
||||
import { Note } from '../entities/Note';
|
||||
import {
|
||||
handleAuthResponse,
|
||||
getDefaultHeaders,
|
||||
getPostHeaders,
|
||||
} from './authUtils';
|
||||
|
||||
export const fetchNotes = async (): Promise<Note[]> => {
|
||||
const response = await fetch("/api/notes", {
|
||||
credentials: 'include',
|
||||
headers: getDefaultHeaders(),
|
||||
});
|
||||
await handleAuthResponse(response, 'Failed to fetch notes.');
|
||||
const response = await fetch('/api/notes', {
|
||||
credentials: 'include',
|
||||
headers: getDefaultHeaders(),
|
||||
});
|
||||
await handleAuthResponse(response, 'Failed to fetch notes.');
|
||||
|
||||
return await response.json();
|
||||
return await response.json();
|
||||
};
|
||||
|
||||
export const createNote = async (noteData: Note): Promise<Note> => {
|
||||
try {
|
||||
const response = await fetch('/api/note', {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
headers: getPostHeaders(),
|
||||
body: JSON.stringify(noteData),
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
headers: getPostHeaders(),
|
||||
body: JSON.stringify(noteData),
|
||||
});
|
||||
|
||||
await handleAuthResponse(response, 'Failed to create note.');
|
||||
return await response.json();
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const updateNote = async (noteId: number, noteData: Note): Promise<Note> => {
|
||||
const response = await fetch(`/api/note/${noteId}`, {
|
||||
method: 'PATCH',
|
||||
credentials: 'include',
|
||||
headers: getPostHeaders(),
|
||||
body: JSON.stringify(noteData),
|
||||
});
|
||||
export const updateNote = async (
|
||||
noteId: number,
|
||||
noteData: Note
|
||||
): Promise<Note> => {
|
||||
const response = await fetch(`/api/note/${noteId}`, {
|
||||
method: 'PATCH',
|
||||
credentials: 'include',
|
||||
headers: getPostHeaders(),
|
||||
body: JSON.stringify(noteData),
|
||||
});
|
||||
|
||||
await handleAuthResponse(response, 'Failed to update note.');
|
||||
return await response.json();
|
||||
await handleAuthResponse(response, 'Failed to update note.');
|
||||
return await response.json();
|
||||
};
|
||||
|
||||
export const deleteNote = async (noteId: number): Promise<void> => {
|
||||
const response = await fetch(`/api/note/${noteId}`, {
|
||||
method: 'DELETE',
|
||||
credentials: 'include',
|
||||
headers: getDefaultHeaders(),
|
||||
});
|
||||
const response = await fetch(`/api/note/${noteId}`, {
|
||||
method: 'DELETE',
|
||||
credentials: 'include',
|
||||
headers: getDefaultHeaders(),
|
||||
});
|
||||
|
||||
await handleAuthResponse(response, 'Failed to delete note.');
|
||||
};
|
||||
await handleAuthResponse(response, 'Failed to delete note.');
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue