Remove unused components and models for improved maintainability
- Deleted redundant components (`AddActionButton`, `AlertBox`, `AlertStack`, `BackButton`, `CancelButton`, and `CollapsableArea`) and related files. - Removed unused models (`Book`, `BookSerie`, `BookTables`, `Character`, and `Chapter`) to reduce codebase clutter. - Updated project structure and references to reflect these removals.
This commit is contained in:
@@ -2,8 +2,7 @@
|
||||
|
||||
import type {Context, Dispatch, JSX, ReactNode, SetStateAction} from 'react';
|
||||
import React, {createContext, useCallback, useState} from 'react';
|
||||
import AlertStack from '@/components/AlertStack';
|
||||
import {cleanErrorMessage} from '@/lib/errors';
|
||||
import AlertStack from '@/components/ui/AlertStack';
|
||||
|
||||
export type AlertType = 'success' | 'error' | 'info' | 'warning';
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import {Context, createContext, Dispatch, SetStateAction} from "react";
|
||||
import {BookProps} from "@/lib/models/Book";
|
||||
import {BookProps} from "@/lib/types/book";
|
||||
|
||||
export interface BookContextProps {
|
||||
book: BookProps | null,
|
||||
setBook?: Dispatch<SetStateAction<BookProps | null>>
|
||||
setBook: Dispatch<SetStateAction<BookProps | null>>
|
||||
}
|
||||
|
||||
export const BookContext: Context<BookContextProps> = createContext<BookContextProps>({
|
||||
book: null,
|
||||
setBook: () => {
|
||||
setBook: (): void => {
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,34 +1,13 @@
|
||||
import {BookSyncCompare, SyncedBook} from "@/lib/models/SyncedBook";
|
||||
import {SyncedBook} from "@/lib/types/synced-book";
|
||||
import {Context, createContext, Dispatch, SetStateAction} from "react";
|
||||
|
||||
export type SyncType = 'server-only' | 'local-only' | 'to-sync-from-server' | 'to-sync-to-server' | 'synced'
|
||||
|
||||
export interface BooksSyncContextProps {
|
||||
serverSyncedBooks:SyncedBook[];
|
||||
localSyncedBooks:SyncedBook[];
|
||||
booksToSyncFromServer:BookSyncCompare[];
|
||||
booksToSyncToServer:BookSyncCompare[];
|
||||
setServerSyncedBooks:Dispatch<SetStateAction<SyncedBook[]>>;
|
||||
setLocalSyncedBooks:Dispatch<SetStateAction<SyncedBook[]>>;
|
||||
setServerOnlyBooks:Dispatch<SetStateAction<SyncedBook[]>>;
|
||||
setLocalOnlyBooks:Dispatch<SetStateAction<SyncedBook[]>>;
|
||||
setBooksToSyncFromServer:Dispatch<SetStateAction<BookSyncCompare[]>>;
|
||||
setBooksToSyncToServer:Dispatch<SetStateAction<BookSyncCompare[]>>;
|
||||
serverOnlyBooks:SyncedBook[];
|
||||
localOnlyBooks:SyncedBook[];
|
||||
setServerSyncedBooks: Dispatch<SetStateAction<SyncedBook[]>>;
|
||||
serverSyncedBooks: SyncedBook[];
|
||||
}
|
||||
|
||||
export const BooksSyncContext:Context<BooksSyncContextProps> = createContext<BooksSyncContextProps>({
|
||||
serverSyncedBooks:[],
|
||||
localSyncedBooks:[],
|
||||
booksToSyncFromServer:[],
|
||||
booksToSyncToServer:[],
|
||||
setServerSyncedBooks:():void => {},
|
||||
setLocalSyncedBooks:():void => {},
|
||||
setServerOnlyBooks:():void => {},
|
||||
setLocalOnlyBooks:():void => {},
|
||||
setBooksToSyncFromServer:():void => {},
|
||||
setBooksToSyncToServer:():void => {},
|
||||
serverOnlyBooks:[],
|
||||
localOnlyBooks:[]
|
||||
export const BooksSyncContext: Context<BooksSyncContextProps> = createContext<BooksSyncContextProps>({
|
||||
serverSyncedBooks: [],
|
||||
setServerSyncedBooks: (): void => {
|
||||
}
|
||||
})
|
||||
@@ -1,5 +1,5 @@
|
||||
import {ChapterProps} from "@/lib/models/Chapter";
|
||||
import {createContext, Dispatch, SetStateAction} from "react";
|
||||
import {ChapterProps} from "@/lib/types/chapter";
|
||||
import {Context, createContext, Dispatch, SetStateAction} from "react";
|
||||
|
||||
|
||||
export interface ChapterContextProps {
|
||||
@@ -7,8 +7,8 @@ export interface ChapterContextProps {
|
||||
setChapter: Dispatch<SetStateAction<ChapterProps | undefined>>
|
||||
}
|
||||
|
||||
export const ChapterContext = createContext<ChapterContextProps>({
|
||||
export const ChapterContext: Context<ChapterContextProps> = createContext<ChapterContextProps>({
|
||||
chapter: undefined,
|
||||
setChapter: () => {
|
||||
setChapter: (_value: SetStateAction<ChapterProps | undefined>): void => {
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import {createContext} from "react";
|
||||
import {Context, createContext} from "react";
|
||||
import {Editor} from "@tiptap/core";
|
||||
|
||||
export interface EditorContextProps {
|
||||
editor: Editor | null
|
||||
}
|
||||
|
||||
export const EditorContext = createContext<EditorContextProps>({
|
||||
export const EditorContext: Context<EditorContextProps> = createContext<EditorContextProps>({
|
||||
editor: null
|
||||
});
|
||||
|
||||
@@ -2,6 +2,10 @@ import {Context, createContext, Dispatch, SetStateAction} from "react";
|
||||
|
||||
export type SupportedLocale = 'fr' | 'en';
|
||||
|
||||
export function isSupportedLocale(value: string | null): value is SupportedLocale {
|
||||
return value === 'fr' || value === 'en';
|
||||
}
|
||||
|
||||
export interface LangContextProps {
|
||||
lang: SupportedLocale;
|
||||
setLang: Dispatch<SetStateAction<SupportedLocale>>;
|
||||
|
||||
@@ -1,35 +1,11 @@
|
||||
import { createContext, Dispatch, SetStateAction } from 'react';
|
||||
|
||||
export interface OfflineMode {
|
||||
isManuallyOffline: boolean;
|
||||
isNetworkOnline: boolean;
|
||||
isOffline: boolean;
|
||||
isDatabaseInitialized: boolean;
|
||||
error: string | null;
|
||||
}
|
||||
|
||||
export interface OfflineContextType {
|
||||
offlineMode: OfflineMode;
|
||||
setOfflineMode: Dispatch<SetStateAction<OfflineMode>>;
|
||||
toggleOfflineMode: () => void;
|
||||
initializeDatabase: (userId: string, encryptionKey?: string) => Promise<boolean>;
|
||||
isCurrentlyOffline: () => boolean;
|
||||
}
|
||||
|
||||
export const defaultOfflineMode: OfflineMode = {
|
||||
isManuallyOffline: false,
|
||||
isNetworkOnline: typeof navigator !== 'undefined' ? navigator.onLine : true,
|
||||
isOffline: false,
|
||||
isDatabaseInitialized: false,
|
||||
error: null
|
||||
};
|
||||
|
||||
const OfflineContext = createContext<OfflineContextType>({
|
||||
offlineMode: defaultOfflineMode,
|
||||
setOfflineMode: () => {},
|
||||
toggleOfflineMode: () => {},
|
||||
initializeDatabase: async () => false,
|
||||
isCurrentlyOffline: () => false
|
||||
});
|
||||
|
||||
export default OfflineContext;
|
||||
import {createContext} from 'react';
|
||||
|
||||
export interface OfflineContextType {
|
||||
isCurrentlyOffline: () => boolean;
|
||||
}
|
||||
|
||||
const OfflineContext = createContext<OfflineContextType>({
|
||||
isCurrentlyOffline: () => false,
|
||||
});
|
||||
|
||||
export default OfflineContext;
|
||||
|
||||
@@ -2,10 +2,8 @@ import {Context, createContext} from "react";
|
||||
|
||||
export interface SeriesContextProps {
|
||||
seriesId: string;
|
||||
localSeries: boolean;
|
||||
}
|
||||
|
||||
export const SeriesContext: Context<SeriesContextProps> = createContext<SeriesContextProps>({
|
||||
seriesId: '',
|
||||
localSeries: false
|
||||
seriesId: ''
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { SeriesSyncCompare, SyncedSeries } from "@/lib/models/SyncedSeries";
|
||||
import { SeriesSyncCompare, SyncedSeries } from "@/lib/types/synced-series";
|
||||
import { Context, createContext, Dispatch, SetStateAction } from "react";
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {SessionProps} from "@/lib/models/Session";
|
||||
import {SessionProps} from "@/lib/types/session";
|
||||
import {Context, createContext, Dispatch, SetStateAction} from "react";
|
||||
|
||||
export interface SessionContextProps {
|
||||
@@ -12,6 +12,6 @@ export const SessionContext: Context<SessionContextProps> = createContext<Sessio
|
||||
accessToken: "",
|
||||
user: null,
|
||||
},
|
||||
setSession: () => {
|
||||
setSession: (): void => {
|
||||
},
|
||||
})
|
||||
|
||||
10
context/WorldContext.ts
Executable file → Normal file
10
context/WorldContext.ts
Executable file → Normal file
@@ -1,4 +1,4 @@
|
||||
import {WorldProps} from "@/lib/models/World";
|
||||
import {WorldProps} from "@/lib/types/world";
|
||||
import {createContext, Dispatch, SetStateAction} from "react";
|
||||
|
||||
export interface WorldContextProps {
|
||||
@@ -8,4 +8,10 @@ export interface WorldContextProps {
|
||||
isSeriesMode?: boolean;
|
||||
}
|
||||
|
||||
export const WorldContext = createContext<WorldContextProps>({} as WorldContextProps);
|
||||
export const WorldContext = createContext<WorldContextProps>({
|
||||
worlds: [],
|
||||
setWorlds: (): void => {
|
||||
},
|
||||
selectedWorldIndex: 0,
|
||||
isSeriesMode: false,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user