mirror of
https://github.com/pterodactyl/panel.git
synced 2026-11-30 11:25:52 -05:00
Co-authored-by: Anthony <anthony@infraly.co> Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
25 lines
797 B
TypeScript
25 lines
797 B
TypeScript
import type { AdminListActivityFilterOptionsResponseBody } from '@/api/generated';
|
|
import { isNumber, isString } from '@/lib/objects';
|
|
|
|
export interface ActivityFacetUser {
|
|
id: number;
|
|
username: string;
|
|
email: string;
|
|
}
|
|
|
|
export interface ActivityFacets {
|
|
events: string[];
|
|
users: ActivityFacetUser[];
|
|
}
|
|
|
|
export const toActivityFacets = (body: AdminListActivityFilterOptionsResponseBody | undefined): ActivityFacets => ({
|
|
events: (body?.data?.events ?? []).filter(isString),
|
|
users: (body?.data?.users ?? []).flatMap((user) =>
|
|
isNumber(user.id) && isString(user.username)
|
|
? [{ id: user.id, username: user.username, email: user.email ?? '' }]
|
|
: []
|
|
),
|
|
});
|
|
|
|
export const emptyActivityFacets: ActivityFacets = toActivityFacets(undefined);
|