Skip to content

Commit

Permalink
fix: remove limitation when clone experience (#1815)
Browse files Browse the repository at this point in the history
* fix: remove limitation when clone experience

* fix: resolve user not found

---------

Co-authored-by: Abdul Hakim <hakim@undercurrent.tech>
  • Loading branch information
abdulhakim2902 and abdulhakim2902 authored Apr 28, 2023
1 parent 4cc761c commit d229c16
Showing 3 changed files with 4 additions and 26 deletions.
3 changes: 1 addition & 2 deletions pages/experience/[experienceId]/clone.tsx
Original file line number Diff line number Diff line change
@@ -109,6 +109,7 @@ export const getServerSideProps = wrapper.getServerSideProps(

res.setHeader('set-cookie', [`${COOKIE_INSTANCE_URL}=${apiURL}`]);

const user = (await dispatch(fetchUser())) as unknown as User;
await Promise.all([
dispatch(fetchServer(sessionInstanceURL)),
dispatch(fetchNetwork()),
@@ -124,7 +125,6 @@ export const getServerSideProps = wrapper.getServerSideProps(
const experience = await ExperienceAPI.getExperienceDetail(experienceId);

if (experience?.visibility === 'selected_user') {
const user = (await dispatch(fetchUser())) as unknown as User;
const found = experience?.selectedUserIds?.find(
e => e.userId === user?.id,
);
@@ -135,7 +135,6 @@ export const getServerSideProps = wrapper.getServerSideProps(
}

if (experience?.visibility === 'private') {
const user = (await dispatch(fetchUser())) as unknown as User;
if (experience?.createdBy !== user?.id)
return {
notFound: true,
11 changes: 1 addition & 10 deletions src/components/ExperienceList/ExperienceList.container.tsx
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@ import { ExperienceListRightBar } from './ExperienceListRightBar';
import { useExperienceList } from './hooks/use-experience-list.hook';

import useConfirm from 'components/common/Confirm/use-confirm.hook';
import { useEnqueueSnackbar } from 'components/common/Snackbar/useEnqueueSnackbar.hook';
import { LoadMoreComponent } from 'src/components/atoms/LoadMore/LoadMore';
import {
ExperienceOwner,
@@ -65,7 +64,6 @@ export const ExperienceListContainer: React.FC<ExperienceListContainerProps> =

const style = useStyles(props);
const router = useRouter();
const enqueueSnackbar = useEnqueueSnackbar();
const confirm = useConfirm();
const user = useSelector<RootState, User | undefined>(
state => state.userState.user,
@@ -132,14 +130,7 @@ export const ExperienceListContainer: React.FC<ExperienceListContainerProps> =
},
});
} else {
if (totalOwnedExperience >= 10) {
enqueueSnackbar({
message: i18n.t('Experience.List.Alert'),
variant: 'warning',
});
} else {
router.push(`/experience/${experienceId}/clone`);
}
router.push(`/experience/${experienceId}/clone`);
}
};

16 changes: 2 additions & 14 deletions src/components/ExperiencePreview/ExperiencePreview.container.tsx
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@ import { useRouter } from 'next/router';
import { ExperiencePreview } from './ExperiencePreview';
import { useStyles } from './experience.style';

import { useEnqueueSnackbar } from 'components/common/Snackbar/useEnqueueSnackbar.hook';
import { TopNavbarComponent } from 'src/components/atoms/TopNavbar';
import { useExperienceHook } from 'src/hooks/use-experience-hook';
import i18n from 'src/locale';
@@ -14,12 +13,11 @@ export const ExperiencePreviewContainer: React.FC = () => {
const {
experience,
userExperiences,
userExperiencesMeta,
getExperienceDetail,
subscribeExperience,
unsubscribeExperience,
} = useExperienceHook();
const enqueueSnackbar = useEnqueueSnackbar();

const style = useStyles();
const router = useRouter();
const { experienceId } = router.query;
@@ -37,17 +35,7 @@ export const ExperiencePreviewContainer: React.FC = () => {
};

const handleCloneExperience = (experienceId: string) => {
const totalOwnedExperience =
userExperiencesMeta.additionalData?.totalOwnedExperience ?? 0;

if (totalOwnedExperience >= 10) {
enqueueSnackbar({
message: i18n.t('Experience.Alert.Max_Exp'),
variant: 'warning',
});
} else {
router.push(`/experience/${experienceId}/clone`);
}
router.push(`/experience/${experienceId}/clone`);
};

const handleEditExperience = (experienceId: string) => {

0 comments on commit d229c16

Please sign in to comment.