Skip to content

Commit

Permalink
Merge pull request #2058 from harshalranjhani/harshalranjhani/2054/ad…
Browse files Browse the repository at this point in the history
…d-toast-for-deletion

feat: remove confirmation and show toast on goal delete
  • Loading branch information
vinaybadgujar102 authored Oct 13, 2024
2 parents 711033d + 83da4f3 commit e2bf3d8
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import ConfirmationModal from "@src/common/ConfirmationModal";
import ZModal from "@src/common/ZModal";
import archiveSound from "@assets/archive.mp3";

import { lastAction, openDevMode, displayConfirmation } from "@src/store";
import { lastAction, openDevMode, displayConfirmation, displayToast } from "@src/store";
import { GoalItem } from "@src/models/GoalItem";
import { TConfirmAction } from "@src/Interfaces/IPopupModals";
import useGoalActions from "@src/hooks/useGoalActions";
Expand Down Expand Up @@ -40,8 +40,18 @@ const RegularGoalActions = ({ goal }: { goal: GoalItem }) => {
const setLastAction = useSetRecoilState(lastAction);
const ancestors = (state?.goalsHistory || []).map((ele) => ele.goalID);

const setShowToast = useSetRecoilState(displayToast);

const [confirmationAction, setConfirmationAction] = useState<TConfirmAction | null>(null);

const showMessage = (message: string, extra = "") => {
setShowToast({
open: true,
message,
extra,
});
};

const handleArchiveGoal = async (goalToArchive: GoalItem, goalAncestors: string[]) => {
await archiveThisGoal(goalToArchive, goalAncestors);
setLastAction("goalArchived");
Expand All @@ -58,6 +68,7 @@ const RegularGoalActions = ({ goal }: { goal: GoalItem }) => {
if (action === "delete") {
await deleteGoalAction(goal);
setLastAction("goalDeleted");
showMessage("Moved to trash!", "We'll delete it in 7 days.");
} else if (action === "archive") {
await handleArchiveGoal(goal, ancestors);
} else if (action === "colabRequest") {
Expand Down Expand Up @@ -106,7 +117,7 @@ const RegularGoalActions = ({ goal }: { goal: GoalItem }) => {
className="goal-action shareOptions-btn"
onClickCapture={async (e) => {
e.stopPropagation();
await openConfirmationPopUp({ actionCategory: confirmActionCategory, actionName: "delete" });
await handleActionClick("delete");
}}
>
<ActionDiv label={t("Delete")} icon="Delete" />
Expand Down

0 comments on commit e2bf3d8

Please sign in to comment.