- Implemented API functions for creating, updating, and deleting draws. - Enhanced the admin draws console with UI components for managing draws. - Added internationalization support for new draw management actions and messages.
26 lines
735 B
TypeScript
26 lines
735 B
TypeScript
import type { AdminDrawListItem } from "@/types/api/admin-draws";
|
|
|
|
const CANCELLABLE_STATUSES = new Set(["pending", "open", "closing", "closed"]);
|
|
|
|
export function drawHasNoBets(row: AdminDrawListItem): boolean {
|
|
return (row.total_bet_minor ?? 0) === 0;
|
|
}
|
|
|
|
export function canEditDrawRow(row: AdminDrawListItem): boolean {
|
|
if (!drawHasNoBets(row)) {
|
|
return false;
|
|
}
|
|
return row.status === "pending" || row.status === "open";
|
|
}
|
|
|
|
export function canDeleteDrawRow(row: AdminDrawListItem): boolean {
|
|
return row.status === "pending" && drawHasNoBets(row);
|
|
}
|
|
|
|
export function canCancelDrawRow(row: AdminDrawListItem): boolean {
|
|
if (!drawHasNoBets(row)) {
|
|
return false;
|
|
}
|
|
return CANCELLABLE_STATUSES.has(row.status);
|
|
}
|