Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export type TLinkCreateEditModal = {
handleOnClose?: () => void;
linkOperations: TLinkOperationsModal;
preloadedData?: TLinkCreateFormFieldOptions;
setLinkData: (link: TLink | undefined) => void;
};

const defaultValues: TLinkCreateFormFieldOptions = {
Expand All @@ -31,7 +30,7 @@ const defaultValues: TLinkCreateFormFieldOptions = {

export const LinkCreateUpdateModal: FC<TLinkCreateEditModal> = observer((props) => {
// props
const { setLinkData, isModalOpen, handleOnClose, linkOperations, preloadedData } = props;
const { isModalOpen, handleOnClose, linkOperations, preloadedData } = props;
// react hook form
const {
formState: { errors, isSubmitting },
Expand All @@ -45,7 +44,6 @@ export const LinkCreateUpdateModal: FC<TLinkCreateEditModal> = observer((props)

const onClose = () => {
if (handleOnClose) handleOnClose();
setLinkData(undefined);
};

const handleFormSubmit = async (formData: TLinkCreateFormFieldOptions) => {
Expand Down
11 changes: 7 additions & 4 deletions web/core/components/home/widgets/links/root.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useCallback } from "react";
import { observer } from "mobx-react";
import useSWR from "swr";
import { Plus } from "lucide-react";
Expand All @@ -16,6 +17,11 @@ export const DashboardQuickLinks = observer((props: THomeWidgetProps) => {
} = useHome();
const { t } = useTranslation();

const handleCreateLinkModal = useCallback(() => {
toggleLinkModal(true);
setLinkData(undefined);
}, []);

useSWR(
workspaceSlug ? `HOME_LINKS_${workspaceSlug}` : null,
workspaceSlug ? () => fetchLinks(workspaceSlug.toString()) : null,
Expand All @@ -32,15 +38,12 @@ export const DashboardQuickLinks = observer((props: THomeWidgetProps) => {
handleOnClose={() => toggleLinkModal(false)}
linkOperations={linkOperations}
preloadedData={linkData}
setLinkData={setLinkData}
/>
<div className="mb-2">
<div className="flex items-center justify-between mb-4">
<div className="text-base font-semibold text-custom-text-350">{t("home.quick_links.title_plural")}</div>
<button
onClick={() => {
toggleLinkModal(true);
}}
onClick={handleCreateLinkModal}
className="flex gap-1 text-sm font-medium text-custom-primary-100 my-auto"
>
<Plus className="size-4 my-auto" /> <span>{t("home.quick_links.add")}</span>
Expand Down