mirror of
https://github.com/aykhans/slash-e.git
synced 2025-04-20 22:07:15 +00:00
chore: add tag input
This commit is contained in:
parent
7c16b1e00f
commit
47821879fa
@ -22,6 +22,7 @@ const CreateShortcutButton = () => {
|
|||||||
title: "",
|
title: "",
|
||||||
link: "",
|
link: "",
|
||||||
});
|
});
|
||||||
|
const [tag, setTag] = useState<string>("");
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [showModal, setShowModal] = useState(false);
|
const [showModal, setShowModal] = useState(false);
|
||||||
|
|
||||||
@ -83,6 +84,11 @@ const CreateShortcutButton = () => {
|
|||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleTagsInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
const text = e.target.value as string;
|
||||||
|
setTag(text);
|
||||||
|
};
|
||||||
|
|
||||||
const handleSaveBtnClick = async () => {
|
const handleSaveBtnClick = async () => {
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return;
|
return;
|
||||||
@ -94,6 +100,7 @@ const CreateShortcutButton = () => {
|
|||||||
|
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
try {
|
try {
|
||||||
|
const tags = tag.split(" ").filter(Boolean);
|
||||||
await shortcutStore.createShortcut(
|
await shortcutStore.createShortcut(
|
||||||
instanceUrl,
|
instanceUrl,
|
||||||
accessToken,
|
accessToken,
|
||||||
@ -102,6 +109,7 @@ const CreateShortcutButton = () => {
|
|||||||
title: state.title,
|
title: state.title,
|
||||||
link: state.link,
|
link: state.link,
|
||||||
visibility: Visibility.PUBLIC,
|
visibility: Visibility.PUBLIC,
|
||||||
|
tags,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
toast.success("Shortcut created successfully");
|
toast.success("Shortcut created successfully");
|
||||||
@ -157,6 +165,10 @@ const CreateShortcutButton = () => {
|
|||||||
onChange={handleLinkInputChange}
|
onChange={handleLinkInputChange}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="w-full flex flex-row justify-start items-center mb-2">
|
||||||
|
<span className="block w-12 mr-2 shrink-0">Tags</span>
|
||||||
|
<Input className="grow" type="text" placeholder="The tags of shortcut" value={tag} onChange={handleTagsInputChange} />
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="w-full flex flex-row justify-end items-center mt-2 space-x-2">
|
<div className="w-full flex flex-row justify-end items-center mt-2 space-x-2">
|
||||||
<Button color="neutral" variant="plain" onClick={() => setShowModal(false)}>
|
<Button color="neutral" variant="plain" onClick={() => setShowModal(false)}>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user