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:
@@ -1,10 +1,10 @@
|
||||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
|
||||
import {faCloud, faCloudArrowDown, faCloudArrowUp, faSpinner} from "@fortawesome/free-solid-svg-icons";
|
||||
import {useTranslations} from "next-intl";
|
||||
import {Cloud, CloudDownload, CloudUpload, Loader2} from "lucide-react";
|
||||
import {useTranslations} from "@/lib/i18n";
|
||||
import {useState, useEffect, useContext} from "react";
|
||||
import OfflineContext, {OfflineContextType} from "@/context/OfflineContext";
|
||||
import {SyncType} from "@/context/BooksSyncContext";
|
||||
import useSyncBooks from "@/hooks/useSyncBooks";
|
||||
import IconButton from "@/components/ui/IconButton";
|
||||
|
||||
interface SyncBookProps {
|
||||
bookId: string;
|
||||
@@ -27,7 +27,7 @@ export default function SyncBook({bookId, status}: SyncBookProps) {
|
||||
async function upload(): Promise<void> {
|
||||
if (isOffline) return;
|
||||
setIsLoading(true);
|
||||
const success:boolean = await hookUpload(bookId);
|
||||
const success: boolean = await hookUpload(bookId);
|
||||
if (success) setCurrentStatus('synced');
|
||||
setIsLoading(false);
|
||||
}
|
||||
@@ -59,9 +59,7 @@ export default function SyncBook({bookId, status}: SyncBookProps) {
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-primary">
|
||||
<FontAwesomeIcon icon={faSpinner} className="w-4 h-4 animate-spin"/>
|
||||
</span>
|
||||
<Loader2 className="w-4 h-4 text-primary animate-spin"/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -69,57 +67,48 @@ export default function SyncBook({bookId, status}: SyncBookProps) {
|
||||
return (
|
||||
<div className="flex items-center gap-2">
|
||||
{currentStatus === 'synced' && (
|
||||
<span
|
||||
className="text-gray-light"
|
||||
title={t("bookCard.synced")}
|
||||
>
|
||||
<FontAwesomeIcon icon={faCloud} className="w-4 h-4"/>
|
||||
</span>
|
||||
<Cloud className="w-4 h-4 text-gray-light" title={t("bookCard.synced")}/>
|
||||
)}
|
||||
|
||||
|
||||
{currentStatus === 'local-only' && (
|
||||
<button
|
||||
<IconButton
|
||||
icon={CloudUpload}
|
||||
variant={isOffline ? 'muted' : 'primary'}
|
||||
size="sm"
|
||||
onClick={upload}
|
||||
className={`transition-colors ${isOffline ? 'text-gray-dark cursor-not-allowed' : 'text-gray hover:text-primary cursor-pointer'}`}
|
||||
title={t("bookCard.localOnly")}
|
||||
type="button"
|
||||
disabled={isOffline}
|
||||
>
|
||||
<FontAwesomeIcon icon={faCloudArrowUp} className="w-4 h-4"/>
|
||||
</button>
|
||||
tooltip={t("bookCard.localOnly")}
|
||||
/>
|
||||
)}
|
||||
{currentStatus === 'server-only' && (
|
||||
<button
|
||||
<IconButton
|
||||
icon={CloudDownload}
|
||||
variant={isOffline ? 'muted' : 'primary'}
|
||||
size="sm"
|
||||
onClick={download}
|
||||
className={`transition-colors ${isOffline ? 'text-gray-dark cursor-not-allowed' : 'text-gray hover:text-primary cursor-pointer'}`}
|
||||
title={t("bookCard.serverOnly")}
|
||||
type="button"
|
||||
disabled={isOffline}
|
||||
>
|
||||
<FontAwesomeIcon icon={faCloudArrowDown} className="w-4 h-4"/>
|
||||
</button>
|
||||
tooltip={t("bookCard.serverOnly")}
|
||||
/>
|
||||
)}
|
||||
{currentStatus === 'to-sync-from-server' && (
|
||||
<button
|
||||
<IconButton
|
||||
icon={CloudDownload}
|
||||
variant={isOffline ? 'muted' : 'primary'}
|
||||
size="sm"
|
||||
onClick={syncFromServer}
|
||||
className={`transition-colors ${isOffline ? 'text-gray-dark cursor-not-allowed' : 'text-warning hover:text-primary cursor-pointer'}`}
|
||||
title={t("bookCard.toSyncFromServer")}
|
||||
type="button"
|
||||
disabled={isOffline}
|
||||
>
|
||||
<FontAwesomeIcon icon={faCloudArrowDown} className="w-4 h-4"/>
|
||||
</button>
|
||||
tooltip={t("bookCard.toSyncFromServer")}
|
||||
/>
|
||||
)}
|
||||
{currentStatus === 'to-sync-to-server' && (
|
||||
<button
|
||||
<IconButton
|
||||
icon={CloudUpload}
|
||||
variant={isOffline ? 'muted' : 'primary'}
|
||||
size="sm"
|
||||
onClick={syncToServer}
|
||||
className={`transition-colors ${isOffline ? 'text-gray-dark cursor-not-allowed' : 'text-warning hover:text-primary cursor-pointer'}`}
|
||||
title={t("bookCard.toSyncToServer")}
|
||||
type="button"
|
||||
disabled={isOffline}
|
||||
>
|
||||
<FontAwesomeIcon icon={faCloudArrowUp} className="w-4 h-4"/>
|
||||
</button>
|
||||
tooltip={t("bookCard.toSyncToServer")}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user