feat: add notes feature and keyboard shortcuts
- Introduced a new Note model in the Prisma schema to support note-taking functionality. - Updated the HeaderNavigation component to include a link to the new Notes page. - Implemented keyboard shortcuts for note actions, enhancing user experience and productivity. - Added dependencies for markdown rendering and formatting tools to support note content.
This commit is contained in:
95
src/clients/notes.ts
Normal file
95
src/clients/notes.ts
Normal file
@@ -0,0 +1,95 @@
|
||||
import { HttpClient } from '@/clients/base/http-client';
|
||||
import { Note } from '@/services/notes';
|
||||
|
||||
export interface CreateNoteData {
|
||||
title: string;
|
||||
content: string;
|
||||
tags?: string[];
|
||||
}
|
||||
|
||||
export interface UpdateNoteData {
|
||||
title?: string;
|
||||
content?: string;
|
||||
tags?: string[];
|
||||
}
|
||||
|
||||
export interface NotesResponse {
|
||||
notes: Note[];
|
||||
}
|
||||
|
||||
export interface NoteResponse {
|
||||
note: Note;
|
||||
}
|
||||
|
||||
export interface NotesStatsResponse {
|
||||
totalNotes: number;
|
||||
totalWords: number;
|
||||
lastUpdated: Date | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Client HTTP pour les notes
|
||||
*/
|
||||
export class NotesClient extends HttpClient {
|
||||
constructor() {
|
||||
super('/api/notes');
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère toutes les notes de l'utilisateur
|
||||
*/
|
||||
async getNotes(search?: string): Promise<Note[]> {
|
||||
const params = search ? { search } : undefined;
|
||||
const response = await this.get<NotesResponse>('', params);
|
||||
return response.notes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère une note par son ID
|
||||
*/
|
||||
async getNoteById(id: string): Promise<Note> {
|
||||
const response = await this.get<NoteResponse>(`/${id}`);
|
||||
return response.note;
|
||||
}
|
||||
|
||||
/**
|
||||
* Crée une nouvelle note
|
||||
*/
|
||||
async createNote(data: CreateNoteData): Promise<Note> {
|
||||
const response = await this.post<NoteResponse>('', data);
|
||||
return response.note;
|
||||
}
|
||||
|
||||
/**
|
||||
* Met à jour une note existante
|
||||
*/
|
||||
async updateNote(id: string, data: UpdateNoteData): Promise<Note> {
|
||||
const response = await this.put<NoteResponse>(`/${id}`, data);
|
||||
return response.note;
|
||||
}
|
||||
|
||||
/**
|
||||
* Supprime une note
|
||||
*/
|
||||
async deleteNote(id: string): Promise<void> {
|
||||
await this.delete(`/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recherche des notes
|
||||
*/
|
||||
async searchNotes(query: string): Promise<Note[]> {
|
||||
const response = await this.get<NotesResponse>('', { search: query });
|
||||
return response.notes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère les statistiques des notes
|
||||
*/
|
||||
async getNotesStats(): Promise<NotesStatsResponse> {
|
||||
return await this.get<NotesStatsResponse>('/stats');
|
||||
}
|
||||
}
|
||||
|
||||
// Instance singleton
|
||||
export const notesClient = new NotesClient();
|
||||
Reference in New Issue
Block a user