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>;
|
||||
};
|
||||
|
||||
const defaultValues: ModuleLink = {
|
||||
const defaultValues: IIssueLink | ModuleLink = {
|
||||
title: "",
|
||||
url: "",
|
||||
};
|
||||
@ -30,9 +30,8 @@ export const LinkModal: React.FC<Props> = ({ isOpen, handleClose, onFormSubmit }
|
||||
defaultValues,
|
||||
});
|
||||
|
||||
const onSubmit = async (formData: ModuleLink) => {
|
||||
await onFormSubmit(formData);
|
||||
|
||||
const onSubmit = async (formData: IIssueLink | ModuleLink) => {
|
||||
await onFormSubmit({ title: formData.title, url: formData.url });
|
||||
onClose();
|
||||
};
|
||||
|
||||
@ -87,7 +86,7 @@ export const LinkModal: React.FC<Props> = ({ isOpen, handleClose, onFormSubmit }
|
||||
label="URL"
|
||||
name="url"
|
||||
type="url"
|
||||
placeholder="Enter URL"
|
||||
placeholder="https://..."
|
||||
autoComplete="off"
|
||||
error={errors.url}
|
||||
register={register}
|
||||
@ -99,16 +98,13 @@ export const LinkModal: React.FC<Props> = ({ isOpen, handleClose, onFormSubmit }
|
||||
<div>
|
||||
<Input
|
||||
id="title"
|
||||
label="Title"
|
||||
label="Title (optional)"
|
||||
name="title"
|
||||
type="text"
|
||||
placeholder="Enter title"
|
||||
autoComplete="off"
|
||||
error={errors.title}
|
||||
register={register}
|
||||
validations={{
|
||||
required: "Title is required",
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -55,7 +55,7 @@ export const LinksList: React.FC<Props> = ({ links, handleDeleteLink, userAuth }
|
||||
<LinkIcon className="h-3.5 w-3.5" />
|
||||
</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">
|
||||
Added {timeAgo(link.created_at)}
|
||||
<br />
|
||||
|
Loading…
Reference in New Issue
Block a user