refactor: fix some lintter erros

This commit is contained in:
Sonny
2024-05-25 17:19:26 +02:00
committed by Sonny
parent 09700a1916
commit 8b161dcf49
7 changed files with 31 additions and 21 deletions

View File

@@ -18,6 +18,7 @@ interface ModalProps {
children: ReactNode;
opened: boolean;
hideCloseBtn?: boolean;
className?: string;
close: () => void;
}
@@ -27,13 +28,14 @@ export default function Modal({
children,
opened = true,
hideCloseBtn = false,
className,
close,
}: ModalProps) {
const modalRef = useRef<HTMLDivElement>(null);
const { setGlobalHotkeysEnabled } = useGlobalHotkeys();
useClickOutside(modalRef, close);
useShortcut('ESCAPE_KEY', close);
useShortcut('ESCAPE_KEY', close, { disableGlobalCheck: true });
useEffect(() => setGlobalHotkeysEnabled(!opened), [opened]);
@@ -45,18 +47,17 @@ export default function Modal({
opened &&
createPortal(
<ModalWrapper>
<ModalContainer ref={modalRef}>
{!hideCloseBtn ||
(title && (
<ModalHeader>
{title && <TextEllipsis>{title}</TextEllipsis>}
{!hideCloseBtn && (
<ModalCloseBtn onClick={close}>
<IoClose size={20} />
</ModalCloseBtn>
)}
</ModalHeader>
))}
<ModalContainer className={className} ref={modalRef}>
{(!hideCloseBtn || title) && (
<ModalHeader>
{title && <TextEllipsis>{title}</TextEllipsis>}
{!hideCloseBtn && (
<ModalCloseBtn onClick={close}>
<IoClose size={20} />
</ModalCloseBtn>
)}
</ModalHeader>
)}
<ModalBody>{children}</ModalBody>
</ModalContainer>
</ModalWrapper>,

View File

@@ -6,9 +6,12 @@ import useShortcut from '~/hooks/use_shortcut';
import { appendCollectionId } from '~/lib/navigation';
export default function BackToDashboard({ children }: { children: ReactNode }) {
const collectionId = useSearchParam('collectionId');
useShortcut('ESCAPE_KEY', () =>
router.visit(appendCollectionId(route('dashboard').url, collectionId))
const collectionId = Number(useSearchParam('collectionId'));
useShortcut(
'ESCAPE_KEY',
() =>
router.visit(appendCollectionId(route('dashboard').url, collectionId)),
{ disableGlobalCheck: true }
);
return <>{children}</>;
}

View File

@@ -21,7 +21,7 @@ export default function DeleteCollectionPage({
const handleSubmit = () => {
const { method, url } = route('collection.delete', {
params: { id: collection.id },
params: { id: collection.id.toString() },
});
submit(method, url);
};

View File

@@ -30,7 +30,7 @@ export default function EditCollectionPage({
const handleSubmit = () => {
const { method, url } = route('collection.edit', {
params: { id: collection.id },
params: { id: collection.id.toString() },
});
submit(method, url);
};

View File

@@ -15,10 +15,11 @@ export default function DeleteLinkPage({ link }: { link: Link }) {
});
const handleSubmit = () => {
const { method, url } = route('link.delete', { params: { id: link.id } });
const { method, url } = route('link.delete', {
params: { id: link.id.toString() },
});
submit(method, url);
};
console.log(link);
return (
<FormLink

View File

@@ -40,7 +40,9 @@ export default function EditLinkPage({
}, [data, processing]);
const handleSubmit = () => {
const { method, url } = route('link.edit', { params: { id: link.id } });
const { method, url } = route('link.edit', {
params: { id: link.id.toString() },
});
submit(method, url);
};