Migrace z pořadových indexů na unikátní klíče

This commit is contained in:
2025-01-09 22:05:20 +01:00
parent 774cb4f9d2
commit 02de6691a8
7 changed files with 104 additions and 100 deletions

View File

@@ -1,4 +1,4 @@
import { Choices } from "../../types";
import { Choices, LocationKey } from "../../types";
/** Vrátí datum v ISO formátu. */
export function formatDate(date: Date) {
@@ -110,19 +110,19 @@ export const checkBodyParams = (req: any, paramNames: string[]) => {
// TODO umístit do samostatného souboru
export class InsufficientPermissions extends Error { }
export const getUsersByLocation = (data: Choices, login: string): string[] => {
export const getUsersByLocation = (choices: Choices, login: string): string[] => {
const result: string[] = [];
for (const location in data) {
if (data.hasOwnProperty(location)) {
if (data[location][login]) {
for (const username in data[location]) {
if (data[location].hasOwnProperty(username)) {
result.push(username);
}
for (const location of Object.entries(choices)) {
const locationKey = location[0] as LocationKey;
const locationValue = location[1];
if (locationValue[login]) {
for (const username in choices[locationKey]) {
if (choices[locationKey].hasOwnProperty(username)) {
result.push(username);
}
break;
}
break;
}
}