Fix an issue with notes not adding tags on creation
This commit is contained in:
parent
cbc53822f4
commit
05cfbddec8
3 changed files with 30 additions and 22 deletions
|
|
@ -8,13 +8,17 @@ const useManageNotes = () => {
|
|||
|
||||
const createNote = useCallback(
|
||||
async (noteData: Partial<Note>) => {
|
||||
const noteDataToSend = {
|
||||
...noteData,
|
||||
tags: noteData.tags?.map((tag) => (typeof tag === 'string' ? tag : tag.name)),
|
||||
};
|
||||
const response = await fetch('/api/note', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(noteData),
|
||||
body: JSON.stringify(noteDataToSend),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
|
|
@ -31,13 +35,17 @@ const useManageNotes = () => {
|
|||
|
||||
const updateNote = useCallback(
|
||||
async (noteId: number, noteData: Partial<Note>) => {
|
||||
const noteDataToSend = {
|
||||
...noteData,
|
||||
tags: noteData.tags?.map((tag) => (typeof tag === 'string' ? tag : tag.name)),
|
||||
};
|
||||
const response = await fetch(`/api/note/${noteId}`, {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(noteData),
|
||||
body: JSON.stringify(noteDataToSend),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ const useManageProjects = () => {
|
|||
|
||||
const createProject = async (projectData: Partial<Project>): Promise<Project> => {
|
||||
try {
|
||||
const response = await fetch('/api/projects', {
|
||||
const response = await fetch('/api/project', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
credentials: 'include',
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue