Migrace na OpenAPI - TypeScript typy
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Choices, LocationKey } from "../../types";
|
||||
import { LunchChoice, LunchChoices } from "../../types";
|
||||
|
||||
const DAY_OF_WEEK_FORMAT = new Intl.DateTimeFormat(undefined, {weekday: 'long'});
|
||||
const DAY_OF_WEEK_FORMAT = new Intl.DateTimeFormat(undefined, { weekday: 'long' });
|
||||
|
||||
/** Vrátí datum v ISO formátu. */
|
||||
export function formatDate(date: Date, format?: string) {
|
||||
@@ -114,13 +114,13 @@ export const checkBodyParams = (req: any, paramNames: string[]) => {
|
||||
// TODO umístit do samostatného souboru
|
||||
export class InsufficientPermissions extends Error { }
|
||||
|
||||
export const getUsersByLocation = (choices: Choices, login: string): string[] => {
|
||||
export const getUsersByLocation = (choices: LunchChoices, login?: string): string[] => {
|
||||
const result: string[] = [];
|
||||
|
||||
for (const location of Object.entries(choices)) {
|
||||
const locationKey = location[0] as LocationKey;
|
||||
const locationKey = location[0] as keyof typeof LunchChoice;
|
||||
const locationValue = location[1];
|
||||
if (locationValue[login]) {
|
||||
if (login && locationValue[login]) {
|
||||
for (const username in choices[locationKey]) {
|
||||
if (choices[locationKey].hasOwnProperty(username)) {
|
||||
result.push(username);
|
||||
|
||||
Reference in New Issue
Block a user