Files
cloudron-box/dashboard/src/models/NotificationsModel.js
T

37 lines
885 B
JavaScript
Raw Normal View History

2025-03-18 16:53:15 +01:00
2025-07-10 11:55:11 +02:00
import { fetcher } from '@cloudron/pankow';
2025-03-18 16:53:15 +01:00
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, per_page: 100 });
2025-03-18 16:53:15 +01:00
} 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,
};