forked from github/plane
fix: link validation fix (#1645)
* fix: link validation fix * fix: build fix and code refactor * fix: build fix * chore: code refactor * fix: link url input fix * chore: link type updated * fix: build fix
This commit is contained in:
parent
ad410d134f
commit
2229d8d828
@ -15,7 +15,7 @@ type Props = {
|
|||||||
onFormSubmit: (formData: IIssueLink | ModuleLink) => Promise<void>;
|
onFormSubmit: (formData: IIssueLink | ModuleLink) => Promise<void>;
|
||||||
};
|
};
|
||||||
|
|
||||||
const defaultValues: ModuleLink = {
|
const defaultValues: IIssueLink | ModuleLink = {
|
||||||
title: "",
|
title: "",
|
||||||
url: "",
|
url: "",
|
||||||
};
|
};
|
||||||
@ -30,9 +30,8 @@ export const LinkModal: React.FC<Props> = ({ isOpen, handleClose, onFormSubmit }
|
|||||||
defaultValues,
|
defaultValues,
|
||||||
});
|
});
|
||||||
|
|
||||||
const onSubmit = async (formData: ModuleLink) => {
|
const onSubmit = async (formData: IIssueLink | ModuleLink) => {
|
||||||
await onFormSubmit(formData);
|
await onFormSubmit({ title: formData.title, url: formData.url });
|
||||||
|
|
||||||
onClose();
|
onClose();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -87,7 +86,7 @@ export const LinkModal: React.FC<Props> = ({ isOpen, handleClose, onFormSubmit }
|
|||||||
label="URL"
|
label="URL"
|
||||||
name="url"
|
name="url"
|
||||||
type="url"
|
type="url"
|
||||||
placeholder="Enter URL"
|
placeholder="https://..."
|
||||||
autoComplete="off"
|
autoComplete="off"
|
||||||
error={errors.url}
|
error={errors.url}
|
||||||
register={register}
|
register={register}
|
||||||
@ -99,16 +98,13 @@ export const LinkModal: React.FC<Props> = ({ isOpen, handleClose, onFormSubmit }
|
|||||||
<div>
|
<div>
|
||||||
<Input
|
<Input
|
||||||
id="title"
|
id="title"
|
||||||
label="Title"
|
label="Title (optional)"
|
||||||
name="title"
|
name="title"
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Enter title"
|
placeholder="Enter title"
|
||||||
autoComplete="off"
|
autoComplete="off"
|
||||||
error={errors.title}
|
error={errors.title}
|
||||||
register={register}
|
register={register}
|
||||||
validations={{
|
|
||||||
required: "Title is required",
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -55,7 +55,7 @@ export const LinksList: React.FC<Props> = ({ links, handleDeleteLink, userAuth }
|
|||||||
<LinkIcon className="h-3.5 w-3.5" />
|
<LinkIcon className="h-3.5 w-3.5" />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h5 className="w-4/5 break-words">{link.title}</h5>
|
<h5 className="w-4/5 break-words">{link.title ?? link.url}</h5>
|
||||||
<p className="mt-0.5 text-custom-text-200">
|
<p className="mt-0.5 text-custom-text-200">
|
||||||
Added {timeAgo(link.created_at)}
|
Added {timeAgo(link.created_at)}
|
||||||
<br />
|
<br />
|
||||||
|
Loading…
Reference in New Issue
Block a user