chore: estimate alerts

This commit is contained in:
guru_sainath 2024-05-31 16:21:37 +05:30
parent 1d9a011797
commit ec228ad02c
3 changed files with 49 additions and 13 deletions

View File

@ -2,7 +2,7 @@ import { FC, FormEvent, useState } from "react";
import { observer } from "mobx-react";
import { Check, Info, X } from "lucide-react";
import { TEstimatePointsObject, TEstimateSystemKeys } from "@plane/types";
import { Spinner, Tooltip } from "@plane/ui";
import { Spinner, TOAST_TYPE, Tooltip, setToast } from "@plane/ui";
// constants
import { EEstimateSystem } from "@/constants/estimates";
// helpers
@ -91,21 +91,34 @@ export const EstimatePointCreate: FC<TEstimatePointCreate> = observer((props) =>
setLoader(false);
setError(undefined);
setToast({
type: TOAST_TYPE.SUCCESS,
title: "Estimate point updated",
message: "The estimate point has been updated successfully.",
});
handleClose();
} catch {
setLoader(false);
setError("something went wrong. please try again later");
setError("We are unable to process your request, please try again.");
setToast({
type: TOAST_TYPE.ERROR,
title: "Estimate point failed to updated",
message: "We are unable to process your request, please try again.",
});
}
} else {
handleSuccess(estimateInputValue);
setError("Please fill the input field");
}
} else {
setLoader(false);
setError("please enter a valid estimate value");
setError(
[EEstimateSystem.POINTS, EEstimateSystem.TIME].includes(estimateType)
? "Estimate point needs to be a numeric value."
: "Estimate point needs to be a character value."
);
}
} else setError("Estimate point values cannot be repeated");
} else setError("Please fill the input field");
} else setError("Estimate value already exists.");
} else setError("Estimate value cannot be empty.");
};
return (

View File

@ -2,7 +2,7 @@ import { FC, useState } from "react";
import { observer } from "mobx-react";
import { MoveRight, Trash2, X } from "lucide-react";
import { TEstimatePointsObject } from "@plane/types";
import { Spinner } from "@plane/ui";
import { Spinner, TOAST_TYPE, setToast } from "@plane/ui";
// components
import { EstimatePointDropdown } from "@/components/estimates/points";
// hooks
@ -49,10 +49,20 @@ export const EstimatePointDelete: FC<TEstimatePointDelete> = observer((props) =>
setLoader(false);
setError(undefined);
setToast({
type: TOAST_TYPE.SUCCESS,
title: "Estimate point updated",
message: "The estimate point has been updated successfully.",
});
handleClose();
} catch {
setLoader(false);
setError("something went wrong. please try again later");
setToast({
type: TOAST_TYPE.ERROR,
title: "Estimate point failed to updated",
message: "We are unable to process your request, please try again.",
});
}
else setError("please select option");
};

View File

@ -2,7 +2,7 @@ import { FC, FormEvent, useEffect, useState } from "react";
import { observer } from "mobx-react";
import { Check, Info, X } from "lucide-react";
import { TEstimatePointsObject, TEstimateSystemKeys } from "@plane/types";
import { Spinner, Tooltip } from "@plane/ui";
import { Spinner, TOAST_TYPE, Tooltip, setToast } from "@plane/ui";
// constants
import { EEstimateSystem } from "@/constants/estimates";
// helpers
@ -99,20 +99,33 @@ export const EstimatePointUpdate: FC<TEstimatePointUpdate> = observer((props) =>
setLoader(false);
setError(undefined);
handleClose();
setToast({
type: TOAST_TYPE.SUCCESS,
title: "Estimate point updated",
message: "The estimate point has been updated successfully.",
});
} catch {
setLoader(false);
setError("something went wrong. please try again later");
setError("We are unable to process your request, please try again.");
setToast({
type: TOAST_TYPE.ERROR,
title: "Estimate point failed to updated",
message: "We are unable to process your request, please try again.",
});
}
} else {
handleSuccess(estimateInputValue);
setError("Please fill the input field");
}
} else {
setLoader(false);
setError("please enter a valid estimate value");
setError(
[EEstimateSystem.POINTS, EEstimateSystem.TIME].includes(estimateType)
? "Estimate point needs to be a numeric value."
: "Estimate point needs to be a character value."
);
}
} else setError("Estimate point values cannot be repeated");
} else setError("Please fill the input field");
} else setError("Estimate value already exists.");
} else setError("Estimate value cannot be empty.");
};
return (