mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-09 15:05:35 +00:00
refactor: fix some lintter erros
This commit is contained in:
@@ -18,3 +18,6 @@ docker-compose*
|
|||||||
*.md
|
*.md
|
||||||
.git
|
.git
|
||||||
.gitignore
|
.gitignore
|
||||||
|
|
||||||
|
# App specific
|
||||||
|
database/seeders
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ interface ModalProps {
|
|||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
opened: boolean;
|
opened: boolean;
|
||||||
hideCloseBtn?: boolean;
|
hideCloseBtn?: boolean;
|
||||||
|
className?: string;
|
||||||
|
|
||||||
close: () => void;
|
close: () => void;
|
||||||
}
|
}
|
||||||
@@ -27,13 +28,14 @@ export default function Modal({
|
|||||||
children,
|
children,
|
||||||
opened = true,
|
opened = true,
|
||||||
hideCloseBtn = false,
|
hideCloseBtn = false,
|
||||||
|
className,
|
||||||
close,
|
close,
|
||||||
}: ModalProps) {
|
}: ModalProps) {
|
||||||
const modalRef = useRef<HTMLDivElement>(null);
|
const modalRef = useRef<HTMLDivElement>(null);
|
||||||
const { setGlobalHotkeysEnabled } = useGlobalHotkeys();
|
const { setGlobalHotkeysEnabled } = useGlobalHotkeys();
|
||||||
|
|
||||||
useClickOutside(modalRef, close);
|
useClickOutside(modalRef, close);
|
||||||
useShortcut('ESCAPE_KEY', close);
|
useShortcut('ESCAPE_KEY', close, { disableGlobalCheck: true });
|
||||||
|
|
||||||
useEffect(() => setGlobalHotkeysEnabled(!opened), [opened]);
|
useEffect(() => setGlobalHotkeysEnabled(!opened), [opened]);
|
||||||
|
|
||||||
@@ -45,18 +47,17 @@ export default function Modal({
|
|||||||
opened &&
|
opened &&
|
||||||
createPortal(
|
createPortal(
|
||||||
<ModalWrapper>
|
<ModalWrapper>
|
||||||
<ModalContainer ref={modalRef}>
|
<ModalContainer className={className} ref={modalRef}>
|
||||||
{!hideCloseBtn ||
|
{(!hideCloseBtn || title) && (
|
||||||
(title && (
|
<ModalHeader>
|
||||||
<ModalHeader>
|
{title && <TextEllipsis>{title}</TextEllipsis>}
|
||||||
{title && <TextEllipsis>{title}</TextEllipsis>}
|
{!hideCloseBtn && (
|
||||||
{!hideCloseBtn && (
|
<ModalCloseBtn onClick={close}>
|
||||||
<ModalCloseBtn onClick={close}>
|
<IoClose size={20} />
|
||||||
<IoClose size={20} />
|
</ModalCloseBtn>
|
||||||
</ModalCloseBtn>
|
)}
|
||||||
)}
|
</ModalHeader>
|
||||||
</ModalHeader>
|
)}
|
||||||
))}
|
|
||||||
<ModalBody>{children}</ModalBody>
|
<ModalBody>{children}</ModalBody>
|
||||||
</ModalContainer>
|
</ModalContainer>
|
||||||
</ModalWrapper>,
|
</ModalWrapper>,
|
||||||
|
|||||||
@@ -6,9 +6,12 @@ import useShortcut from '~/hooks/use_shortcut';
|
|||||||
import { appendCollectionId } from '~/lib/navigation';
|
import { appendCollectionId } from '~/lib/navigation';
|
||||||
|
|
||||||
export default function BackToDashboard({ children }: { children: ReactNode }) {
|
export default function BackToDashboard({ children }: { children: ReactNode }) {
|
||||||
const collectionId = useSearchParam('collectionId');
|
const collectionId = Number(useSearchParam('collectionId'));
|
||||||
useShortcut('ESCAPE_KEY', () =>
|
useShortcut(
|
||||||
router.visit(appendCollectionId(route('dashboard').url, collectionId))
|
'ESCAPE_KEY',
|
||||||
|
() =>
|
||||||
|
router.visit(appendCollectionId(route('dashboard').url, collectionId)),
|
||||||
|
{ disableGlobalCheck: true }
|
||||||
);
|
);
|
||||||
return <>{children}</>;
|
return <>{children}</>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export default function DeleteCollectionPage({
|
|||||||
|
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
const { method, url } = route('collection.delete', {
|
const { method, url } = route('collection.delete', {
|
||||||
params: { id: collection.id },
|
params: { id: collection.id.toString() },
|
||||||
});
|
});
|
||||||
submit(method, url);
|
submit(method, url);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export default function EditCollectionPage({
|
|||||||
|
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
const { method, url } = route('collection.edit', {
|
const { method, url } = route('collection.edit', {
|
||||||
params: { id: collection.id },
|
params: { id: collection.id.toString() },
|
||||||
});
|
});
|
||||||
submit(method, url);
|
submit(method, url);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,10 +15,11 @@ export default function DeleteLinkPage({ link }: { link: Link }) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const handleSubmit = () => {
|
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);
|
submit(method, url);
|
||||||
};
|
};
|
||||||
console.log(link);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FormLink
|
<FormLink
|
||||||
|
|||||||
@@ -40,7 +40,9 @@ export default function EditLinkPage({
|
|||||||
}, [data, processing]);
|
}, [data, processing]);
|
||||||
|
|
||||||
const handleSubmit = () => {
|
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);
|
submit(method, url);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user