ФУНКЦИИ - МЕЖПРОЕКТНАЯ КОММУНИКАЦИЯ: web-доступ к внешним контурам и исправление модалки запроса
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
import type { FormEvent } from "react";
|
||||
import { useRef, useState } from "react";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import type { EditorRefApi } from "@plane/editor";
|
||||
import { useTranslation } from "@plane/i18n";
|
||||
@@ -46,7 +46,7 @@ export const ExternalContoursCreateRoot = observer(function ExternalContoursCrea
|
||||
const { getWorkspaceBySlug } = useWorkspace();
|
||||
const workspaceId = getWorkspaceBySlug(workspaceSlug)?.id;
|
||||
const { currentProjectDetails } = useProject();
|
||||
const { createRequest } = useProjectExternalContours();
|
||||
const { createRequest, fetchTargetOptions, fetchTargetProjects } = useProjectExternalContours();
|
||||
const descriptionEditorRef = useRef<EditorRefApi>(null);
|
||||
const [createMore, setCreateMore] = useState(false);
|
||||
const [formSubmitting, setFormSubmitting] = useState(false);
|
||||
@@ -59,6 +59,28 @@ export const ExternalContoursCreateRoot = observer(function ExternalContoursCrea
|
||||
const isTitleLengthMoreThan255Character = formData?.name ? formData.name.length > 255 : false;
|
||||
const canSubmit = !!formData.name?.trim() && !!formData.target_project_id;
|
||||
|
||||
useEffect(() => {
|
||||
if (!workspaceSlug || !projectId) return;
|
||||
fetchTargetProjects(workspaceSlug, projectId).catch(() => {
|
||||
setToast({
|
||||
type: TOAST_TYPE.ERROR,
|
||||
title: t("error"),
|
||||
message: t("external_contours_page.modal.error_message"),
|
||||
});
|
||||
});
|
||||
}, [fetchTargetProjects, projectId, t, workspaceSlug]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!workspaceSlug || !projectId || !formData.target_project_id) return;
|
||||
fetchTargetOptions(workspaceSlug, projectId, formData.target_project_id).catch(() => {
|
||||
setToast({
|
||||
type: TOAST_TYPE.ERROR,
|
||||
title: t("error"),
|
||||
message: t("external_contours_page.modal.error_message"),
|
||||
});
|
||||
});
|
||||
}, [fetchTargetOptions, formData.target_project_id, projectId, t, workspaceSlug]);
|
||||
|
||||
const handleFormSubmit = async (event: FormEvent<HTMLFormElement>) => {
|
||||
event.preventDefault();
|
||||
|
||||
@@ -128,7 +150,6 @@ export const ExternalContoursCreateRoot = observer(function ExternalContoursCrea
|
||||
onAssetUpload={() => {}}
|
||||
/>
|
||||
<ExternalContoursCreateProperties
|
||||
currentProjectId={projectId}
|
||||
currentProjectName={currentProjectDetails?.name}
|
||||
data={formData}
|
||||
handleData={handleFormData as any}
|
||||
|
||||
Reference in New Issue
Block a user