Skip to content

Commit

Permalink
Merge pull request #2068 from daostack/feature/CW-1940-change-join-co…
Browse files Browse the repository at this point in the history
…mmon-flow

Change the Join common\space flow #1940
  • Loading branch information
andreymikhadyuk authored Sep 13, 2023
2 parents fd3b06e + 6f949b0 commit 23acf4f
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default function EmptyTabComponent({
className="button-blue empty-tab-content-wrapper__button"
onClick={handleModalOpen}
>
Join the effort
Join
</button>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ export default function ChatComponent({

return (
<span className={styles.permissionsText} onClick={onJoinCommon}>
{directParent ? "Join the space" : "Join the effort"}
Join
</span>
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/pages/common/components/CommonHeader/CommonHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const CommonHeader: FC<CommonHeaderProps> = (props) => {
details = [],
isProject = false,
withJoin = true,
joinButtonText = isProject ? "Join the space" : "Join the effort",
joinButtonText = "Join",
} = props;
const { isJoinAllowed, onJoinCommon } = useCommonDataContext();
const isTabletView = useIsTabletView();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const CommonEntranceJoin: FC<CommonEntranceJoinProps> = (props) => {
: onJoinCommon
}
>
Join the {isProject ? "space" : "effort"}
Join
</Button>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const JoinProjectForm: FC<PropsWithChildren<JoinProjectFormProps>> = (
disabled={!message}
onClick={handleRequestToJoin}
>
{isJoinMemberAdmittanceRequest ? "Request to join" : "Join space"}
{isJoinMemberAdmittanceRequest ? "Request to join" : "Join"}
</Button>
</div>
</>
Expand Down
7 changes: 7 additions & 0 deletions src/pages/commonFeed/CommonFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const CommonFeedComponent: FC<CommonFeedProps> = (props) => {
fetchCommonData,
} = useCommonData(userId);
const parentCommonId = commonData?.common.directParent?.commonId;
const parentCommonMember = commonData?.parentCommonMember;
const isRootCommon = !parentCommonId;
const isRootCommonMember = Boolean(commonData?.rootCommonMember);
const anotherCommonId =
Expand Down Expand Up @@ -193,6 +194,12 @@ const CommonFeedComponent: FC<CommonFeedProps> = (props) => {
[dispatch],
);

useEffect(() => {
if (isCommonDataFetched && parentCommonId && !parentCommonMember) {
history.replace(getCommonPageAboutTabPath(commonId));
}
}, [isCommonDataFetched, parentCommonMember?.id, commonId]);

useEffect(() => {
if (!isCommonDataFetched || !isGlobalDataFetched || commonMember) {
return;
Expand Down
27 changes: 19 additions & 8 deletions src/pages/commonFeed/hooks/useCommonData/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,24 @@ export const useCommonData = (userId?: string): Return => {
}

const rootCommonId = common.directParent?.commonId;
const [parentCommons, subCommons, rootCommonMember] =
await Promise.all([
CommonService.getAllParentCommonsForCommon(common),
CommonService.getCommonsByDirectParentIds([common.id]),
rootCommonId && userId
? CommonService.getCommonMemberByUserId(rootCommonId, userId)
: null,
]);
const [
parentCommons,
subCommons,
rootCommonMember,
parentCommonMember,
] = await Promise.all([
CommonService.getAllParentCommonsForCommon(common),
CommonService.getCommonsByDirectParentIds([common.id]),
rootCommonId && userId
? CommonService.getCommonMemberByUserId(rootCommonId, userId)
: null,
common.directParent?.commonId && userId
? CommonService.getCommonMemberByUserId(
common.directParent.commonId,
userId,
)
: null,
]);

setState({
loading: false,
Expand All @@ -85,6 +95,7 @@ export const useCommonData = (userId?: string): Return => {
commonMembersAmount,
sharedFeedItem,
rootCommonMember,
parentCommonMember,
parentCommon: last(parentCommons),
},
});
Expand Down
1 change: 1 addition & 0 deletions src/pages/commonFeed/hooks/useCommonData/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface Data {
commonMembersAmount: number;
sharedFeedItem: CommonFeed | null;
rootCommonMember: CommonMember | null;
parentCommonMember: CommonMember | null;
parentCommon?: Common;
}

Expand Down

0 comments on commit 23acf4f

Please sign in to comment.