Move to Zustand and add Filters to web_test (#1077)

* Moved to zustand and started refactored filters

- Move from redux to zustand
- Refactor Filters typings and add some helper types
- Add Filters button and Picker/Switch filter options
- Fixed Syosetu typings

* Add rule consistent-type-definitions

- Add consistent-type-definitions eslint rule to force consistent use of types instead of interfaces
- Run eslint to auto-change every interface to types

https://dev.to/atheodosiou/types-vs-interfaces-in-typescript-making-the-right-choice-48a4
https://www.youtube.com/watch?v=zM9UPcIyyhQ

* Add other filters and refactor

- Move Dialog to FiltersDialog
- CheckboxFilter, TextFilter, XCheckboxFilter added
- Added TripleCheckbox and TripleSwitch as tri-state checkbox/switch items using Mui stylings

* TriStateCheckbox/Switch refactor

- Change name of TripleSwitch and TripleCheckbox to TriState
- Change slightly TriStateSwitch and StyledSwitch styles
- Add option to change into TriStateSwitches via `localStorage` value `useSwitches`

* Refactor code and fix issues

* fix: prettier

---------

Co-authored-by: nyagami <hoangquan05112002@gmail.com>
This commit is contained in:
Marcin Majewski
2024-08-18 17:31:41 +02:00
committed by GitHub
parent eb5522b066
commit b2caf26da3
73 changed files with 1914 additions and 916 deletions
@@ -55,16 +55,16 @@ async function getFilters(sources: HotNovelPubMetadata) {
return filters;
}
interface response {
type response = {
status: number;
message: string;
data?: DataEntity[];
}
interface DataEntity {
};
type DataEntity = {
id: number;
name: string;
slug: string;
}
};
async function start() {
const result = [];
+38 -38
View File
@@ -3,17 +3,17 @@ import { Filters, FilterTypes } from '@libs/filterInputs';
import { Plugin } from '@typings/plugin';
import { NovelStatus } from '@libs/novelStatus';
export interface HotNovelPubMetadata {
export type HotNovelPubMetadata = {
id: string;
sourceSite: string;
sourceName: string;
filters?: Filters;
options?: HotNovelPubOptions;
}
};
interface HotNovelPubOptions {
type HotNovelPubOptions = {
lang?: string;
}
};
class HotNovelPubPlugin implements Plugin.PluginBase {
id: string;
@@ -161,16 +161,16 @@ class HotNovelPubPlugin implements Plugin.PluginBase {
resolveUrl = (path: string) => this.site + '/' + path;
}
interface responseNovels {
type responseNovels = {
status: number;
message: string;
data: Data;
}
interface Data {
};
type Data = {
category?: Category;
books: Books;
}
interface Category {
};
type Category = {
id: number;
name: string;
description: string;
@@ -178,13 +178,13 @@ interface Category {
createdAt: string;
updatedAt: string;
countryId: number;
}
interface Books {
};
type Books = {
total: number;
pages_count: number;
data?: DataEntity[];
}
interface DataEntity {
};
type DataEntity = {
id: number;
name: string;
view: number;
@@ -193,24 +193,24 @@ interface DataEntity {
slug: string;
categories?: CategoriesEntity[] | null;
source?: null;
}
interface CategoriesEntity {
};
type CategoriesEntity = {
id: number;
name: string;
slug?: string;
}
};
interface responseNovel {
type responseNovel = {
status: number;
message: string;
data: Data1;
}
interface Data1 {
};
type Data1 = {
book: Book1;
tags: Tags;
chapters?: ChaptersEntity[];
}
interface Book1 {
};
type Book1 = {
id: number;
name: string;
description: string;
@@ -229,47 +229,47 @@ interface Book1 {
source?: null;
idSource?: null;
prize?: null;
}
interface Authorize {
};
type Authorize = {
id: number;
name: string;
description: string;
avatar: string;
slug: string;
}
interface Tags {
};
type Tags = {
tags_name?: string[] | null;
tags?: CategoriesEntity[] | null;
}
interface ChaptersEntity {
};
type ChaptersEntity = {
id: number;
title: string;
slug: string;
index: number;
}
};
interface ChapterType {
type ChapterType = {
type: string;
data?: string[];
}
};
interface responseSearch {
type responseSearch = {
status: number;
message: string;
data: Data2;
}
interface Data2 {
};
type Data2 = {
books?: BooksEntity[] | null;
authorizes?: AuthorizesEntityOrCategoriesEntity[] | null;
categories?: AuthorizesEntityOrCategoriesEntity[] | null;
}
interface BooksEntity {
};
type BooksEntity = {
id: number;
name: string;
slug: string;
}
interface AuthorizesEntityOrCategoriesEntity {
};
type AuthorizesEntityOrCategoriesEntity = {
id: number;
name: string;
slug: string;
}
};
+2 -2
View File
@@ -5,12 +5,12 @@ import { NovelStatus } from '@libs/novelStatus';
import { load as parseHTML } from 'cheerio';
import dayjs from 'dayjs';
export interface IfreedomMetadata {
export type IfreedomMetadata = {
id: string;
sourceSite: string;
sourceName: string;
filters?: Filters;
}
};
class IfreedomPlugin implements Plugin.PluginBase {
id: string;
+4 -4
View File
@@ -4,18 +4,18 @@ import { Plugin } from '@typings/plugin';
import { Filters, FilterTypes } from '@libs/filterInputs';
import dayjs from 'dayjs';
interface LightNovelWorldOptions {
type LightNovelWorldOptions = {
lang?: string;
versionIncrements?: number;
}
};
export interface LightNovelWorldMetadata {
export type LightNovelWorldMetadata = {
id: string;
sourceSite: string;
sourceName: string;
options?: LightNovelWorldOptions;
filters?: any;
}
};
class LightNovelWorld implements Plugin.PagePlugin {
id: string;
+4 -4
View File
@@ -6,21 +6,21 @@ import { NovelStatus } from '@libs/novelStatus';
import { defaultCover } from '@libs/defaultCover';
import { Filters } from '@libs/filterInputs';
interface LightNovelWPOptions {
type LightNovelWPOptions = {
reverseChapters?: boolean;
lang?: string;
versionIncrements?: number;
seriesPath?: string;
customJs?: string;
}
};
export interface LightNovelWPMetadata {
export type LightNovelWPMetadata = {
id: string;
sourceSite: string;
sourceName: string;
options?: LightNovelWPOptions;
filters?: any;
}
};
class LightNovelWPPlugin implements Plugin.PluginBase {
id: string;
+4 -4
View File
@@ -9,20 +9,20 @@ import dayjs from 'dayjs';
const includesAny = (str: string, keywords: string[]) =>
new RegExp(keywords.join('|')).test(str);
interface MadaraOptions {
type MadaraOptions = {
useNewChapterEndpoint?: boolean;
lang?: string;
orderBy?: string;
versionIncrements?: number;
}
};
export interface MadaraMetadata {
export type MadaraMetadata = {
id: string;
sourceSite: string;
sourceName: string;
options?: MadaraOptions;
filters?: any;
}
};
class MadaraPlugin implements Plugin.PluginBase {
id: string;
+6 -6
View File
@@ -5,17 +5,17 @@ import { NovelStatus } from '@libs/novelStatus';
import { defaultCover } from '@libs/defaultCover';
import { Filters } from '@libs/filterInputs';
interface MTLNovelOptions {
type MTLNovelOptions = {
lang?: string;
}
};
export interface MTLNovelMetadata {
export type MTLNovelMetadata = {
id: string;
sourceSite: string;
sourceName: string;
options?: MTLNovelOptions;
filters?: any;
}
};
class MTLNovelPlugin implements Plugin.PluginBase {
id: string;
@@ -197,11 +197,11 @@ class MTLNovelPlugin implements Plugin.PluginBase {
const result = await res.json();
const novels: Plugin.NovelItem[] = [];
interface SearchEntry {
type SearchEntry = {
title: string;
thumbnail: string;
permalink: string;
}
};
result.items[0].results.map((item: SearchEntry) => {
const novelName = item.title.replace(/<\/?strong>/g, '');
const novelCover = item.thumbnail;
+4 -4
View File
@@ -3,18 +3,18 @@ import { fetchApi } from '@libs/fetch';
import { Plugin } from '@typings/plugin';
import { NovelStatus } from '@libs/novelStatus';
interface ReadNovelFullOptions {
type ReadNovelFullOptions = {
lang?: string;
versionIncrements?: number;
}
};
export interface ReadNovelFullMetadata {
export type ReadNovelFullMetadata = {
id: string;
sourceSite: string;
sourceName: string;
options?: ReadNovelFullOptions;
filters?: any;
}
};
class ReadNovelFullPlugin implements Plugin.PluginBase {
id: string;
+4 -4
View File
@@ -6,17 +6,17 @@ import { load as parseHTML } from 'cheerio';
import dayjs from 'dayjs';
import qs from 'qs';
interface ReadwnOptions {
type ReadwnOptions = {
versionIncrements?: number;
}
};
export interface ReadwnMetadata {
export type ReadwnMetadata = {
id: string;
sourceSite: string;
sourceName: string;
filters?: any;
options?: ReadwnOptions;
}
};
class ReadwnPlugin implements Plugin.PluginBase {
id: string;
+4 -4
View File
@@ -5,12 +5,12 @@ import { NovelStatus } from '@libs/novelStatus';
import { load as parseHTML } from 'cheerio';
import dayjs from 'dayjs';
export interface RulateMetadata {
export type RulateMetadata = {
id: string;
sourceSite: string;
sourceName: string;
filters?: Filters;
}
};
class RulatePlugin implements Plugin.PluginBase {
id: string;
@@ -241,10 +241,10 @@ class RulatePlugin implements Plugin.PluginBase {
};
}
interface response {
type response = {
id: number;
title_one: string;
title_two: string;
url: string;
img: string;
}
};