Add notification panel

This commit is contained in:
Johannes Zellner
2025-03-18 16:53:15 +01:00
parent e665857aa8
commit 0fe5d9d628
4 changed files with 156 additions and 37 deletions

View File

@@ -0,0 +1,36 @@
import { fetcher } from 'pankow';
import { API_ORIGIN } from '../constants.js';
function create() {
const accessToken = localStorage.token;
return {
async list(acknowledged = false) {
let result;
try {
result = await fetcher.get(`${API_ORIGIN}/api/v1/notifications`, { acknowledged, access_token: accessToken });
} catch (e) {
return [e];
}
if (result.status !== 200) return [result];
return [null, result.body.notifications];
},
async update(id, acknowledged) {
let result;
try {
result = await fetcher.post(`${API_ORIGIN}/api/v1/notifications/${id}`, { acknowledged }, { access_token: accessToken });
} catch (e) {
return [e];
}
if (result.status !== 204) return [result];
return [null];
},
};
}
export default {
create,
};