Activities and categories, WIP

This commit is contained in:
Eric van der Vlist 2023-07-08 10:52:02 +02:00
parent 03666ff605
commit 435149d718
3 changed files with 40 additions and 24 deletions

View File

@ -0,0 +1,30 @@
export interface TagFormatDefinition {}
interface TagCategoryDefinitions {
[key: string]: TagFormatDefinition;
}
export enum TagType {
ROUTE = 'route',
POI = 'poi',
}
interface TagActivityDefinitions {
route?: { [key: string]: TagCategoryDefinitions };
poi?: { [key: string]: TagCategoryDefinitions };
}
export interface TagDefinitions {
[key: string]: TagActivityDefinitions;
}
interface TagActivitiesAndCategories {
[activity: string]: {
route?: { [key: string]: string[] };
poi?: { [key: string]: string[] };
};
}
export const getTagActivitiesAndCategories = (
definitions: TagDefinitions
) => {};

View File

@ -1,5 +1,5 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { getTagStatus } from './tagsStatus';
import { getTagStatus } from './tags-status';
describe('The getTagStatus function', () => {
it('should return undefined/false for a tag that does NOT exist', () => {

View File

@ -1,22 +1,8 @@
interface TagFormatDefinition {}
interface TagCategoryDefinitions {
[key: string]: TagFormatDefinition;
}
enum TagType {
ROUTE = 'route',
POI = 'poi',
}
interface TagActivityDefinitions {
route?: { [key: string]: TagCategoryDefinitions };
poi?: { [key: string]: TagCategoryDefinitions };
}
interface TagDefinitions {
[key: string]: TagActivityDefinitions;
}
import {
TagDefinitions,
TagFormatDefinition,
TagType,
} from './activities-and-categories';
interface TagStatus {
type?: TagType;
@ -29,8 +15,8 @@ export const getTagStatus = (
definitions: TagDefinitions,
selectedKey: string,
highlightedKey: string
) => {
const defaultStatus: TagStatus = {
): TagStatus => {
const defaultStatus = {
highlighted: false,
};
const activityDefinitions = definitions[selectedKey];
@ -47,7 +33,7 @@ export const getTagStatus = (
if (!!highlightedDefinitions) {
const definition = highlightedDefinitions[tag];
if (!!definition) {
return { type, definition, highlighted: true } as TagStatus;
return { type, definition, highlighted: true };
}
}
@ -56,7 +42,7 @@ export const getTagStatus = (
const categoryDefinitions = typeDefinitions[category];
const definition = categoryDefinitions[tag];
if (!!definition) {
return { type, definition, highlighted: false } as TagStatus;
return { type, definition, highlighted: false };
}
}
}