Skip to content

Commit

Permalink
Handled show list (#1463)
Browse files Browse the repository at this point in the history
fix: handled show list
  • Loading branch information
ical10 authored Sep 16, 2022
1 parent b4a2594 commit f979791
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 39 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {InformationCircleIcon} from '@heroicons/react/outline';

import React, {useCallback, useState} from 'react';
import React, {useCallback, useState, useEffect} from 'react';
import InfiniteScroll from 'react-infinite-scroll-component';
import {useSelector} from 'react-redux';

Expand All @@ -24,7 +24,6 @@ import {useStyles} from './ModalAddToPost.styles';
import {Empty} from 'components/atoms/Empty';
import ShowIf from 'components/common/show-if.component';
import {Skeleton} from 'src/components/Expericence';
import {Loading} from 'src/components/atoms/Loading';
import {Modal} from 'src/components/atoms/Modal';
import {useExperienceHook} from 'src/hooks/use-experience-hook';
import {WrappedExperience} from 'src/interfaces/experience';
Expand Down Expand Up @@ -105,6 +104,12 @@ export const ModalAddToPostProvider: React.ComponentType<ModalAddPostExperienceP
addPostsToExperience,
loading,
} = useExperienceHook();

useEffect(() => {
if (Boolean(user) && userExperiencesMeta.currentPage < userExperiencesMeta.totalPageCount)
loadNextUserExperience();
}, [user, userExperiencesMeta]);

const [postId, setPostId] = useState<string | null>(null);
const [open, setOpen] = useState(false);
const [isSelectAll, setIsSelectAll] = useState(false);
Expand Down Expand Up @@ -170,8 +175,6 @@ export const ModalAddToPostProvider: React.ComponentType<ModalAddPostExperienceP
}
};

console.log({userExperiences});

return (
<>
<ModalAddToPostContext.Provider value={addPostToExperience}>
Expand Down Expand Up @@ -213,37 +216,32 @@ export const ModalAddToPostProvider: React.ComponentType<ModalAddPostExperienceP
<div></div>
</div>

<div id="selectable-list-experiences" className={styles.experienceList}>
{loading ? (
<Loading />
) : (
<InfiniteScroll
scrollableTarget="selectable-list-experiences"
dataLength={
userExperiences.filter(ar => ar.userId === user?.id && ar.subscribed === false)
.length
}
hasMore={
Boolean(user)
? userExperiencesMeta.currentPage < userExperiencesMeta.totalPageCount
: false
}
next={handleLoadNextPage}
loader={<Skeleton />}>
{userExperiences
.filter(ar => ar.userId === user?.id && ar.subscribed === false)
.map(item => {
return (
<ExperienceItem
key={item.id}
item={item}
selectedExperience={selectedExperience}
handleSelectExperience={handleSelectExperience}
/>
);
})}
</InfiniteScroll>
)}
<div id="selectable-experience-list" className={styles.experienceList}>
<InfiniteScroll
scrollableTarget="selectable-experience-list"
dataLength={
userExperiences.filter(ar => ar.userId === user?.id && ar.subscribed === false).length
}
hasMore={
Boolean(user)
? userExperiencesMeta.currentPage < userExperiencesMeta.totalPageCount
: false
}
next={handleLoadNextPage}
loader={<Skeleton />}>
{userExperiences
.filter(ar => ar.userId === user?.id && ar.subscribed === false)
.map(item => {
return (
<ExperienceItem
key={item.id}
item={item}
selectedExperience={selectedExperience}
handleSelectExperience={handleSelectExperience}
/>
);
})}
</InfiniteScroll>

<ShowIf condition={userExperiences.filter(ar => ar.userId === user?.id).length === 0}>
<div className={styles.containerEmpty}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ export const useStyles = makeStyles((theme: Theme) =>
marginBottom: theme.spacing(0.5),
},
experienceList: {
maxHeight: '329px',
maxHeight: 'fit-content',
gap: '8px',
marginBottom: theme.spacing(1.5),
alignItems: 'center',
overflow: 'scroll',
//overflow: 'scroll',
},
experienceCard: {
display: 'flex',
Expand Down
2 changes: 0 additions & 2 deletions src/components/ExperienceList/ExperienceList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ export const ExperienceList: React.FC<ExperienceListProps> = props => {
viewPostList(TimelineType.EXPERIENCE, userExperience);
};

console.log({experiences});

return (
<div className={classes.root}>
{experiences.map(item => (
Expand Down

0 comments on commit f979791

Please sign in to comment.