forked from github/plane
fix: cycle and module create/update modal fix (#2833)
This commit is contained in:
parent
e6a1f34713
commit
dd8c7a7487
@ -30,9 +30,11 @@ export const CycleCreateUpdateModal: React.FC<CycleModalProps> = (props) => {
|
||||
// toast
|
||||
const { setToastAlert } = useToast();
|
||||
|
||||
const createCycle = async (payload: Partial<ICycle>) =>
|
||||
cycleStore
|
||||
.createCycle(workspaceSlug, projectId, payload)
|
||||
const createCycle = async (payload: Partial<ICycle>) => {
|
||||
if (!workspaceSlug || !projectId) return;
|
||||
const selectedProjectId = payload.project ?? projectId.toString();
|
||||
await cycleStore
|
||||
.createCycle(workspaceSlug, selectedProjectId, payload)
|
||||
.then(() => {
|
||||
setToastAlert({
|
||||
type: "success",
|
||||
@ -47,10 +49,13 @@ export const CycleCreateUpdateModal: React.FC<CycleModalProps> = (props) => {
|
||||
message: "Error in creating cycle. Please try again.",
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const updateCycle = async (cycleId: string, payload: Partial<ICycle>) =>
|
||||
cycleStore
|
||||
.patchCycle(workspaceSlug, projectId, cycleId, payload)
|
||||
const updateCycle = async (cycleId: string, payload: Partial<ICycle>) => {
|
||||
if (!workspaceSlug || !projectId) return;
|
||||
const selectedProjectId = payload.project ?? projectId.toString();
|
||||
await cycleStore
|
||||
.patchCycle(workspaceSlug, selectedProjectId, cycleId, payload)
|
||||
.then(() => {
|
||||
setToastAlert({
|
||||
type: "success",
|
||||
@ -65,6 +70,7 @@ export const CycleCreateUpdateModal: React.FC<CycleModalProps> = (props) => {
|
||||
message: "Error in updating cycle. Please try again.",
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const dateChecker = async (payload: CycleDateCheckData) => {
|
||||
let status = false;
|
||||
|
@ -49,9 +49,9 @@ export const CreateUpdateModuleModal: React.FC<Props> = observer((props) => {
|
||||
|
||||
const createModule = async (payload: Partial<IModule>) => {
|
||||
if (!workspaceSlug || !projectId) return;
|
||||
|
||||
const selectedProjectId = payload.project ?? projectId.toString();
|
||||
await moduleStore
|
||||
.createModule(workspaceSlug.toString(), projectId.toString(), payload)
|
||||
.createModule(workspaceSlug.toString(), selectedProjectId, payload)
|
||||
.then(() => {
|
||||
handleClose();
|
||||
|
||||
@ -72,9 +72,9 @@ export const CreateUpdateModuleModal: React.FC<Props> = observer((props) => {
|
||||
|
||||
const updateModule = async (payload: Partial<IModule>) => {
|
||||
if (!workspaceSlug || !projectId || !data) return;
|
||||
|
||||
const selectedProjectId = payload.project ?? projectId.toString();
|
||||
await moduleStore
|
||||
.updateModuleDetails(workspaceSlug.toString(), projectId.toString(), data.id, payload)
|
||||
.updateModuleDetails(workspaceSlug.toString(), selectedProjectId, data.id, payload)
|
||||
.then(() => {
|
||||
handleClose();
|
||||
|
||||
@ -99,7 +99,6 @@ export const CreateUpdateModuleModal: React.FC<Props> = observer((props) => {
|
||||
const payload: Partial<IModule> = {
|
||||
...formData,
|
||||
};
|
||||
|
||||
if (!data) await createModule(payload);
|
||||
else await updateModule(payload);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user