mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-09 07:03:25 +00:00
refactor: fix some lintter erros
This commit is contained in:
@@ -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>,
|
||||
|
||||
@@ -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}</>;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user