diff --git a/src/pages/commonCreation/components/ProjectCreation/ProjectCreation.module.scss b/src/pages/commonCreation/components/ProjectCreation/ProjectCreation.module.scss index 2bd7b059b3..8bc32d041f 100644 --- a/src/pages/commonCreation/components/ProjectCreation/ProjectCreation.module.scss +++ b/src/pages/commonCreation/components/ProjectCreation/ProjectCreation.module.scss @@ -23,6 +23,7 @@ display: flex; align-items: center; text-decoration: none; + color: $black; &:hover { text-decoration: underline; diff --git a/src/pages/commonCreation/components/ProjectCreation/ProjectCreation.tsx b/src/pages/commonCreation/components/ProjectCreation/ProjectCreation.tsx index 5dd74b89c6..5a7bd438d5 100644 --- a/src/pages/commonCreation/components/ProjectCreation/ProjectCreation.tsx +++ b/src/pages/commonCreation/components/ProjectCreation/ProjectCreation.tsx @@ -1,11 +1,13 @@ import React, { FC, useEffect } from "react"; import { useDispatch, useSelector } from "react-redux"; -import { NavLink, Redirect, useHistory } from "react-router-dom"; +import { Redirect, useHistory } from "react-router-dom"; import { CommonEvent, CommonEventEmitter } from "@/events"; import { selectUser } from "@/pages/Auth/store/selectors"; import { useCommonMember } from "@/pages/OldCommon/hooks"; +import { ButtonLink } from "@/shared/components"; import { GovernanceActions } from "@/shared/constants"; import { useRoutesContext } from "@/shared/contexts"; +import { useGoBack } from "@/shared/hooks"; import { useCommon, useGovernance } from "@/shared/hooks/useCases"; import { LongLeftArrowIcon } from "@/shared/icons"; import { Common, Governance, Project } from "@/shared/models"; @@ -23,6 +25,7 @@ interface ProjectCreationProps { const ProjectCreation: FC = (props) => { const { parentCommonId, initialCommon } = props; const history = useHistory(); + const { canGoBack, goBack } = useGoBack(); const dispatch = useDispatch(); const { getCommonPagePath } = useRoutesContext(); const { @@ -86,6 +89,14 @@ const ProjectCreation: FC = (props) => { history.push(getCommonPagePath(createdProject.id)); }; + const handleBackButtonClick = () => { + if (canGoBack) { + goBack(); + } else { + history.push(backRoute); + } + }; + useEffect(() => { fetchParentCommon(parentCommonId); }, [parentCommonId]); @@ -149,10 +160,10 @@ const ProjectCreation: FC = (props) => { return (
- + Back - +

{isEditing ? `Edit space ${initialCommon?.name}` diff --git a/src/pages/commonEditing/components/Editing/Editing.tsx b/src/pages/commonEditing/components/Editing/Editing.tsx index 3637ad60c3..1b0d06a453 100644 --- a/src/pages/commonEditing/components/Editing/Editing.tsx +++ b/src/pages/commonEditing/components/Editing/Editing.tsx @@ -1,12 +1,14 @@ import React, { FC, useEffect } from "react"; import { useSelector } from "react-redux"; -import { NavLink, Redirect, useHistory } from "react-router-dom"; +import { Redirect, useHistory } from "react-router-dom"; import { CommonEvent, CommonEventEmitter } from "@/events"; import { selectUser } from "@/pages/Auth/store/selectors"; import { useCommonMember } from "@/pages/OldCommon/hooks"; import { CenterWrapper } from "@/pages/commonCreation/components"; import { styles } from "@/pages/commonCreation/components/ProjectCreation"; +import { ButtonLink } from "@/shared/components"; import { GovernanceActions } from "@/shared/constants"; +import { useGoBack } from "@/shared/hooks"; import { LongLeftArrowIcon } from "@/shared/icons"; import { Common } from "@/shared/models"; import { Container, Loader } from "@/shared/ui-kit"; @@ -21,6 +23,7 @@ interface EditingProps { const Editing: FC = (props) => { const { common } = props; const history = useHistory(); + const { canGoBack, goBack } = useGoBack(); const { fetched: isCommonMemberFetched, data: commonMember, @@ -35,6 +38,7 @@ const Editing: FC = (props) => { ); + const backRoute = getCommonPageAboutTabPath(common.id); const handleUpdatedCommon = (updatedCommon: Common) => { CommonEventEmitter.emit(CommonEvent.ProjectUpdated, { @@ -46,6 +50,14 @@ const Editing: FC = (props) => { history.push(getCommonPageAboutTabPath(updatedCommon.id)); }; + const handleBackButtonClick = () => { + if (canGoBack) { + goBack(); + } else { + history.push(backRoute); + } + }; + useEffect(() => { fetchCommonMember(common.id, {}, true); }, [common.id, userId]); @@ -54,8 +66,6 @@ const Editing: FC = (props) => { return loaderEl; } - const backRoute = getCommonPageAboutTabPath(common.id); - if ( !commonMember || !commonMember.allowedActions[GovernanceActions.UPDATE_COMMON] @@ -70,10 +80,10 @@ const Editing: FC = (props) => { return (
- + Back - +

Edit common {common.name}