mirror of
https://github.com/wgh136/nysoure.git
synced 2025-09-27 12:17:24 +00:00
Add loading status to publish page.
This commit is contained in:
@@ -158,13 +158,20 @@ export function QuickAddTagDialog({ onAdded }: { onAdded: (tags: Tag[]) => void
|
|||||||
|
|
||||||
const [separator, setSeparator] = useState<string>(",")
|
const [separator, setSeparator] = useState<string>(",")
|
||||||
|
|
||||||
|
const [isLoading, setLoading] = useState(false)
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
|
if (isLoading) {
|
||||||
|
return
|
||||||
|
}
|
||||||
if (text.trim().length === 0) {
|
if (text.trim().length === 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
setError(null)
|
setError(null)
|
||||||
const names = text.split(separator).filter((n) => n.length > 0)
|
const names = text.split(separator).filter((n) => n.length > 0)
|
||||||
|
setLoading(true)
|
||||||
const res = await network.getOrCreateTags(names, type)
|
const res = await network.getOrCreateTags(names, type)
|
||||||
|
setLoading(false)
|
||||||
if (!res.success) {
|
if (!res.success) {
|
||||||
setError(res.message)
|
setError(res.message)
|
||||||
return
|
return
|
||||||
@@ -214,7 +221,7 @@ export function QuickAddTagDialog({ onAdded }: { onAdded: (tags: Tag[]) => void
|
|||||||
<form method="dialog">
|
<form method="dialog">
|
||||||
<Button className="btn">{t("Cancel")}</Button>
|
<Button className="btn">{t("Cancel")}</Button>
|
||||||
</form>
|
</form>
|
||||||
<Button className={"btn-primary"} disabled={text === ""} onClick={handleSubmit}>{t("Submit")}</Button>
|
<Button isLoading={isLoading} className={"btn-primary"} disabled={text === ""} onClick={handleSubmit}>{t("Submit")}</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</dialog>
|
</dialog>
|
||||||
|
@@ -72,6 +72,7 @@ export default function EditResourcePage() {
|
|||||||
setError(t("Description cannot be empty"))
|
setError(t("Description cannot be empty"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
setSubmitting(true)
|
||||||
const res = await network.editResource(id, {
|
const res = await network.editResource(id, {
|
||||||
title: title,
|
title: title,
|
||||||
alternative_titles: altTitles,
|
alternative_titles: altTitles,
|
||||||
|
@@ -50,6 +50,7 @@ export default function PublishPage() {
|
|||||||
setError(t("Description cannot be empty"))
|
setError(t("Description cannot be empty"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
setSubmitting(true)
|
||||||
const res = await network.createResource({
|
const res = await network.createResource({
|
||||||
title: title,
|
title: title,
|
||||||
alternative_titles: altTitles,
|
alternative_titles: altTitles,
|
||||||
|
Reference in New Issue
Block a user