Public Access
feat(dashboard): show admin hints and add the hints admin page
This commit is contained in:
1 parent
6601277961
commit
01ae372b2d
12 files changed
+700
-6
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import {apiFetch} from './api.js';
|
||||
|
||||
const AUTH = () => import.meta.env.VITE_API_URL;
|
||||
|
||||
/**
|
||||
* GET /api/hints: {results: [{id, textEn, textDe, kind, startsAt, endsAt}]}, the running hints the user has not
|
||||
* closed for good, newest first.
|
||||
*/
|
||||
export const fetchHints = () => apiFetch(`${AUTH()}/api/hints`);
|
||||
|
||||
/**
|
||||
* The hint never comes back for this user.
|
||||
*/
|
||||
export const markHintDone = (hintId) => apiFetch(`${AUTH()}/api/hints/${hintId}/done`, {method: 'PUT'});
|
||||
|
||||
/**
|
||||
* PLATFORM_ADMIN only (403 otherwise): {results: [...]}, every hint with doneCount, newest first.
|
||||
*/
|
||||
export const fetchAdminHints = () => apiFetch(`${AUTH()}/api/admin/hints`);
|
||||
|
||||
/**
|
||||
* 201 {id}, or 400 (code INVALID_HINT when the end is not after the start or not in the future).
|
||||
*/
|
||||
export const createHint = (hint) =>
|
||||
apiFetch(`${AUTH()}/api/admin/hints`, {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify(hint),
|
||||
});
|
||||
|
||||
export const endHint = (hintId) => apiFetch(`${AUTH()}/api/admin/hints/${hintId}/end`, {method: 'PUT'});
|
||||
|
||||
export const hintText = (hint, language) => (language?.startsWith('de') && hint.textDe ? hint.textDe : hint.textEn);
|
||||
Reference in new issue
Block a user