Migrace z pořadových indexů na unikátní klíče
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user