Restore celebration when adding suggestions
This commit is contained in:
@@ -2,7 +2,7 @@ import { api } from "./api.js";
|
|||||||
import { t } from "./i18n.js";
|
import { t } from "./i18n.js";
|
||||||
import { state, getSavedUsername, setSavedUsername } from "./state.js";
|
import { state, getSavedUsername, setSavedUsername } from "./state.js";
|
||||||
import { $, toast } from "./dom.js";
|
import { $, toast } from "./dom.js";
|
||||||
import { setupCardVisualHover } from "./effects.js";
|
import { setupCardVisualHover, triggerCelebration } from "./effects.js";
|
||||||
|
|
||||||
export function setAuthUI(isAuthed) {
|
export function setAuthUI(isAuthed) {
|
||||||
const main = document.querySelector("main");
|
const main = document.querySelector("main");
|
||||||
@@ -470,7 +470,7 @@ function openSuggestionModal({ title, submitLabel, initial = {}, onSubmit }) {
|
|||||||
}
|
}
|
||||||
if (!data.name?.trim()) return toast(t("toast.nameRequired"), true);
|
if (!data.name?.trim()) return toast(t("toast.nameRequired"), true);
|
||||||
try {
|
try {
|
||||||
await onSubmit(data, close);
|
await onSubmit(data, close, submitBtn);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (window.handleAuthError?.(err)) return;
|
if (window.handleAuthError?.(err)) return;
|
||||||
toast(err.message, true);
|
toast(err.message, true);
|
||||||
@@ -488,9 +488,10 @@ export function openNewSuggestionModal() {
|
|||||||
title: t("modal.addTitle") || t("suggest.new"),
|
title: t("modal.addTitle") || t("suggest.new"),
|
||||||
submitLabel: t("form.submit"),
|
submitLabel: t("form.submit"),
|
||||||
initial: {},
|
initial: {},
|
||||||
onSubmit: async (data, close) => {
|
onSubmit: async (data, close, submitBtn) => {
|
||||||
await api.createSuggestion(data);
|
await api.createSuggestion(data);
|
||||||
toast(t("toast.suggestionAdded"));
|
toast(t("toast.suggestionAdded"));
|
||||||
|
if (submitBtn) triggerCelebration(submitBtn);
|
||||||
close();
|
close();
|
||||||
await window.loadSuggestData();
|
await window.loadSuggestData();
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user