* Add sorting dropdown to projects list * Fix lint issues * fixup! Fix lint issues * Fix new task space and completed expose * Fix completed switch and filters * Fix an issue with projects not appearing as links * Fix an issue with modal appearing relative to task list * Remove obsolete loads * Fix list issues * Fix mobile/desktop settings dropdown functionality * Update project modal layout * Realign project options * Fix tags dropdown in Project modal * Fix inbox amount sidebar layout * Fix project banner tags listing * Remove icons from titles * Fix lint errors * fixup! Fix lint errors * fixup! fixup! Fix lint errors * Beautify notes and areas * Experiment with new notes layout * fixup! Experiment with new notes layout * fixup! fixup! Experiment with new notes layout * Fix note layout * fixup! Fix note layout * Fix an issue with adding an area and refreshing the area list * Fix an issue with project edit delete menu * fixup! Fix an issue with project edit delete menu * Fix an issue with projects create * Update interaction with Notes * Update interaction with tags * fixup! Update interaction with tags * Fix lint issues * Extract shared filter * Add sorting dropdown translations * fixup! Add sorting dropdown translations * fixup! fixup! Add sorting dropdown translations
58 lines
1.7 KiB
TypeScript
58 lines
1.7 KiB
TypeScript
import { Area } from '../entities/Area';
|
|
import { handleAuthResponse } from './authUtils';
|
|
|
|
export const fetchAreas = async (): Promise<Area[]> => {
|
|
const response = await fetch('/api/areas', {
|
|
credentials: 'include',
|
|
headers: {
|
|
Accept: 'application/json',
|
|
},
|
|
});
|
|
await handleAuthResponse(response, 'Failed to fetch areas.');
|
|
return await response.json();
|
|
};
|
|
|
|
export const createArea = async (areaData: Partial<Area>): Promise<Area> => {
|
|
const response = await fetch('/api/areas', {
|
|
method: 'POST',
|
|
credentials: 'include',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
Accept: 'application/json',
|
|
},
|
|
body: JSON.stringify(areaData),
|
|
});
|
|
|
|
await handleAuthResponse(response, 'Failed to create area.');
|
|
return await response.json();
|
|
};
|
|
|
|
export const updateArea = async (
|
|
areaId: number,
|
|
areaData: Partial<Area>
|
|
): Promise<Area> => {
|
|
const response = await fetch(`/api/areas/${areaId}`, {
|
|
method: 'PATCH',
|
|
credentials: 'include',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
Accept: 'application/json',
|
|
},
|
|
body: JSON.stringify(areaData),
|
|
});
|
|
|
|
await handleAuthResponse(response, 'Failed to update area.');
|
|
return await response.json();
|
|
};
|
|
|
|
export const deleteArea = async (areaId: number): Promise<void> => {
|
|
const response = await fetch(`/api/areas/${areaId}`, {
|
|
method: 'DELETE',
|
|
credentials: 'include',
|
|
headers: {
|
|
Accept: 'application/json',
|
|
},
|
|
});
|
|
|
|
await handleAuthResponse(response, 'Failed to delete area.');
|
|
};
|