import express from 'express';
import { adminNoteSystem } from '../../../../features/admin/notes';

export async function AdminNoteChanged(req: express.Request, res: express.Response): Promise<express.Response<any, Record<string, any>>> {
    if (!req.params.accountId) {
        res.status(400).send('Missing parameter');
    }

    if (!Number(req.params.accountId)) {
        res.status(500).send('Unable to parse given parameter');
    }

    const accountId = Number(req.params.accountId);
    for (const player of mp.players.toArray()) {
        if (player.account?.id === accountId) {
            await adminNoteSystem.loadAdminNotes(player as PlayerMpLoggedIn, true);
        }
    }
    return res.sendStatus(200);
}
