Activities and categories, WIP
This commit is contained in:
parent
03666ff605
commit
435149d718
|
@ -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
|
||||||
|
) => {};
|
|
@ -1,5 +1,5 @@
|
||||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||||
import { getTagStatus } from './tagsStatus';
|
import { getTagStatus } from './tags-status';
|
||||||
|
|
||||||
describe('The getTagStatus function', () => {
|
describe('The getTagStatus function', () => {
|
||||||
it('should return undefined/false for a tag that does NOT exist', () => {
|
it('should return undefined/false for a tag that does NOT exist', () => {
|
|
@ -1,22 +1,8 @@
|
||||||
interface TagFormatDefinition {}
|
import {
|
||||||
|
TagDefinitions,
|
||||||
interface TagCategoryDefinitions {
|
TagFormatDefinition,
|
||||||
[key: string]: TagFormatDefinition;
|
TagType,
|
||||||
}
|
} from './activities-and-categories';
|
||||||
|
|
||||||
enum TagType {
|
|
||||||
ROUTE = 'route',
|
|
||||||
POI = 'poi',
|
|
||||||
}
|
|
||||||
|
|
||||||
interface TagActivityDefinitions {
|
|
||||||
route?: { [key: string]: TagCategoryDefinitions };
|
|
||||||
poi?: { [key: string]: TagCategoryDefinitions };
|
|
||||||
}
|
|
||||||
|
|
||||||
interface TagDefinitions {
|
|
||||||
[key: string]: TagActivityDefinitions;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface TagStatus {
|
interface TagStatus {
|
||||||
type?: TagType;
|
type?: TagType;
|
||||||
|
@ -29,8 +15,8 @@ export const getTagStatus = (
|
||||||
definitions: TagDefinitions,
|
definitions: TagDefinitions,
|
||||||
selectedKey: string,
|
selectedKey: string,
|
||||||
highlightedKey: string
|
highlightedKey: string
|
||||||
) => {
|
): TagStatus => {
|
||||||
const defaultStatus: TagStatus = {
|
const defaultStatus = {
|
||||||
highlighted: false,
|
highlighted: false,
|
||||||
};
|
};
|
||||||
const activityDefinitions = definitions[selectedKey];
|
const activityDefinitions = definitions[selectedKey];
|
||||||
|
@ -47,7 +33,7 @@ export const getTagStatus = (
|
||||||
if (!!highlightedDefinitions) {
|
if (!!highlightedDefinitions) {
|
||||||
const definition = highlightedDefinitions[tag];
|
const definition = highlightedDefinitions[tag];
|
||||||
if (!!definition) {
|
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 categoryDefinitions = typeDefinitions[category];
|
||||||
const definition = categoryDefinitions[tag];
|
const definition = categoryDefinitions[tag];
|
||||||
if (!!definition) {
|
if (!!definition) {
|
||||||
return { type, definition, highlighted: false } as TagStatus;
|
return { type, definition, highlighted: false };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue