Fix archive project appearing to do nothing
The archive mutation lacked user feedback: - No toast notification on success/failure - Navigated to /projects instead of /dashboard after archiving - No error handling if the API call failed Added success/error toasts using the existing ToastContext, navigate to /dashboard after archiving (matching user expectations), and error toast on failure. Co-Authored-By: Paperclip <noreply@paperclip.ing> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,7 @@ import { heartbeatsApi } from "../api/heartbeats";
|
||||
import { assetsApi } from "../api/assets";
|
||||
import { usePanel } from "../context/PanelContext";
|
||||
import { useCompany } from "../context/CompanyContext";
|
||||
import { useToast } from "../context/ToastContext";
|
||||
import { useBreadcrumbs } from "../context/BreadcrumbContext";
|
||||
import { queryKeys } from "../lib/queryKeys";
|
||||
import { ProjectProperties, type ProjectConfigFieldKey, type ProjectFieldSaveState } from "../components/ProjectProperties";
|
||||
@@ -213,6 +214,7 @@ export function ProjectDetail() {
|
||||
const queryClient = useQueryClient();
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
const { pushToast } = useToast();
|
||||
const [fieldSaveStates, setFieldSaveStates] = useState<Partial<Record<ProjectConfigFieldKey, ProjectFieldSaveState>>>({});
|
||||
const fieldSaveRequestIds = useRef<Partial<Record<ProjectConfigFieldKey, number>>>({});
|
||||
const fieldSaveTimers = useRef<Partial<Record<ProjectConfigFieldKey, ReturnType<typeof setTimeout>>>>({});
|
||||
@@ -287,9 +289,18 @@ export function ProjectDetail() {
|
||||
onSuccess: (_, archived) => {
|
||||
invalidateProject();
|
||||
if (archived) {
|
||||
navigate("/projects");
|
||||
pushToast({ title: "Project archived", tone: "success" });
|
||||
navigate("/dashboard");
|
||||
} else {
|
||||
pushToast({ title: "Project unarchived", tone: "success" });
|
||||
}
|
||||
},
|
||||
onError: (_, archived) => {
|
||||
pushToast({
|
||||
title: archived ? "Failed to archive project" : "Failed to unarchive project",
|
||||
tone: "error",
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const uploadImage = useMutation({
|
||||
|
||||
Reference in New Issue
Block a user