diff options
Diffstat (limited to 'frontend/src/lib/Enums.ts')
-rw-r--r-- | frontend/src/lib/Enums.ts | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/frontend/src/lib/Enums.ts b/frontend/src/lib/Enums.ts index 876aec8..c557cfa 100644 --- a/frontend/src/lib/Enums.ts +++ b/frontend/src/lib/Enums.ts @@ -10,11 +10,13 @@ import { Language, Layout, NamespaceSort, + Operator, Rating, TagSort, UpdateMode, WorldSort } from '$gql/graphql'; +import type { Key } from './Utils'; export interface EnumOption<T> { id: T; @@ -60,8 +62,8 @@ export const ArchiveSortLabel: Record<ArchiveSort, string> = { [ArchiveSort.Path]: 'Path', [ArchiveSort.Size]: 'File Size', [ArchiveSort.CreatedAt]: 'Created At', - [ArchiveSort.PageCount]: 'Page Count', - [ArchiveSort.Random]: 'Random' + [ArchiveSort.Random]: 'Random', + [ArchiveSort.PageCount]: '# Pages' }; export const ComicSortLabel: Record<ComicSort, string> = { @@ -70,30 +72,37 @@ export const ComicSortLabel: Record<ComicSort, string> = { [ComicSort.Date]: 'Date', [ComicSort.CreatedAt]: 'Created At', [ComicSort.UpdatedAt]: 'Updated At', - [ComicSort.TagCount]: 'Tag Count', - [ComicSort.PageCount]: 'Page Count', - [ComicSort.Random]: 'Random' + [ComicSort.Random]: 'Random', + [ComicSort.ArtistCount]: '# Artists', + [ComicSort.CharacterCount]: '# Characters', + [ComicSort.CircleCount]: '# Circles', + [ComicSort.PageCount]: '# Pages', + [ComicSort.TagCount]: '# Tags', + [ComicSort.WorldCount]: '# Worlds' }; export const ArtistSortLabel: Record<ArtistSort, string> = { [ArtistSort.Name]: 'Name', [ArtistSort.CreatedAt]: 'Created At', [ArtistSort.UpdatedAt]: 'Updated At', - [ArchiveSort.Random]: 'Random' + [ArtistSort.Random]: 'Random', + [ArtistSort.ComicCount]: '# Count' }; export const CharacterSortLabel: Record<CharacterSort, string> = { [CharacterSort.Name]: 'Name', [CharacterSort.CreatedAt]: 'Created At', [CharacterSort.UpdatedAt]: 'Updated At', - [ArchiveSort.Random]: 'Random' + [CharacterSort.Random]: 'Random', + [CharacterSort.ComicCount]: '# Comics' }; export const CircleSortLabel: Record<CircleSort, string> = { [CircleSort.Name]: 'Name', [CircleSort.CreatedAt]: 'Created At', [CircleSort.UpdatedAt]: 'Updated At', - [ArchiveSort.Random]: 'Random' + [CircleSort.Random]: 'Random', + [CircleSort.ComicCount]: '# Comics' }; export const NamespaceSortLabel: Record<NamespaceSort, string> = { @@ -101,21 +110,25 @@ export const NamespaceSortLabel: Record<NamespaceSort, string> = { [NamespaceSort.SortName]: 'Sort Name', [NamespaceSort.CreatedAt]: 'Created At', [NamespaceSort.UpdatedAt]: 'Updated At', - [ArchiveSort.Random]: 'Random' + [NamespaceSort.Random]: 'Random', + [NamespaceSort.TagCount]: '# Tags' }; export const TagSortLabel: Record<TagSort, string> = { [TagSort.Name]: 'Name', [TagSort.CreatedAt]: 'Created At', [TagSort.UpdatedAt]: 'Updated At', - [ArchiveSort.Random]: 'Random' + [TagSort.Random]: 'Random', + [TagSort.ComicCount]: '# Comics', + [TagSort.NamespaceCount]: '# Namespaces' }; export const WorldSortLabel: Record<WorldSort, string> = { [WorldSort.Name]: 'Name', [WorldSort.CreatedAt]: 'Created At', [WorldSort.UpdatedAt]: 'Updated At', - [ArchiveSort.Random]: 'Random' + [WorldSort.Random]: 'Random', + [WorldSort.ComicCount]: '# Comics' }; export const UpdateModeLabel: Record<UpdateMode, string> = { @@ -124,6 +137,12 @@ export const UpdateModeLabel: Record<UpdateMode, string> = { [UpdateMode.Replace]: 'Replace' }; +export const OperatorLabel: Record<Operator, string> = { + [Operator.Equal]: 'Equal', + [Operator.GreaterThan]: 'Greater than', + [Operator.LowerThan]: 'Lower than,' +}; + export const LanguageLabel: Record<Language, string> = { [Language.Ab]: 'Abkhazian', [Language.Aa]: 'Afar', @@ -318,8 +337,6 @@ export const censorships: EnumOption<Censorship>[] = optionsFromLabel(Censorship export const categories: EnumOption<Category>[] = optionsFromLabel(CategoryLabel); export const languages: EnumOption<Language>[] = optionsFromLabel(LanguageLabel); -function optionsFromLabel<T extends string | number | symbol>( - labels: Record<T, string> -): EnumOption<T>[] { +function optionsFromLabel<T extends Key>(labels: Record<T, string>): EnumOption<T>[] { return Object.entries(labels).map(([k, v]) => ({ id: k as T, name: v as string })); } |