From 6df4f75de924caa84e197665178e28e8958110d2 Mon Sep 17 00:00:00 2001 From: Roie Natan Date: Thu, 14 Sep 2023 17:42:25 +0300 Subject: [PATCH 01/12] init --- .../interfaces/UpdateGovernanceCircleName.ts | 6 +++++ src/pages/OldCommon/store/api.tsx | 13 +++++++++++ .../CreationForm/components/Item/Item.tsx | 22 +++++++++++++++++++ .../constants/creationFormItemType.ts | 1 + .../components/CreationForm/types.ts | 8 ++++++- .../ProjectCreationForm.tsx | 4 +++- .../ProjectCreationForm/configuration.ts | 17 +++++++++++++- .../commonCreation/hooks/useCommonForm.ts | 10 ++++++--- .../components/EditingForm/EditingForm.tsx | 20 ++++++++++++++++- .../Form/Formik/TextField/TextField.tsx | 4 +++- src/shared/constants/endpoint.ts | 1 + src/shared/interfaces/CreateProjectPayload.ts | 1 + 12 files changed, 99 insertions(+), 8 deletions(-) create mode 100644 src/pages/OldCommon/interfaces/UpdateGovernanceCircleName.ts diff --git a/src/pages/OldCommon/interfaces/UpdateGovernanceCircleName.ts b/src/pages/OldCommon/interfaces/UpdateGovernanceCircleName.ts new file mode 100644 index 0000000000..7fc262088d --- /dev/null +++ b/src/pages/OldCommon/interfaces/UpdateGovernanceCircleName.ts @@ -0,0 +1,6 @@ +export interface UpdateGovernanceCircleNamePayload { + commonId: string; + circleId: string; + userId: string; + newName: string; +} diff --git a/src/pages/OldCommon/store/api.tsx b/src/pages/OldCommon/store/api.tsx index 0af0b8244c..8c837b12ea 100644 --- a/src/pages/OldCommon/store/api.tsx +++ b/src/pages/OldCommon/store/api.tsx @@ -68,6 +68,7 @@ import firebase from "@/shared/utils/firebase"; import { generateCirclesDataForCommonMember } from "../../../shared/utils/generateCircleDataForCommonMember"; import { ChangeVisibilityDto } from "../interfaces/ChangeVisibilityDto"; import { UpdateDiscussionMessageDto } from "../interfaces/UpdateDiscussionMessageDto"; +import { UpdateGovernanceCircleNamePayload } from "../interfaces/UpdateGovernanceCircleName"; export async function createGovernance( requestData: CreateGovernancePayload, @@ -1204,3 +1205,15 @@ export async function updateGovernanceRules( return convertObjectDatesToFirestoreTimestamps(data); } + +export async function updateGovernanceCircleName( + payload: UpdateGovernanceCircleNamePayload, +): Promise { + // UpdateGovernanceCircleNameResponse + const { data } = await Api.put( + ApiEndpoint.GovernanceUpdateCircleName, + payload, + ); + + return convertObjectDatesToFirestoreTimestamps(data); +} diff --git a/src/pages/commonCreation/components/CreationForm/components/Item/Item.tsx b/src/pages/commonCreation/components/CreationForm/components/Item/Item.tsx index 4ae58de11f..434504355d 100644 --- a/src/pages/commonCreation/components/CreationForm/components/Item/Item.tsx +++ b/src/pages/commonCreation/components/CreationForm/components/Item/Item.tsx @@ -1,5 +1,6 @@ import React, { FC } from "react"; import classNames from "classnames"; +import { FieldArray } from "formik"; import { LinksArrayWrapper, TextEditor, @@ -66,6 +67,27 @@ const Item: FC = (props) => { disabled={disabled ?? item.props.disabled} /> ); + case CreationFormItemType.TextFieldArray: + console.log(item); + + return ( + <> + + item.values.map((role, index) => ( + + )) + } + /> + + ); default: return null; } diff --git a/src/pages/commonCreation/components/CreationForm/constants/creationFormItemType.ts b/src/pages/commonCreation/components/CreationForm/constants/creationFormItemType.ts index 8699b2213e..c1cc4b724a 100644 --- a/src/pages/commonCreation/components/CreationForm/constants/creationFormItemType.ts +++ b/src/pages/commonCreation/components/CreationForm/constants/creationFormItemType.ts @@ -3,4 +3,5 @@ export enum CreationFormItemType { TextEditor = "TextEditor", UploadFiles = "UploadFiles", Links = "Links", + TextFieldArray = "TextFieldArray", } diff --git a/src/pages/commonCreation/components/CreationForm/types.ts b/src/pages/commonCreation/components/CreationForm/types.ts index 106ef4d9d6..e03c97f8a1 100644 --- a/src/pages/commonCreation/components/CreationForm/types.ts +++ b/src/pages/commonCreation/components/CreationForm/types.ts @@ -55,8 +55,14 @@ export interface LinksFormItem extends BaseFormItem { validation?: Pick; } +export interface TextFieldFormItems extends BaseFormItem { + type: CreationFormItemType.TextFieldArray; + values: string[]; +} + export type CreationFormItem = | TextFieldFormItem | TextEditorFormItem | UploadFilesFormItem - | LinksFormItem; + | LinksFormItem + | TextFieldFormItems; diff --git a/src/pages/commonCreation/components/ProjectCreation/components/ProjectCreationForm/ProjectCreationForm.tsx b/src/pages/commonCreation/components/ProjectCreation/components/ProjectCreationForm/ProjectCreationForm.tsx index dfe07cfd45..23b3f18b79 100644 --- a/src/pages/commonCreation/components/ProjectCreation/components/ProjectCreationForm/ProjectCreationForm.tsx +++ b/src/pages/commonCreation/components/ProjectCreation/components/ProjectCreationForm/ProjectCreationForm.tsx @@ -167,7 +167,9 @@ const ProjectCreationForm: FC = (props) => { ref={formRef} initialValues={initialValues} onSubmit={isEditing ? handleProjectUpdate : handleProjectCreate} - items={getConfiguration(true, { existingNames: existingProjectsNames })} + items={getConfiguration(true, [], { + existingNames: existingProjectsNames, + })} submitButtonText={isEditing ? "Save changes" : "Create Space"} disabled={isLoading} error={error} diff --git a/src/pages/commonCreation/components/ProjectCreation/components/ProjectCreationForm/configuration.ts b/src/pages/commonCreation/components/ProjectCreation/components/ProjectCreationForm/configuration.ts index 334f4411a6..a5f0752962 100644 --- a/src/pages/commonCreation/components/ProjectCreation/components/ProjectCreationForm/configuration.ts +++ b/src/pages/commonCreation/components/ProjectCreation/components/ProjectCreationForm/configuration.ts @@ -9,11 +9,12 @@ import styles from "./ProjectCreationForm.module.scss"; export const getConfiguration = ( isProject = true, + roles?: string[], shouldBeUnique?: { existingNames: string[] }, ): CreationFormItem[] => { const type = isProject ? "Space" : "Common"; - return [ + const items: CreationFormItem[] = [ { type: CreationFormItemType.UploadFiles, className: styles.projectImages, @@ -105,4 +106,18 @@ export const getConfiguration = ( }, }, ]; + + if (roles) { + items.push({ + type: CreationFormItemType.TextFieldArray, + props: { + id: "roles", + name: "roles", + label: "Roles", + }, + values: roles, + }); + } + + return items; }; diff --git a/src/pages/commonCreation/hooks/useCommonForm.ts b/src/pages/commonCreation/hooks/useCommonForm.ts index 43ac391f85..885e4dd58c 100644 --- a/src/pages/commonCreation/hooks/useCommonForm.ts +++ b/src/pages/commonCreation/hooks/useCommonForm.ts @@ -17,8 +17,10 @@ interface Return { onSubmit: (values: CommonFormValues) => void; } -const CONFIGURATION: CreationFormItem[] = getConfiguration(false); -const getInitialValues = (common?: Common): CommonFormValues => { +const getInitialValues = ( + common?: Common, + roles?: string[], +): CommonFormValues => { return { projectImages: common?.image ? [ @@ -35,6 +37,7 @@ const getInitialValues = (common?: Common): CommonFormValues => { videoUrl: common?.video?.value || "", gallery: common?.gallery ? convertLinksToUploadFiles(common.gallery) : [], links: common?.links || [], + roles: roles || [], }; }; @@ -43,6 +46,7 @@ export const useCommonForm = ( commonData: IntermediateUpdateCommonData | IntermediateCreateCommonData, ) => Promise, common?: Common, + roles?: string[], ): Return => { const dispatch = useDispatch(); const initialValues: CommonFormValues = useMemo( @@ -75,6 +79,6 @@ export const useCommonForm = ( return { initialValues, onSubmit, - formItems: CONFIGURATION, + formItems: getConfiguration(false, roles), }; }; diff --git a/src/pages/commonEditing/components/Editing/components/EditingForm/EditingForm.tsx b/src/pages/commonEditing/components/Editing/components/EditingForm/EditingForm.tsx index 8e97c0ee95..8b308e5b2c 100644 --- a/src/pages/commonEditing/components/Editing/components/EditingForm/EditingForm.tsx +++ b/src/pages/commonEditing/components/Editing/components/EditingForm/EditingForm.tsx @@ -1,4 +1,4 @@ -import React, { FC, useCallback, useEffect, useRef } from "react"; +import React, { FC, useCallback, useEffect, useMemo, useRef } from "react"; import { useCommonUpdate } from "@/pages/OldCommon/components/CommonListContainer/EditCommonModal/useCases"; import { generateCreationForm, @@ -9,8 +9,10 @@ import { CommonFormValues } from "@/pages/commonCreation/components/CommonCreati import { styles } from "@/pages/commonCreation/components/ProjectCreation/components/ProjectCreationForm"; import { useCommonForm } from "@/pages/commonCreation/hooks"; import { usePreventReload } from "@/shared/hooks"; +import { useGovernance } from "@/shared/hooks/useCases"; import { Common } from "@/shared/models"; import { Loader, LoaderVariant } from "@/shared/ui-kit"; +import { removeProjectCircles } from "@/shared/utils"; const CreationForm = generateCreationForm(); @@ -23,6 +25,15 @@ interface EditingFormProps { const EditingForm: FC = (props) => { const { common, onFinish, onCancel } = props; const formRef = useRef(null); + const { + data: governance, + fetched: isGovernanceFetched, + fetchGovernance, + } = useGovernance(); + const governanceCircles = useMemo( + () => removeProjectCircles(Object.values(governance?.circles || {})), + [governance?.circles], + ); const { isCommonUpdateLoading: isLoading, common: updatedCommon, @@ -32,8 +43,15 @@ const EditingForm: FC = (props) => { const { initialValues, formItems, onSubmit } = useCommonForm( updateCommon, common, + governanceCircles.map((circle) => circle.name), ); + useEffect(() => { + if (common.governanceId) { + fetchGovernance(common.governanceId); + } + }, [common.governanceId]); + const shouldPreventReload = useCallback( () => (!updatedCommon && formRef.current?.isDirty()) ?? true, [formRef, updatedCommon], diff --git a/src/shared/components/Form/Formik/TextField/TextField.tsx b/src/shared/components/Form/Formik/TextField/TextField.tsx index 9e9419fe03..51819ec380 100644 --- a/src/shared/components/Form/Formik/TextField/TextField.tsx +++ b/src/shared/components/Form/Formik/TextField/TextField.tsx @@ -4,10 +4,11 @@ import { Input, InputProps } from "../../Input"; export type TextFieldProps = InputProps & { isRequired?: boolean; + value?: string; }; const TextField: FC = (props) => { - const { isRequired, ...restProps } = props; + const { isRequired, value, ...restProps } = props; const [field, { touched, error }] = useField(restProps); const hintToShow = restProps.hint || (isRequired ? "Required" : ""); @@ -17,6 +18,7 @@ const TextField: FC = (props) => { {...field} hint={hintToShow} error={touched ? error : ""} + value={value} /> ); }; diff --git a/src/shared/constants/endpoint.ts b/src/shared/constants/endpoint.ts index 88af6d488c..b15ee3226b 100644 --- a/src/shared/constants/endpoint.ts +++ b/src/shared/constants/endpoint.ts @@ -1,6 +1,7 @@ export const ApiEndpoint = { GovernanceCreate: "/governance/create", GovernanceUpdateRules: "/governance/updateRules", + GovernanceUpdateCircleName: "/governance/circle-name", AddFounderToMembers: "/commons/add-founder-to-members", CreateCommon: "/commons/create", UpdateCommon: "/commons/update", diff --git a/src/shared/interfaces/CreateProjectPayload.ts b/src/shared/interfaces/CreateProjectPayload.ts index 3ec742cdcc..525f072c47 100644 --- a/src/shared/interfaces/CreateProjectPayload.ts +++ b/src/shared/interfaces/CreateProjectPayload.ts @@ -23,5 +23,6 @@ export interface IntermediateCreateProjectPayload { videoUrl: string; gallery: UploadFile[]; links?: CommonLink[]; + roles?: string[]; highestCircleId: string; } From c4f7e34619eb54b34f7f8b29bbc1a0be97cada69 Mon Sep 17 00:00:00 2001 From: Roie Natan Date: Mon, 18 Sep 2023 12:59:10 +0300 Subject: [PATCH 02/12] init 2 --- .../CreationForm/components/Item/Item.tsx | 30 ++---- .../constants/creationFormItemType.ts | 2 +- .../components/CreationForm/types.ts | 8 +- .../ProjectCreationForm/configuration.ts | 9 +- .../commonCreation/hooks/useCommonForm.ts | 4 +- .../components/EditingForm/EditingForm.tsx | 2 + .../Form/Formik/RolesArray/RolesArray.tsx | 95 +++++++++++++++++++ .../Form/Formik/RolesArray/index.ts | 2 + .../RolesArrayWrapper/RolesArrayWrapper.tsx | 21 ++++ .../Form/Formik/RolesArrayWrapper/index.ts | 2 + src/shared/components/Form/Formik/index.ts | 2 + 11 files changed, 147 insertions(+), 30 deletions(-) create mode 100644 src/shared/components/Form/Formik/RolesArray/RolesArray.tsx create mode 100644 src/shared/components/Form/Formik/RolesArray/index.ts create mode 100644 src/shared/components/Form/Formik/RolesArrayWrapper/RolesArrayWrapper.tsx create mode 100644 src/shared/components/Form/Formik/RolesArrayWrapper/index.ts diff --git a/src/pages/commonCreation/components/CreationForm/components/Item/Item.tsx b/src/pages/commonCreation/components/CreationForm/components/Item/Item.tsx index 434504355d..4af03c72f5 100644 --- a/src/pages/commonCreation/components/CreationForm/components/Item/Item.tsx +++ b/src/pages/commonCreation/components/CreationForm/components/Item/Item.tsx @@ -1,11 +1,11 @@ import React, { FC } from "react"; import classNames from "classnames"; -import { FieldArray } from "formik"; import { LinksArrayWrapper, TextEditor, TextField, UploadFiles, + RolesArrayWrapper, } from "@/shared/components/Form/Formik"; import { CreationFormItemType } from "../../constants"; import { CreationFormItem } from "../../types"; @@ -67,26 +67,16 @@ const Item: FC = (props) => { disabled={disabled ?? item.props.disabled} /> ); - case CreationFormItemType.TextFieldArray: - console.log(item); - + case CreationFormItemType.Roles: return ( - <> - - item.values.map((role, index) => ( - - )) - } - /> - + ); default: return null; diff --git a/src/pages/commonCreation/components/CreationForm/constants/creationFormItemType.ts b/src/pages/commonCreation/components/CreationForm/constants/creationFormItemType.ts index c1cc4b724a..68613e563c 100644 --- a/src/pages/commonCreation/components/CreationForm/constants/creationFormItemType.ts +++ b/src/pages/commonCreation/components/CreationForm/constants/creationFormItemType.ts @@ -3,5 +3,5 @@ export enum CreationFormItemType { TextEditor = "TextEditor", UploadFiles = "UploadFiles", Links = "Links", - TextFieldArray = "TextFieldArray", + Roles = "Roles", } diff --git a/src/pages/commonCreation/components/CreationForm/types.ts b/src/pages/commonCreation/components/CreationForm/types.ts index e03c97f8a1..8f5bfc9430 100644 --- a/src/pages/commonCreation/components/CreationForm/types.ts +++ b/src/pages/commonCreation/components/CreationForm/types.ts @@ -3,6 +3,7 @@ import { TextFieldProps, TextEditorProps, UploadFilesProps, + RolesArrayWrapperProps, } from "@/shared/components/Form/Formik"; import { CreationFormItemType } from "./constants"; @@ -55,9 +56,8 @@ export interface LinksFormItem extends BaseFormItem { validation?: Pick; } -export interface TextFieldFormItems extends BaseFormItem { - type: CreationFormItemType.TextFieldArray; - values: string[]; +export interface RolesFormItems extends BaseFormItem { + type: CreationFormItemType.Roles; } export type CreationFormItem = @@ -65,4 +65,4 @@ export type CreationFormItem = | TextEditorFormItem | UploadFilesFormItem | LinksFormItem - | TextFieldFormItems; + | RolesFormItems; diff --git a/src/pages/commonCreation/components/ProjectCreation/components/ProjectCreationForm/configuration.ts b/src/pages/commonCreation/components/ProjectCreation/components/ProjectCreationForm/configuration.ts index a5f0752962..81153c8b3b 100644 --- a/src/pages/commonCreation/components/ProjectCreation/components/ProjectCreationForm/configuration.ts +++ b/src/pages/commonCreation/components/ProjectCreation/components/ProjectCreationForm/configuration.ts @@ -107,15 +107,16 @@ export const getConfiguration = ( }, ]; + console.log(roles); + if (roles) { items.push({ - type: CreationFormItemType.TextFieldArray, + type: CreationFormItemType.Roles, props: { - id: "roles", name: "roles", - label: "Roles", + title: "Roles", + maxTitleLength: MAX_LINK_TITLE_LENGTH, }, - values: roles, }); } diff --git a/src/pages/commonCreation/hooks/useCommonForm.ts b/src/pages/commonCreation/hooks/useCommonForm.ts index 885e4dd58c..5a7d408e92 100644 --- a/src/pages/commonCreation/hooks/useCommonForm.ts +++ b/src/pages/commonCreation/hooks/useCommonForm.ts @@ -50,10 +50,12 @@ export const useCommonForm = ( ): Return => { const dispatch = useDispatch(); const initialValues: CommonFormValues = useMemo( - () => getInitialValues(common), + () => getInitialValues(common, roles), [], ); + console.log(initialValues); + useEffect(() => { dispatch(projectsActions.setIsCommonCreationDisabled(true)); diff --git a/src/pages/commonEditing/components/Editing/components/EditingForm/EditingForm.tsx b/src/pages/commonEditing/components/Editing/components/EditingForm/EditingForm.tsx index 8b308e5b2c..84de86b853 100644 --- a/src/pages/commonEditing/components/Editing/components/EditingForm/EditingForm.tsx +++ b/src/pages/commonEditing/components/Editing/components/EditingForm/EditingForm.tsx @@ -46,6 +46,8 @@ const EditingForm: FC = (props) => { governanceCircles.map((circle) => circle.name), ); + console.log(initialValues); + useEffect(() => { if (common.governanceId) { fetchGovernance(common.governanceId); diff --git a/src/shared/components/Form/Formik/RolesArray/RolesArray.tsx b/src/shared/components/Form/Formik/RolesArray/RolesArray.tsx new file mode 100644 index 0000000000..85db09ee88 --- /dev/null +++ b/src/shared/components/Form/Formik/RolesArray/RolesArray.tsx @@ -0,0 +1,95 @@ +import React, { FC } from "react"; +import { FieldArray, FieldArrayConfig, FormikErrors } from "formik"; +import { ErrorText } from "../../ErrorText"; +import { TextField } from "../TextField"; + +type Errors = string | string[] | FormikErrors | undefined; + +export interface RolesArrayProps extends FieldArrayConfig { + values: string[]; + errors?: Errors; + title?: string; + maxTitleLength?: number; + className?: string; + itemClassName?: string; + labelClassName?: string; + disabled?: boolean; +} + +const RolesArray: FC = (props) => { + const { + values, + errors, + title = "Add links", + maxTitleLength, + className, + itemClassName, + labelClassName, + disabled, + ...restProps + } = props; + + console.log(values); + + return ( + { + //className={classNames("links-array", className)} + return ( +
+ {values.map((value, index) => { + // const titleError = isTouched(touched, index, "title") + // ? getInputError(errors, index, "title") + // : ""; + // const valueError = isTouched(touched, index, "value") + // ? getInputError(errors, index, "value") + // : ""; + // const error = titleError || valueError; + // const shouldDisplayDeleteButton = values.length > 1; + + return ( + + + //
+ // + + // {/* {error && {error}} */} + //
+ ); + })} +
+ ); + }} + /> + ); +}; + +export default RolesArray; diff --git a/src/shared/components/Form/Formik/RolesArray/index.ts b/src/shared/components/Form/Formik/RolesArray/index.ts new file mode 100644 index 0000000000..ed73b3339f --- /dev/null +++ b/src/shared/components/Form/Formik/RolesArray/index.ts @@ -0,0 +1,2 @@ +export { default as RolesArray } from "./RolesArray"; +export type { RolesArrayProps } from "./RolesArray"; diff --git a/src/shared/components/Form/Formik/RolesArrayWrapper/RolesArrayWrapper.tsx b/src/shared/components/Form/Formik/RolesArrayWrapper/RolesArrayWrapper.tsx new file mode 100644 index 0000000000..56760cbc7d --- /dev/null +++ b/src/shared/components/Form/Formik/RolesArrayWrapper/RolesArrayWrapper.tsx @@ -0,0 +1,21 @@ +import React, { FC } from "react"; +import { useField, useFormikContext } from "formik"; +import { FormikTouched } from "formik/dist/types"; +import { RolesArray, RolesArrayProps } from "../RolesArray"; + +export type RolesArrayWrapperProps = Omit< + RolesArrayProps, + "values" | "errors" | "touched" +>; + +const RolesArrayWrapper: FC = (props) => { + const [{ value }, { error }] = useField(props.name); + const formik = useFormikContext(); + + console.log(props); + console.log(value); + + return ; +}; + +export default RolesArrayWrapper; diff --git a/src/shared/components/Form/Formik/RolesArrayWrapper/index.ts b/src/shared/components/Form/Formik/RolesArrayWrapper/index.ts new file mode 100644 index 0000000000..f67d222576 --- /dev/null +++ b/src/shared/components/Form/Formik/RolesArrayWrapper/index.ts @@ -0,0 +1,2 @@ +export { default as RolesArrayWrapper } from "./RolesArrayWrapper"; +export type { RolesArrayWrapperProps } from "./RolesArrayWrapper"; diff --git a/src/shared/components/Form/Formik/index.ts b/src/shared/components/Form/Formik/index.ts index 53ded76afd..b70334a696 100644 --- a/src/shared/components/Form/Formik/index.ts +++ b/src/shared/components/Form/Formik/index.ts @@ -10,3 +10,5 @@ export * from "./ToggleButtonGroup"; export * from "./TextEditor"; export * from "./TextField"; export * from "./UploadFiles"; +export * from "./RolesArray"; +export * from "./RolesArrayWrapper"; From a98cf3a9a47b92a82513765279c08d2e59f90620 Mon Sep 17 00:00:00 2001 From: Roie Natan Date: Mon, 18 Sep 2023 16:37:09 +0300 Subject: [PATCH 03/12] init 3 --- .../components/CreationForm/CreationForm.tsx | 1 + .../CreationForm/components/Item/Item.tsx | 1 + .../components/CreationForm/types.ts | 5 +- .../ProjectCreationForm/configuration.ts | 15 +++- .../ProjectCreation/constants/form.ts | 1 + .../commonCreation/hooks/useCommonForm.ts | 4 +- .../components/EditingForm/EditingForm.tsx | 4 +- .../Formik/RolesArray/RolesArray.module.scss | 3 + .../Form/Formik/RolesArray/RolesArray.tsx | 73 ++++++------------- .../RolesArrayWrapper/RolesArrayWrapper.tsx | 12 ++- 10 files changed, 54 insertions(+), 65 deletions(-) create mode 100644 src/shared/components/Form/Formik/RolesArray/RolesArray.module.scss diff --git a/src/pages/commonCreation/components/CreationForm/CreationForm.tsx b/src/pages/commonCreation/components/CreationForm/CreationForm.tsx index 626d32d275..1a76bc9193 100644 --- a/src/pages/commonCreation/components/CreationForm/CreationForm.tsx +++ b/src/pages/commonCreation/components/CreationForm/CreationForm.tsx @@ -62,6 +62,7 @@ const CreationForm = ( validationSchema={validationSchema} onSubmit={onSubmit} validateOnMount + enableReinitialize >
diff --git a/src/pages/commonCreation/components/CreationForm/components/Item/Item.tsx b/src/pages/commonCreation/components/CreationForm/components/Item/Item.tsx index 4af03c72f5..c829a54160 100644 --- a/src/pages/commonCreation/components/CreationForm/components/Item/Item.tsx +++ b/src/pages/commonCreation/components/CreationForm/components/Item/Item.tsx @@ -76,6 +76,7 @@ const Item: FC = (props) => { styles.linksArrayWrapperLabel, item.props.labelClassName, )} + disabled={disabled ?? item.props.disabled} /> ); default: diff --git a/src/pages/commonCreation/components/CreationForm/types.ts b/src/pages/commonCreation/components/CreationForm/types.ts index 8f5bfc9430..1e21bb0713 100644 --- a/src/pages/commonCreation/components/CreationForm/types.ts +++ b/src/pages/commonCreation/components/CreationForm/types.ts @@ -56,8 +56,9 @@ export interface LinksFormItem extends BaseFormItem { validation?: Pick; } -export interface RolesFormItems extends BaseFormItem { +export interface RolesFormItem extends BaseFormItem { type: CreationFormItemType.Roles; + validation?: Pick; } export type CreationFormItem = @@ -65,4 +66,4 @@ export type CreationFormItem = | TextEditorFormItem | UploadFilesFormItem | LinksFormItem - | RolesFormItems; + | RolesFormItem; diff --git a/src/pages/commonCreation/components/ProjectCreation/components/ProjectCreationForm/configuration.ts b/src/pages/commonCreation/components/ProjectCreation/components/ProjectCreationForm/configuration.ts index 81153c8b3b..bc4890e79e 100644 --- a/src/pages/commonCreation/components/ProjectCreation/components/ProjectCreationForm/configuration.ts +++ b/src/pages/commonCreation/components/ProjectCreation/components/ProjectCreationForm/configuration.ts @@ -4,6 +4,7 @@ import { MAX_LINK_TITLE_LENGTH, MAX_PROJECT_NAME_LENGTH, MAX_PROJECT_TAGLINE_LENGTH, + MAX_ROLE_TITLE_LENGTH, } from "../../constants"; import styles from "./ProjectCreationForm.module.scss"; @@ -107,15 +108,23 @@ export const getConfiguration = ( }, ]; - console.log(roles); - if (roles) { items.push({ type: CreationFormItemType.Roles, props: { name: "roles", title: "Roles", - maxTitleLength: MAX_LINK_TITLE_LENGTH, + maxTitleLength: MAX_ROLE_TITLE_LENGTH, + }, + validation: { + required: { + value: true, + message: "Role title required", + }, + max: { + value: MAX_ROLE_TITLE_LENGTH, + message: "Role title is too long", + }, }, }); } diff --git a/src/pages/commonCreation/components/ProjectCreation/constants/form.ts b/src/pages/commonCreation/components/ProjectCreation/constants/form.ts index d9ae7c8c75..156c70e4e3 100644 --- a/src/pages/commonCreation/components/ProjectCreation/constants/form.ts +++ b/src/pages/commonCreation/components/ProjectCreation/constants/form.ts @@ -1,3 +1,4 @@ export const MAX_PROJECT_NAME_LENGTH = 20; export const MAX_PROJECT_TAGLINE_LENGTH = 40; export const MAX_LINK_TITLE_LENGTH = 30; +export const MAX_ROLE_TITLE_LENGTH = 25; diff --git a/src/pages/commonCreation/hooks/useCommonForm.ts b/src/pages/commonCreation/hooks/useCommonForm.ts index 5a7d408e92..199b075de2 100644 --- a/src/pages/commonCreation/hooks/useCommonForm.ts +++ b/src/pages/commonCreation/hooks/useCommonForm.ts @@ -51,11 +51,9 @@ export const useCommonForm = ( const dispatch = useDispatch(); const initialValues: CommonFormValues = useMemo( () => getInitialValues(common, roles), - [], + [common, roles], ); - console.log(initialValues); - useEffect(() => { dispatch(projectsActions.setIsCommonCreationDisabled(true)); diff --git a/src/pages/commonEditing/components/Editing/components/EditingForm/EditingForm.tsx b/src/pages/commonEditing/components/Editing/components/EditingForm/EditingForm.tsx index 84de86b853..facc38fe6f 100644 --- a/src/pages/commonEditing/components/Editing/components/EditingForm/EditingForm.tsx +++ b/src/pages/commonEditing/components/Editing/components/EditingForm/EditingForm.tsx @@ -46,8 +46,6 @@ const EditingForm: FC = (props) => { governanceCircles.map((circle) => circle.name), ); - console.log(initialValues); - useEffect(() => { if (common.governanceId) { fetchGovernance(common.governanceId); @@ -78,7 +76,7 @@ const EditingForm: FC = (props) => { return ( <> - {isLoading && ( + {(isLoading || !isGovernanceFetched) && ( | undefined; +type Touched = FormikTouched[] | undefined; export interface RolesArrayProps extends FieldArrayConfig { values: string[]; - errors?: Errors; + errors: Errors; + touched: Touched; title?: string; maxTitleLength?: number; className?: string; @@ -20,7 +28,7 @@ const RolesArray: FC = (props) => { const { values, errors, - title = "Add links", + title, maxTitleLength, className, itemClassName, @@ -29,60 +37,25 @@ const RolesArray: FC = (props) => { ...restProps } = props; - console.log(values); - return ( { - //className={classNames("links-array", className)} return (
- {values.map((value, index) => { - // const titleError = isTouched(touched, index, "title") - // ? getInputError(errors, index, "title") - // : ""; - // const valueError = isTouched(touched, index, "value") - // ? getInputError(errors, index, "value") - // : ""; - // const error = titleError || valueError; - // const shouldDisplayDeleteButton = values.length > 1; - + {values?.map((value, index) => { return ( - - - //
- // - - // {/* {error && {error}} */} - //
+
+ + {!value && Error} +
); })}
diff --git a/src/shared/components/Form/Formik/RolesArrayWrapper/RolesArrayWrapper.tsx b/src/shared/components/Form/Formik/RolesArrayWrapper/RolesArrayWrapper.tsx index 56760cbc7d..58699e4529 100644 --- a/src/shared/components/Form/Formik/RolesArrayWrapper/RolesArrayWrapper.tsx +++ b/src/shared/components/Form/Formik/RolesArrayWrapper/RolesArrayWrapper.tsx @@ -12,10 +12,14 @@ const RolesArrayWrapper: FC = (props) => { const [{ value }, { error }] = useField(props.name); const formik = useFormikContext(); - console.log(props); - console.log(value); - - return ; + return ( + []} + /> + ); }; export default RolesArrayWrapper; From b4851b6162d59001f057ba5603c245ac55057f40 Mon Sep 17 00:00:00 2001 From: Roie Natan Date: Tue, 19 Sep 2023 10:58:00 +0300 Subject: [PATCH 04/12] pass Roles interface to RolesArray and to useCommonUpdate --- .../EditCommonModal/useCases/useCommonUpdate.ts | 2 ++ .../OldCommon/interfaces/CreateCommonPayload.ts | 3 ++- .../components/ProjectCreationForm/configuration.ts | 3 ++- src/pages/commonCreation/hooks/useCommonForm.ts | 9 +++------ .../Editing/components/EditingForm/EditingForm.tsx | 8 ++++++-- .../Form/Formik/RolesArray/RolesArray.tsx | 13 +++++++------ .../Formik/RolesArrayWrapper/RolesArrayWrapper.tsx | 3 ++- src/shared/interfaces/CreateProjectPayload.ts | 4 ++-- src/shared/models/governance/Roles.ts | 6 ++++++ src/shared/models/governance/index.ts | 1 + 10 files changed, 33 insertions(+), 19 deletions(-) create mode 100644 src/shared/models/governance/Roles.ts diff --git a/src/pages/OldCommon/components/CommonListContainer/EditCommonModal/useCases/useCommonUpdate.ts b/src/pages/OldCommon/components/CommonListContainer/EditCommonModal/useCases/useCommonUpdate.ts index 86b7145bc7..37b27828e2 100644 --- a/src/pages/OldCommon/components/CommonListContainer/EditCommonModal/useCases/useCommonUpdate.ts +++ b/src/pages/OldCommon/components/CommonListContainer/EditCommonModal/useCases/useCommonUpdate.ts @@ -61,6 +61,8 @@ const useCommonUpdate = (commonId?: string): Return => { return; } + console.log(updatedData); + setIsCommonUpdateLoading(true); try { diff --git a/src/pages/OldCommon/interfaces/CreateCommonPayload.ts b/src/pages/OldCommon/interfaces/CreateCommonPayload.ts index c76cdb0924..b23d19dc16 100644 --- a/src/pages/OldCommon/interfaces/CreateCommonPayload.ts +++ b/src/pages/OldCommon/interfaces/CreateCommonPayload.ts @@ -1,5 +1,5 @@ import { UploadFile } from "@/shared/interfaces"; -import { BaseRule, CommonLink } from "@/shared/models"; +import { BaseRule, CommonLink, Roles } from "@/shared/models"; import { MemberAdmittanceLimitations } from "@/shared/models/governance/proposals"; import { TextEditorValue } from "@/shared/ui-kit/TextEditor/types"; @@ -58,6 +58,7 @@ export interface IntermediateUpdateCommonData { videoUrl?: string; gallery?: UploadFile[]; links?: CommonLink[]; + roles?: Roles; } export interface UpdateCommonData { diff --git a/src/pages/commonCreation/components/ProjectCreation/components/ProjectCreationForm/configuration.ts b/src/pages/commonCreation/components/ProjectCreation/components/ProjectCreationForm/configuration.ts index bc4890e79e..1596cd12ff 100644 --- a/src/pages/commonCreation/components/ProjectCreation/components/ProjectCreationForm/configuration.ts +++ b/src/pages/commonCreation/components/ProjectCreation/components/ProjectCreationForm/configuration.ts @@ -1,3 +1,4 @@ +import { Roles } from "@/shared/models"; import { TextEditorSize } from "@/shared/ui-kit"; import { CreationFormItem, CreationFormItemType } from "../../../CreationForm"; import { @@ -10,7 +11,7 @@ import styles from "./ProjectCreationForm.module.scss"; export const getConfiguration = ( isProject = true, - roles?: string[], + roles?: Roles, shouldBeUnique?: { existingNames: string[] }, ): CreationFormItem[] => { const type = isProject ? "Space" : "Common"; diff --git a/src/pages/commonCreation/hooks/useCommonForm.ts b/src/pages/commonCreation/hooks/useCommonForm.ts index 199b075de2..18ed453a27 100644 --- a/src/pages/commonCreation/hooks/useCommonForm.ts +++ b/src/pages/commonCreation/hooks/useCommonForm.ts @@ -4,7 +4,7 @@ import { IntermediateCreateCommonData, IntermediateUpdateCommonData, } from "@/pages/OldCommon/interfaces"; -import { Common } from "@/shared/models"; +import { Common, Roles } from "@/shared/models"; import { parseStringToTextEditorValue } from "@/shared/ui-kit"; import { convertLinksToUploadFiles } from "@/shared/utils"; import { projectsActions } from "@/store/states"; @@ -17,10 +17,7 @@ interface Return { onSubmit: (values: CommonFormValues) => void; } -const getInitialValues = ( - common?: Common, - roles?: string[], -): CommonFormValues => { +const getInitialValues = (common?: Common, roles?: Roles): CommonFormValues => { return { projectImages: common?.image ? [ @@ -46,7 +43,7 @@ export const useCommonForm = ( commonData: IntermediateUpdateCommonData | IntermediateCreateCommonData, ) => Promise, common?: Common, - roles?: string[], + roles?: Roles, ): Return => { const dispatch = useDispatch(); const initialValues: CommonFormValues = useMemo( diff --git a/src/pages/commonEditing/components/Editing/components/EditingForm/EditingForm.tsx b/src/pages/commonEditing/components/Editing/components/EditingForm/EditingForm.tsx index facc38fe6f..916da92529 100644 --- a/src/pages/commonEditing/components/Editing/components/EditingForm/EditingForm.tsx +++ b/src/pages/commonEditing/components/Editing/components/EditingForm/EditingForm.tsx @@ -10,7 +10,7 @@ import { styles } from "@/pages/commonCreation/components/ProjectCreation/compon import { useCommonForm } from "@/pages/commonCreation/hooks"; import { usePreventReload } from "@/shared/hooks"; import { useGovernance } from "@/shared/hooks/useCases"; -import { Common } from "@/shared/models"; +import { Common, Roles } from "@/shared/models"; import { Loader, LoaderVariant } from "@/shared/ui-kit"; import { removeProjectCircles } from "@/shared/utils"; @@ -40,10 +40,14 @@ const EditingForm: FC = (props) => { error, updateCommon, } = useCommonUpdate(common.id); + const roles: Roles = governanceCircles.map((circle) => ({ + circleId: circle.id, + circleName: circle.name, + })); const { initialValues, formItems, onSubmit } = useCommonForm( updateCommon, common, - governanceCircles.map((circle) => circle.name), + roles, ); useEffect(() => { diff --git a/src/shared/components/Form/Formik/RolesArray/RolesArray.tsx b/src/shared/components/Form/Formik/RolesArray/RolesArray.tsx index cf3e4298b5..cb1adabfc4 100644 --- a/src/shared/components/Form/Formik/RolesArray/RolesArray.tsx +++ b/src/shared/components/Form/Formik/RolesArray/RolesArray.tsx @@ -5,6 +5,7 @@ import { FormikErrors, FormikTouched, } from "formik"; +import { Roles } from "@/shared/models"; import { ErrorText } from "../../ErrorText"; import { TextField } from "../TextField"; import styles from "./RolesArray.module.scss"; @@ -13,7 +14,7 @@ type Errors = string | string[] | FormikErrors | undefined; type Touched = FormikTouched[] | undefined; export interface RolesArrayProps extends FieldArrayConfig { - values: string[]; + values: Roles; errors: Errors; touched: Touched; title?: string; @@ -43,18 +44,18 @@ const RolesArray: FC = (props) => { render={() => { return (
- {values?.map((value, index) => { + {values?.map((role, index) => { return (
- {!value && Error} + {!role && Error}
); })} diff --git a/src/shared/components/Form/Formik/RolesArrayWrapper/RolesArrayWrapper.tsx b/src/shared/components/Form/Formik/RolesArrayWrapper/RolesArrayWrapper.tsx index 58699e4529..927c672a0a 100644 --- a/src/shared/components/Form/Formik/RolesArrayWrapper/RolesArrayWrapper.tsx +++ b/src/shared/components/Form/Formik/RolesArrayWrapper/RolesArrayWrapper.tsx @@ -1,6 +1,7 @@ import React, { FC } from "react"; import { useField, useFormikContext } from "formik"; import { FormikTouched } from "formik/dist/types"; +import { Roles } from "@/shared/models"; import { RolesArray, RolesArrayProps } from "../RolesArray"; export type RolesArrayWrapperProps = Omit< @@ -9,7 +10,7 @@ export type RolesArrayWrapperProps = Omit< >; const RolesArrayWrapper: FC = (props) => { - const [{ value }, { error }] = useField(props.name); + const [{ value }, { error }] = useField(props.name); const formik = useFormikContext(); return ( diff --git a/src/shared/interfaces/CreateProjectPayload.ts b/src/shared/interfaces/CreateProjectPayload.ts index 525f072c47..42645c695a 100644 --- a/src/shared/interfaces/CreateProjectPayload.ts +++ b/src/shared/interfaces/CreateProjectPayload.ts @@ -1,4 +1,4 @@ -import { BaseRule, CommonLink } from "@/shared/models"; +import { BaseRule, CommonLink, Roles } from "@/shared/models"; import { TextEditorValue } from "@/shared/ui-kit"; import { UploadFile } from "./UploadFile"; @@ -23,6 +23,6 @@ export interface IntermediateCreateProjectPayload { videoUrl: string; gallery: UploadFile[]; links?: CommonLink[]; - roles?: string[]; + roles?: Roles; highestCircleId: string; } diff --git a/src/shared/models/governance/Roles.ts b/src/shared/models/governance/Roles.ts new file mode 100644 index 0000000000..2f865f82b6 --- /dev/null +++ b/src/shared/models/governance/Roles.ts @@ -0,0 +1,6 @@ +export interface Role { + circleId: string; + circleName: string; +} + +export type Roles = Role[]; diff --git a/src/shared/models/governance/index.ts b/src/shared/models/governance/index.ts index 5e319273b2..704e07bd24 100644 --- a/src/shared/models/governance/index.ts +++ b/src/shared/models/governance/index.ts @@ -1,3 +1,4 @@ export * from "./Circles"; export * from "./Governance"; export * from "./UnstructuredRules"; +export * from "./Roles"; From b5e58ef4273970d1e5f6d4e8c9478870711b948e Mon Sep 17 00:00:00 2001 From: Roie Natan Date: Wed, 20 Sep 2023 16:43:36 +0300 Subject: [PATCH 05/12] call governance/space-name --- .../useCases/useCommonUpdate.ts | 33 ++++++++++++++++--- .../interfaces/UpdateGovernanceCircleName.ts | 8 +++-- src/pages/OldCommon/store/actions.tsx | 14 ++++++++ src/pages/OldCommon/store/constants.tsx | 4 +++ src/pages/OldCommon/store/saga.tsx | 29 ++++++++++++++++ .../components/CreationForm/types.ts | 2 +- .../utils/generateValidationSchema.ts | 4 +++ .../ProjectCreationForm/configuration.ts | 6 +--- .../Form/Formik/RolesArray/RolesArray.tsx | 6 ++-- .../RolesArrayWrapper/RolesArrayWrapper.tsx | 2 +- 10 files changed, 92 insertions(+), 16 deletions(-) diff --git a/src/pages/OldCommon/components/CommonListContainer/EditCommonModal/useCases/useCommonUpdate.ts b/src/pages/OldCommon/components/CommonListContainer/EditCommonModal/useCases/useCommonUpdate.ts index 37b27828e2..175f55326c 100644 --- a/src/pages/OldCommon/components/CommonListContainer/EditCommonModal/useCases/useCommonUpdate.ts +++ b/src/pages/OldCommon/components/CommonListContainer/EditCommonModal/useCases/useCommonUpdate.ts @@ -1,5 +1,7 @@ import { useCallback, useState } from "react"; -import { useDispatch } from "react-redux"; +import { useDispatch, useSelector } from "react-redux"; +import { selectUser } from "@/pages/Auth/store/selectors"; +import { UpdateGovernanceCircleNamePayload } from "@/pages/OldCommon/interfaces/UpdateGovernanceCircleName"; import { FileService, Logger } from "@/services"; import { isRequestError } from "@/services/Api"; import { ErrorCode } from "@/shared/constants"; @@ -11,7 +13,10 @@ import { UpdateCommonData, UpdateCommonPayload, } from "../../../../interfaces"; -import { updateCommon as updateCommonAction } from "../../../../store/actions"; +import { + updateCommon as updateCommonAction, + updateGovernanceCircleName, +} from "../../../../store/actions"; interface Return { isCommonUpdateLoading: boolean; @@ -54,6 +59,7 @@ const useCommonUpdate = (commonId?: string): Return => { const [common, setCommon] = useState(null); const [error, setError] = useState(""); const dispatch = useDispatch(); + const user = useSelector(selectUser()); const updateCommon = useCallback( async (updatedData: IntermediateUpdateCommonData) => { @@ -61,8 +67,6 @@ const useCommonUpdate = (commonId?: string): Return => { return; } - console.log(updatedData); - setIsCommonUpdateLoading(true); try { @@ -112,6 +116,27 @@ const useCommonUpdate = (commonId?: string): Return => { }, }), ); + + if (user?.uid && updatedData.roles) { + const circles = updatedData.roles.map((role) => ({ + circleId: role.circleId, + newName: role.circleName, + })); + const payload: UpdateGovernanceCircleNamePayload = { + commonId, + userId: user.uid, + changes: circles, + }; + + dispatch( + updateGovernanceCircleName.request({ + payload, + callback: (error, updatedGovernance) => { + console.log(updatedGovernance); + }, + }), + ); + } } catch (err) { Logger.error(error); setError(getErrorMessage(err, updatedData.name)); diff --git a/src/pages/OldCommon/interfaces/UpdateGovernanceCircleName.ts b/src/pages/OldCommon/interfaces/UpdateGovernanceCircleName.ts index 7fc262088d..128a932ebf 100644 --- a/src/pages/OldCommon/interfaces/UpdateGovernanceCircleName.ts +++ b/src/pages/OldCommon/interfaces/UpdateGovernanceCircleName.ts @@ -1,6 +1,10 @@ +interface NewCircle { + circleId: string; + newName: string; +} + export interface UpdateGovernanceCircleNamePayload { commonId: string; - circleId: string; userId: string; - newName: string; + changes: NewCircle[]; } diff --git a/src/pages/OldCommon/store/actions.tsx b/src/pages/OldCommon/store/actions.tsx index 7cd3e45156..983af2fac1 100644 --- a/src/pages/OldCommon/store/actions.tsx +++ b/src/pages/OldCommon/store/actions.tsx @@ -44,6 +44,7 @@ import { ImmediateContributionResponse, } from "../interfaces"; import { UpdateDiscussionMessageDto } from "../interfaces/UpdateDiscussionMessageDto"; +import { UpdateGovernanceCircleNamePayload } from "../interfaces/UpdateGovernanceCircleName"; import { CommonsActionTypes } from "./constants"; export const createGovernance = createAsyncAction( @@ -369,6 +370,19 @@ export const updateGovernanceRules = createAsyncAction( Error >(); +export const updateGovernanceCircleName = createAsyncAction( + CommonsActionTypes.UPDATE_GOVERNANCE_CIRCLE_NAME, + CommonsActionTypes.UPDATE_GOVERNANCE_CIRCLE_NAME_SUCCESS, + CommonsActionTypes.UPDATE_GOVERNANCE_CIRCLE_NAME_FAILURE, +)< + { + payload: UpdateGovernanceCircleNamePayload; + callback: (error: Error | null, governance?: Governance) => void; + }, + Common, + Error +>(); + export const createVote = createAsyncAction( CommonsActionTypes.CREATE_VOTE, CommonsActionTypes.CREATE_VOTE_SUCCESS, diff --git a/src/pages/OldCommon/store/constants.tsx b/src/pages/OldCommon/store/constants.tsx index 7ab2203521..692a6f377e 100644 --- a/src/pages/OldCommon/store/constants.tsx +++ b/src/pages/OldCommon/store/constants.tsx @@ -214,4 +214,8 @@ export enum CommonsActionTypes { UPDATE_GOVERNANCE_RULES = "@COMMONS/UPDATE_GOVERNANCE_RULES", UPDATE_GOVERNANCE_RULES_SUCCESS = "@COMMONS/UPDATE_GOVERNANCE_RULES_SUCCESS", UPDATE_GOVERNANCE_RULES_FAILURE = "@COMMONS/UPDATE_GOVERNANCE_RULES_FAILURE", + + UPDATE_GOVERNANCE_CIRCLE_NAME = "@COMMONS/UPDATE_GOVERNANCE_CIRCLE_NAME", + UPDATE_GOVERNANCE_CIRCLE_NAME_SUCCESS = "@COMMONS/UPDATE_GOVERNANCE_CIRCLE_NAME_SUCCESS", + UPDATE_GOVERNANCE_CIRCLE_NAME_FAILURE = "@COMMONS/UPDATE_GOVERNANCE_CIRCLE_NAME_FAILURE", } diff --git a/src/pages/OldCommon/store/saga.tsx b/src/pages/OldCommon/store/saga.tsx index b1c51a42fa..1b407893bb 100644 --- a/src/pages/OldCommon/store/saga.tsx +++ b/src/pages/OldCommon/store/saga.tsx @@ -42,6 +42,7 @@ import { createCommon as createCommonApi, updateCommon as updateCommonApi, updateGovernanceRules as updateGovernanceRulesApi, + updateGovernanceCircleName as updateGovernanceCircleNameApi, createProposal as createProposalApi, fetchCommonList, fetchCommonDetail, @@ -1692,6 +1693,30 @@ export function* updateGovernanceRules( } } +export function* updateGovernanceCircleName( + action: ReturnType, +): Generator { + try { + const updatedCircles = (yield call( + updateGovernanceCircleNameApi, + action.payload.payload, + )) as Awaited>; + + console.log(updatedCircles); + // const updatedGovernance = { + // ...action.payload.governance, + // unstructuredRules: updatedRules.unstructuredRules, + // } as Governance; + + // yield put(actions.getGovernance.success(updatedGovernance)); + // action.payload.callback(null, updatedGovernance); + } catch (error) { + if (isError(error)) { + action.payload.callback(error); + } + } +} + export function* commonsSaga() { yield takeLatest(actions.createGovernance.request, createGovernance); yield takeLatest(actions.getCommonsList.request, getCommonsList); @@ -1699,6 +1724,10 @@ export function* commonsSaga() { actions.updateGovernanceRules.request, updateGovernanceRules, ); + yield takeLatest( + actions.updateGovernanceCircleName.request, + updateGovernanceCircleName, + ); yield takeLatest(actions.getCommonsListByIds.request, getCommonsListByIds); yield takeLatest(actions.getCommonDetail.request, getCommonDetail); yield takeLatest( diff --git a/src/pages/commonCreation/components/CreationForm/types.ts b/src/pages/commonCreation/components/CreationForm/types.ts index 1e21bb0713..c86330cd93 100644 --- a/src/pages/commonCreation/components/CreationForm/types.ts +++ b/src/pages/commonCreation/components/CreationForm/types.ts @@ -58,7 +58,7 @@ export interface LinksFormItem extends BaseFormItem { export interface RolesFormItem extends BaseFormItem { type: CreationFormItemType.Roles; - validation?: Pick; + validation?: Pick; } export type CreationFormItem = diff --git a/src/pages/commonCreation/components/CreationForm/utils/generateValidationSchema.ts b/src/pages/commonCreation/components/CreationForm/utils/generateValidationSchema.ts index 46ac024e15..37afe2dde8 100644 --- a/src/pages/commonCreation/components/CreationForm/utils/generateValidationSchema.ts +++ b/src/pages/commonCreation/components/CreationForm/utils/generateValidationSchema.ts @@ -6,6 +6,7 @@ import { LinksFormItem, TextFieldFormItem, UploadFilesFormItem, + RolesFormItem, } from "../types"; type Schema = Yup.Schema; @@ -97,6 +98,9 @@ export const generateValidationSchema = ( if (item.type === CreationFormItemType.Links) { schema = getValidationSchemaForLinksItem(item); } + // if (item.type === CreationFormItemType.Roles) { + // schema = getValidationSchemaForTextFieldItem(item); + // } return schema ? { diff --git a/src/pages/commonCreation/components/ProjectCreation/components/ProjectCreationForm/configuration.ts b/src/pages/commonCreation/components/ProjectCreation/components/ProjectCreationForm/configuration.ts index 1596cd12ff..118bedcf33 100644 --- a/src/pages/commonCreation/components/ProjectCreation/components/ProjectCreationForm/configuration.ts +++ b/src/pages/commonCreation/components/ProjectCreation/components/ProjectCreationForm/configuration.ts @@ -120,11 +120,7 @@ export const getConfiguration = ( validation: { required: { value: true, - message: "Role title required", - }, - max: { - value: MAX_ROLE_TITLE_LENGTH, - message: "Role title is too long", + message: "Role name is required", }, }, }); diff --git a/src/shared/components/Form/Formik/RolesArray/RolesArray.tsx b/src/shared/components/Form/Formik/RolesArray/RolesArray.tsx index cb1adabfc4..03e7e65841 100644 --- a/src/shared/components/Form/Formik/RolesArray/RolesArray.tsx +++ b/src/shared/components/Form/Formik/RolesArray/RolesArray.tsx @@ -5,13 +5,13 @@ import { FormikErrors, FormikTouched, } from "formik"; -import { Roles } from "@/shared/models"; +import { Role, Roles } from "@/shared/models"; import { ErrorText } from "../../ErrorText"; import { TextField } from "../TextField"; import styles from "./RolesArray.module.scss"; type Errors = string | string[] | FormikErrors | undefined; -type Touched = FormikTouched[] | undefined; +type Touched = FormikTouched[] | undefined; export interface RolesArrayProps extends FieldArrayConfig { values: Roles; @@ -55,7 +55,7 @@ const RolesArray: FC = (props) => { value={role.circleName} placeholder="Role title" /> - {!role && Error} + {/* {errors && {errors}} */}
); })} diff --git a/src/shared/components/Form/Formik/RolesArrayWrapper/RolesArrayWrapper.tsx b/src/shared/components/Form/Formik/RolesArrayWrapper/RolesArrayWrapper.tsx index 927c672a0a..e2f0176924 100644 --- a/src/shared/components/Form/Formik/RolesArrayWrapper/RolesArrayWrapper.tsx +++ b/src/shared/components/Form/Formik/RolesArrayWrapper/RolesArrayWrapper.tsx @@ -18,7 +18,7 @@ const RolesArrayWrapper: FC = (props) => { {...props} values={value} errors={error} - touched={formik.touched[props.name] as FormikTouched[]} + touched={formik.touched[props.name] as FormikTouched[]} /> ); }; From 6dfe0566f3dd60e34ed79d880e6d4991ea14a5d5 Mon Sep 17 00:00:00 2001 From: Roie Natan Date: Wed, 20 Sep 2023 17:14:18 +0300 Subject: [PATCH 06/12] . --- src/shared/components/Form/Formik/TextField/TextField.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/shared/components/Form/Formik/TextField/TextField.tsx b/src/shared/components/Form/Formik/TextField/TextField.tsx index 51819ec380..99135bc538 100644 --- a/src/shared/components/Form/Formik/TextField/TextField.tsx +++ b/src/shared/components/Form/Formik/TextField/TextField.tsx @@ -8,7 +8,7 @@ export type TextFieldProps = InputProps & { }; const TextField: FC = (props) => { - const { isRequired, value, ...restProps } = props; + const { isRequired, ...restProps } = props; const [field, { touched, error }] = useField(restProps); const hintToShow = restProps.hint || (isRequired ? "Required" : ""); @@ -18,7 +18,6 @@ const TextField: FC = (props) => { {...field} hint={hintToShow} error={touched ? error : ""} - value={value} /> ); }; From bf5bc14da34a34460ea8b4e7dbdbd78e406974d8 Mon Sep 17 00:00:00 2001 From: Roie Natan Date: Sat, 23 Sep 2023 14:23:56 +0300 Subject: [PATCH 07/12] clean --- .../EditCommonModal/useCases/useCommonUpdate.ts | 11 +++++++---- .../interfaces/UpdateGovernanceCircleName.ts | 10 +++++++++- src/pages/OldCommon/store/actions.tsx | 14 ++++++++++---- src/pages/OldCommon/store/api.tsx | 12 +++++++----- src/pages/OldCommon/store/saga.tsx | 12 +++--------- 5 files changed, 36 insertions(+), 23 deletions(-) diff --git a/src/pages/OldCommon/components/CommonListContainer/EditCommonModal/useCases/useCommonUpdate.ts b/src/pages/OldCommon/components/CommonListContainer/EditCommonModal/useCases/useCommonUpdate.ts index 175f55326c..586ac5777d 100644 --- a/src/pages/OldCommon/components/CommonListContainer/EditCommonModal/useCases/useCommonUpdate.ts +++ b/src/pages/OldCommon/components/CommonListContainer/EditCommonModal/useCases/useCommonUpdate.ts @@ -1,7 +1,7 @@ import { useCallback, useState } from "react"; import { useDispatch, useSelector } from "react-redux"; import { selectUser } from "@/pages/Auth/store/selectors"; -import { UpdateGovernanceCircleNamePayload } from "@/pages/OldCommon/interfaces/UpdateGovernanceCircleName"; +import { UpdateGovernanceCirclesNamesPayload } from "@/pages/OldCommon/interfaces/UpdateGovernanceCircleName"; import { FileService, Logger } from "@/services"; import { isRequestError } from "@/services/Api"; import { ErrorCode } from "@/shared/constants"; @@ -122,7 +122,7 @@ const useCommonUpdate = (commonId?: string): Return => { circleId: role.circleId, newName: role.circleName, })); - const payload: UpdateGovernanceCircleNamePayload = { + const payload: UpdateGovernanceCirclesNamesPayload = { commonId, userId: user.uid, changes: circles, @@ -131,8 +131,11 @@ const useCommonUpdate = (commonId?: string): Return => { dispatch( updateGovernanceCircleName.request({ payload, - callback: (error, updatedGovernance) => { - console.log(updatedGovernance); + callback: (error, updatedCircles) => { + if (error) { + Logger.error(error); + } + setIsCommonUpdateLoading(false); }, }), ); diff --git a/src/pages/OldCommon/interfaces/UpdateGovernanceCircleName.ts b/src/pages/OldCommon/interfaces/UpdateGovernanceCircleName.ts index 128a932ebf..734d13cac9 100644 --- a/src/pages/OldCommon/interfaces/UpdateGovernanceCircleName.ts +++ b/src/pages/OldCommon/interfaces/UpdateGovernanceCircleName.ts @@ -1,10 +1,18 @@ +import firebase from "firebase/app"; + interface NewCircle { circleId: string; newName: string; } -export interface UpdateGovernanceCircleNamePayload { +export interface UpdateGovernanceCirclesNamesPayload { commonId: string; userId: string; changes: NewCircle[]; } + +export interface UpdateGovernanceCirclesNamesResponse { + circles: NewCircle[]; + message: string; + updatedAt: firebase.firestore.Timestamp; +} diff --git a/src/pages/OldCommon/store/actions.tsx b/src/pages/OldCommon/store/actions.tsx index 983af2fac1..3185f959c7 100644 --- a/src/pages/OldCommon/store/actions.tsx +++ b/src/pages/OldCommon/store/actions.tsx @@ -44,7 +44,10 @@ import { ImmediateContributionResponse, } from "../interfaces"; import { UpdateDiscussionMessageDto } from "../interfaces/UpdateDiscussionMessageDto"; -import { UpdateGovernanceCircleNamePayload } from "../interfaces/UpdateGovernanceCircleName"; +import { + UpdateGovernanceCirclesNamesPayload, + UpdateGovernanceCirclesNamesResponse, +} from "../interfaces/UpdateGovernanceCircleName"; import { CommonsActionTypes } from "./constants"; export const createGovernance = createAsyncAction( @@ -376,10 +379,13 @@ export const updateGovernanceCircleName = createAsyncAction( CommonsActionTypes.UPDATE_GOVERNANCE_CIRCLE_NAME_FAILURE, )< { - payload: UpdateGovernanceCircleNamePayload; - callback: (error: Error | null, governance?: Governance) => void; + payload: UpdateGovernanceCirclesNamesPayload; + callback: ( + error: Error | null, + updatedCircles?: UpdateGovernanceCirclesNamesResponse, + ) => void; }, - Common, + UpdateGovernanceCirclesNamesResponse, Error >(); diff --git a/src/pages/OldCommon/store/api.tsx b/src/pages/OldCommon/store/api.tsx index 8c837b12ea..6da6c20410 100644 --- a/src/pages/OldCommon/store/api.tsx +++ b/src/pages/OldCommon/store/api.tsx @@ -68,7 +68,10 @@ import firebase from "@/shared/utils/firebase"; import { generateCirclesDataForCommonMember } from "../../../shared/utils/generateCircleDataForCommonMember"; import { ChangeVisibilityDto } from "../interfaces/ChangeVisibilityDto"; import { UpdateDiscussionMessageDto } from "../interfaces/UpdateDiscussionMessageDto"; -import { UpdateGovernanceCircleNamePayload } from "../interfaces/UpdateGovernanceCircleName"; +import { + UpdateGovernanceCirclesNamesPayload, + UpdateGovernanceCirclesNamesResponse, +} from "../interfaces/UpdateGovernanceCircleName"; export async function createGovernance( requestData: CreateGovernancePayload, @@ -1206,10 +1209,9 @@ export async function updateGovernanceRules( return convertObjectDatesToFirestoreTimestamps(data); } -export async function updateGovernanceCircleName( - payload: UpdateGovernanceCircleNamePayload, -): Promise { - // UpdateGovernanceCircleNameResponse +export async function updateGovernanceCirclesNames( + payload: UpdateGovernanceCirclesNamesPayload, +): Promise { const { data } = await Api.put( ApiEndpoint.GovernanceUpdateCircleName, payload, diff --git a/src/pages/OldCommon/store/saga.tsx b/src/pages/OldCommon/store/saga.tsx index 1b407893bb..77a6affc69 100644 --- a/src/pages/OldCommon/store/saga.tsx +++ b/src/pages/OldCommon/store/saga.tsx @@ -42,7 +42,7 @@ import { createCommon as createCommonApi, updateCommon as updateCommonApi, updateGovernanceRules as updateGovernanceRulesApi, - updateGovernanceCircleName as updateGovernanceCircleNameApi, + updateGovernanceCirclesNames as updateGovernanceCircleNameApi, createProposal as createProposalApi, fetchCommonList, fetchCommonDetail, @@ -1702,14 +1702,8 @@ export function* updateGovernanceCircleName( action.payload.payload, )) as Awaited>; - console.log(updatedCircles); - // const updatedGovernance = { - // ...action.payload.governance, - // unstructuredRules: updatedRules.unstructuredRules, - // } as Governance; - - // yield put(actions.getGovernance.success(updatedGovernance)); - // action.payload.callback(null, updatedGovernance); + yield put(actions.updateGovernanceCircleName.success(updatedCircles)); + action.payload.callback(null, updatedCircles); } catch (error) { if (isError(error)) { action.payload.callback(error); From 847fc270cb517ebd1a1383dabd1c0ec77d9befce Mon Sep 17 00:00:00 2001 From: Roie Natan Date: Sat, 23 Sep 2023 15:09:32 +0300 Subject: [PATCH 08/12] enable space circles names editing --- .../ProjectCreationForm.tsx | 22 ++++++++++++++----- .../components/EditingForm/EditingForm.tsx | 5 +++-- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/pages/commonCreation/components/ProjectCreation/components/ProjectCreationForm/ProjectCreationForm.tsx b/src/pages/commonCreation/components/ProjectCreation/components/ProjectCreationForm/ProjectCreationForm.tsx index 23b3f18b79..7ba13093f5 100644 --- a/src/pages/commonCreation/components/ProjectCreation/components/ProjectCreationForm/ProjectCreationForm.tsx +++ b/src/pages/commonCreation/components/ProjectCreation/components/ProjectCreationForm/ProjectCreationForm.tsx @@ -6,7 +6,7 @@ import { useGovernanceByCommonId, useProjectCreation, } from "@/shared/hooks/useCases"; -import { Circles, Common, Governance, Project } from "@/shared/models"; +import { Circles, Common, Governance, Project, Roles } from "@/shared/models"; import { Loader, LoaderVariant, @@ -15,6 +15,7 @@ import { import { convertLinksToUploadFiles, getCirclesWithHighestTier, + removeProjectCircles, } from "@/shared/utils"; import { projectsActions, selectCommonLayoutProjects } from "@/store/states"; import { generateCreationForm, CreationFormRef } from "../../../CreationForm"; @@ -37,6 +38,7 @@ interface ProjectCreationFormProps { const getInitialValues = ( governanceCircles: Circles, initialCommon?: Project, + roles?: Roles, ): ProjectCreationFormValues => { const circlesWithHighestTier = getCirclesWithHighestTier( Object.values(governanceCircles), @@ -64,6 +66,7 @@ const getInitialValues = ( initialCommon?.directParent.circleId || circlesWithHighestTier[0]?.id || "", + roles: roles || [], }; }; @@ -92,11 +95,20 @@ const ProjectCreationForm: FC = (props) => { error: updateProjectError, updateCommon: updateProject, } = useCommonUpdate(initialCommon?.id); - const isLoading = isProjectCreationLoading || isCommonUpdateLoading; + const isLoading = + isProjectCreationLoading || isCommonUpdateLoading || !governance; const error = createProjectError || updateProjectError; + const nonProjectCircles = useMemo( + () => removeProjectCircles(Object.values(governance?.circles || {})), + [governance?.circles], + ); + const roles: Roles = nonProjectCircles.map((circle) => ({ + circleId: circle.id, + circleName: circle.name, + })); const initialValues = useMemo( - () => getInitialValues(governanceCircles, initialCommon), - [governanceCircles], + () => getInitialValues(governanceCircles, initialCommon, roles), + [governanceCircles, nonProjectCircles], ); const projectId = initialCommon?.id || project?.id; @@ -167,7 +179,7 @@ const ProjectCreationForm: FC = (props) => { ref={formRef} initialValues={initialValues} onSubmit={isEditing ? handleProjectUpdate : handleProjectCreate} - items={getConfiguration(true, [], { + items={getConfiguration(true, roles, { existingNames: existingProjectsNames, })} submitButtonText={isEditing ? "Save changes" : "Create Space"} diff --git a/src/pages/commonEditing/components/Editing/components/EditingForm/EditingForm.tsx b/src/pages/commonEditing/components/Editing/components/EditingForm/EditingForm.tsx index 916da92529..14894f6be5 100644 --- a/src/pages/commonEditing/components/Editing/components/EditingForm/EditingForm.tsx +++ b/src/pages/commonEditing/components/Editing/components/EditingForm/EditingForm.tsx @@ -35,7 +35,7 @@ const EditingForm: FC = (props) => { [governance?.circles], ); const { - isCommonUpdateLoading: isLoading, + isCommonUpdateLoading, common: updatedCommon, error, updateCommon, @@ -49,6 +49,7 @@ const EditingForm: FC = (props) => { common, roles, ); + const isLoading = isCommonUpdateLoading || !isGovernanceFetched; useEffect(() => { if (common.governanceId) { @@ -80,7 +81,7 @@ const EditingForm: FC = (props) => { return ( <> - {(isLoading || !isGovernanceFetched) && ( + {isLoading && ( Date: Tue, 26 Sep 2023 15:29:37 +0300 Subject: [PATCH 09/12] try getValidationSchemaForRolesItem --- .../utils/generateValidationSchema.ts | 26 ++++++++++++++++--- .../Form/Formik/RolesArray/RolesArray.tsx | 2 +- .../RolesArrayWrapper/RolesArrayWrapper.tsx | 6 +++-- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/pages/commonCreation/components/CreationForm/utils/generateValidationSchema.ts b/src/pages/commonCreation/components/CreationForm/utils/generateValidationSchema.ts index 37afe2dde8..46ad993a29 100644 --- a/src/pages/commonCreation/components/CreationForm/utils/generateValidationSchema.ts +++ b/src/pages/commonCreation/components/CreationForm/utils/generateValidationSchema.ts @@ -83,6 +83,26 @@ const getValidationSchemaForLinksItem = ({ ); }; +const getValidationSchemaForRolesItem = ({ + validation, +}: Pick): Schema => { + const schema = Yup.object().shape({ + roles: Yup.array().of( + Yup.object().shape({ + circleName: Yup.string().required("Role name is required"), + }), + ), + }); + + console.log(schema); + + if (!validation) { + return schema; + } + + return schema; +}; + export const generateValidationSchema = ( items: CreationFormItem[], ): Yup.ObjectSchema => { @@ -98,9 +118,9 @@ export const generateValidationSchema = ( if (item.type === CreationFormItemType.Links) { schema = getValidationSchemaForLinksItem(item); } - // if (item.type === CreationFormItemType.Roles) { - // schema = getValidationSchemaForTextFieldItem(item); - // } + if (item.type === CreationFormItemType.Roles) { + schema = getValidationSchemaForRolesItem(item); + } return schema ? { diff --git a/src/shared/components/Form/Formik/RolesArray/RolesArray.tsx b/src/shared/components/Form/Formik/RolesArray/RolesArray.tsx index 03e7e65841..22daee7084 100644 --- a/src/shared/components/Form/Formik/RolesArray/RolesArray.tsx +++ b/src/shared/components/Form/Formik/RolesArray/RolesArray.tsx @@ -11,7 +11,7 @@ import { TextField } from "../TextField"; import styles from "./RolesArray.module.scss"; type Errors = string | string[] | FormikErrors | undefined; -type Touched = FormikTouched[] | undefined; +type Touched = FormikTouched[] | undefined; export interface RolesArrayProps extends FieldArrayConfig { values: Roles; diff --git a/src/shared/components/Form/Formik/RolesArrayWrapper/RolesArrayWrapper.tsx b/src/shared/components/Form/Formik/RolesArrayWrapper/RolesArrayWrapper.tsx index e2f0176924..6569e89cf0 100644 --- a/src/shared/components/Form/Formik/RolesArrayWrapper/RolesArrayWrapper.tsx +++ b/src/shared/components/Form/Formik/RolesArrayWrapper/RolesArrayWrapper.tsx @@ -1,7 +1,7 @@ import React, { FC } from "react"; import { useField, useFormikContext } from "formik"; import { FormikTouched } from "formik/dist/types"; -import { Roles } from "@/shared/models"; +import { Role, Roles } from "@/shared/models"; import { RolesArray, RolesArrayProps } from "../RolesArray"; export type RolesArrayWrapperProps = Omit< @@ -11,6 +11,8 @@ export type RolesArrayWrapperProps = Omit< const RolesArrayWrapper: FC = (props) => { const [{ value }, { error }] = useField(props.name); + console.log(value); + console.log(error); const formik = useFormikContext(); return ( @@ -18,7 +20,7 @@ const RolesArrayWrapper: FC = (props) => { {...props} values={value} errors={error} - touched={formik.touched[props.name] as FormikTouched[]} + touched={formik.touched[props.name] as FormikTouched[]} /> ); }; From c004fe814b9b9ac71b4d5e75f25f2384f3b16d16 Mon Sep 17 00:00:00 2001 From: Andrey Mikhadyuk Date: Tue, 26 Sep 2023 15:36:34 +0300 Subject: [PATCH 10/12] fix roles validation --- .../utils/generateValidationSchema.ts | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/pages/commonCreation/components/CreationForm/utils/generateValidationSchema.ts b/src/pages/commonCreation/components/CreationForm/utils/generateValidationSchema.ts index 46ad993a29..6e4eee070b 100644 --- a/src/pages/commonCreation/components/CreationForm/utils/generateValidationSchema.ts +++ b/src/pages/commonCreation/components/CreationForm/utils/generateValidationSchema.ts @@ -86,21 +86,17 @@ const getValidationSchemaForLinksItem = ({ const getValidationSchemaForRolesItem = ({ validation, }: Pick): Schema => { - const schema = Yup.object().shape({ - roles: Yup.array().of( - Yup.object().shape({ - circleName: Yup.string().required("Role name is required"), - }), - ), - }); - - console.log(schema); - if (!validation) { - return schema; + return Yup.array(); } - return schema; + return Yup.array().of( + Yup.object().shape({ + circleName: Yup.string().required( + validation.required?.message || "Role name is required", + ), + }), + ); }; export const generateValidationSchema = ( From a8ed9bab3a777320d71e383c68bb0d62b7245510 Mon Sep 17 00:00:00 2001 From: Roie Natan Date: Tue, 26 Sep 2023 15:43:21 +0300 Subject: [PATCH 11/12] clean --- .../Form/Formik/RolesArrayWrapper/RolesArrayWrapper.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/shared/components/Form/Formik/RolesArrayWrapper/RolesArrayWrapper.tsx b/src/shared/components/Form/Formik/RolesArrayWrapper/RolesArrayWrapper.tsx index 6569e89cf0..c4f518f4ef 100644 --- a/src/shared/components/Form/Formik/RolesArrayWrapper/RolesArrayWrapper.tsx +++ b/src/shared/components/Form/Formik/RolesArrayWrapper/RolesArrayWrapper.tsx @@ -11,8 +11,6 @@ export type RolesArrayWrapperProps = Omit< const RolesArrayWrapper: FC = (props) => { const [{ value }, { error }] = useField(props.name); - console.log(value); - console.log(error); const formik = useFormikContext(); return ( From c90cbcdaee4f2181a52da2289d04c5a05233bac6 Mon Sep 17 00:00:00 2001 From: Roie Natan Date: Wed, 27 Sep 2023 13:03:04 +0300 Subject: [PATCH 12/12] code review updates --- .../EditCommonModal/useCases/useCommonUpdate.ts | 8 ++++---- .../components/Form/Formik/RolesArray/RolesArray.tsx | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/pages/OldCommon/components/CommonListContainer/EditCommonModal/useCases/useCommonUpdate.ts b/src/pages/OldCommon/components/CommonListContainer/EditCommonModal/useCases/useCommonUpdate.ts index 586ac5777d..2be324c306 100644 --- a/src/pages/OldCommon/components/CommonListContainer/EditCommonModal/useCases/useCommonUpdate.ts +++ b/src/pages/OldCommon/components/CommonListContainer/EditCommonModal/useCases/useCommonUpdate.ts @@ -2,6 +2,10 @@ import { useCallback, useState } from "react"; import { useDispatch, useSelector } from "react-redux"; import { selectUser } from "@/pages/Auth/store/selectors"; import { UpdateGovernanceCirclesNamesPayload } from "@/pages/OldCommon/interfaces/UpdateGovernanceCircleName"; +import { + updateCommon as updateCommonAction, + updateGovernanceCircleName, +} from "@/pages/OldCommon/store/actions"; import { FileService, Logger } from "@/services"; import { isRequestError } from "@/services/Api"; import { ErrorCode } from "@/shared/constants"; @@ -13,10 +17,6 @@ import { UpdateCommonData, UpdateCommonPayload, } from "../../../../interfaces"; -import { - updateCommon as updateCommonAction, - updateGovernanceCircleName, -} from "../../../../store/actions"; interface Return { isCommonUpdateLoading: boolean; diff --git a/src/shared/components/Form/Formik/RolesArray/RolesArray.tsx b/src/shared/components/Form/Formik/RolesArray/RolesArray.tsx index 22daee7084..ab9bc7c0f4 100644 --- a/src/shared/components/Form/Formik/RolesArray/RolesArray.tsx +++ b/src/shared/components/Form/Formik/RolesArray/RolesArray.tsx @@ -55,7 +55,6 @@ const RolesArray: FC = (props) => { value={role.circleName} placeholder="Role title" /> - {/* {errors && {errors}} */}
); })}