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