mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-08-26 14:19:24 +00:00
Fix ViewType usage
This commit is contained in:
parent
acbebd67a3
commit
3c131bc332
@ -142,7 +142,7 @@ export default function Workbench() {
|
|||||||
{/* Top Controls */}
|
{/* Top Controls */}
|
||||||
<TopControls
|
<TopControls
|
||||||
currentView={currentView}
|
currentView={currentView}
|
||||||
setCurrentView={setCurrentView as any /* FIX ME */}
|
setCurrentView={setCurrentView}
|
||||||
selectedToolKey={selectedToolKey}
|
selectedToolKey={selectedToolKey}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import VisibilityIcon from "@mui/icons-material/Visibility";
|
|||||||
import EditNoteIcon from "@mui/icons-material/EditNote";
|
import EditNoteIcon from "@mui/icons-material/EditNote";
|
||||||
import FolderIcon from "@mui/icons-material/Folder";
|
import FolderIcon from "@mui/icons-material/Folder";
|
||||||
import { Group } from "@mantine/core";
|
import { Group } from "@mantine/core";
|
||||||
|
import { isViewType, ViewType } from "../../types/fileContext";
|
||||||
|
|
||||||
// This will be created inside the component to access switchingTo
|
// This will be created inside the component to access switchingTo
|
||||||
const createViewOptions = (switchingTo: string | null) => [
|
const createViewOptions = (switchingTo: string | null) => [
|
||||||
@ -52,8 +53,8 @@ const createViewOptions = (switchingTo: string | null) => [
|
|||||||
];
|
];
|
||||||
|
|
||||||
interface TopControlsProps {
|
interface TopControlsProps {
|
||||||
currentView: string;
|
currentView: ViewType;
|
||||||
setCurrentView: (view: string) => void;
|
setCurrentView: (view: ViewType) => void;
|
||||||
selectedToolKey?: string | null;
|
selectedToolKey?: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +68,7 @@ const TopControls = ({
|
|||||||
|
|
||||||
const isToolSelected = selectedToolKey !== null;
|
const isToolSelected = selectedToolKey !== null;
|
||||||
|
|
||||||
const handleViewChange = useCallback((view: string) => {
|
const handleViewChange = useCallback((view: ViewType) => {
|
||||||
// Show immediate feedback
|
// Show immediate feedback
|
||||||
setSwitchingTo(view);
|
setSwitchingTo(view);
|
||||||
|
|
||||||
@ -119,7 +120,7 @@ const TopControls = ({
|
|||||||
<SegmentedControl
|
<SegmentedControl
|
||||||
data={createViewOptions(switchingTo)}
|
data={createViewOptions(switchingTo)}
|
||||||
value={currentView}
|
value={currentView}
|
||||||
onChange={handleViewChange}
|
onChange={(value) => isViewType(value) && handleViewChange}
|
||||||
color="blue"
|
color="blue"
|
||||||
radius="xl"
|
radius="xl"
|
||||||
size="md"
|
size="md"
|
||||||
|
@ -19,7 +19,17 @@ export type ModeType =
|
|||||||
| 'changePermissions'
|
| 'changePermissions'
|
||||||
| 'removePassword';
|
| 'removePassword';
|
||||||
|
|
||||||
export type ViewType = 'viewer' | 'pageEditor' | 'fileEditor';
|
const VIEW_TYPES = [
|
||||||
|
'viewer',
|
||||||
|
'pageEditor',
|
||||||
|
'fileEditor',
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
export type ViewType = typeof VIEW_TYPES[number];
|
||||||
|
|
||||||
|
export const isViewType = (value: string): value is ViewType => {
|
||||||
|
return VIEW_TYPES.includes(value as ViewType);
|
||||||
|
}
|
||||||
|
|
||||||
export type ToolType = 'merge' | 'split' | 'compress' | 'ocr' | 'convert' | 'sanitize';
|
export type ToolType = 'merge' | 'split' | 'compress' | 'ocr' | 'convert' | 'sanitize';
|
||||||
|
|
||||||
@ -108,12 +118,12 @@ export interface FileContextActions {
|
|||||||
removeFiles: (fileIds: string[], deleteFromStorage?: boolean) => void;
|
removeFiles: (fileIds: string[], deleteFromStorage?: boolean) => void;
|
||||||
replaceFile: (oldFileId: string, newFile: File) => Promise<void>;
|
replaceFile: (oldFileId: string, newFile: File) => Promise<void>;
|
||||||
clearAllFiles: () => void;
|
clearAllFiles: () => void;
|
||||||
|
|
||||||
// File pinning
|
// File pinning
|
||||||
pinFile: (file: File) => void;
|
pinFile: (file: File) => void;
|
||||||
unpinFile: (file: File) => void;
|
unpinFile: (file: File) => void;
|
||||||
isFilePinned: (file: File) => boolean;
|
isFilePinned: (file: File) => boolean;
|
||||||
|
|
||||||
// File consumption (replace unpinned files with outputs)
|
// File consumption (replace unpinned files with outputs)
|
||||||
consumeFiles: (inputFiles: File[], outputFiles: File[]) => Promise<void>;
|
consumeFiles: (inputFiles: File[], outputFiles: File[]) => Promise<void>;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user