Skip to content

Commit

Permalink
Merge pull request #1597 from lumi-tip/development-lumi-7782
Browse files Browse the repository at this point in the history
🐛 attempt to fix bug related to tasks not loading after user buys a program
  • Loading branch information
tommygonzaleza authored Sep 10, 2024
2 parents bf237f4 + a5ebd6f commit be770c4
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 33 deletions.
69 changes: 37 additions & 32 deletions src/pages/cohort/[cohortSlug]/[slug]/[version]/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function Dashboard() {
const [events, setEvents] = useState(null);
const [liveClasses, setLiveClasses] = useState([]);
const { featuredColor, hexColor, modal } = useStyle();

const [isLoadingAssigments, setIsLoadingAssigments] = useState(true);
const { user, isAuthenticated } = useAuth();

const isBelowTablet = getBrowserSize()?.width < 768;
Expand Down Expand Up @@ -270,6 +270,7 @@ function Dashboard() {
// Fetch cohort data with pathName structure
useEffect(() => {
if (user) {
setIsLoadingAssigments(true);
getCohortData({
cohortSlug,
}).then((cohort) => {
Expand All @@ -283,6 +284,8 @@ function Dashboard() {
getCohortAssignments({
user, setContextState, slug, cohort,
});
}).finally(() => {
setIsLoadingAssigments(false);
});
}
}, [user]);
Expand Down Expand Up @@ -331,9 +334,11 @@ function Dashboard() {

// Sort all data fetched in order of taskTodo
useEffect(() => {
prepareTasks({
cohortProgram, contextState, nestAssignments,
});
if (contextState.cohortProgram && typeof contextState.cohortProgram === 'object' && contextState.taskTodo) {
prepareTasks({
cohortProgram, contextState, nestAssignments,
});
}
}, [contextState.cohortProgram, contextState.taskTodo, router]);

const dailyModuleData = getDailyModuleData() || '';
Expand Down Expand Up @@ -500,27 +505,27 @@ function Dashboard() {
/>
</OnlyFor>
{academyOwner?.white_labeled && (
<Box
className="white-label"
borderRadius="md"
padding="10px"
display="flex"
justifyContent="space-around"
bg={colorMode === 'light' ? '#F2F2F2' || 'blue.light' : 'featuredDark'}
>
<Avatar
name={academyOwner.name}
src={academyOwner.icon_url}
/>
<Box className="white-label-text" width="80%">
<Text size="md" fontWeight="700" marginBottom="5px">
{academyOwner.name}
</Text>
<Text size="sm">
{t('whiteLabeledText')}
</Text>
<Box
className="white-label"
borderRadius="md"
padding="10px"
display="flex"
justifyContent="space-around"
bg={colorMode === 'light' ? '#F2F2F2' || 'blue.light' : 'featuredDark'}
>
<Avatar
name={academyOwner.name}
src={academyOwner.icon_url}
/>
<Box className="white-label-text" width="80%">
<Text size="md" fontWeight="700" marginBottom="5px">
{academyOwner.name}
</Text>
<Text size="sm">
{t('whiteLabeledText')}
</Text>
</Box>
</Box>
</Box>
)}
<LiveEvent
featureLabel={t('common:live-event.title')}
Expand Down Expand Up @@ -564,7 +569,7 @@ function Dashboard() {
<Box as="span" fontSize="21px" fontWeight={700} flex="1" textAlign="left">
{t('intro-video-title')}
</Box>
<Icon icon="arrowRight" width="11px" height="20px" color="currentColor" style={{ }} transform={isExpanded ? 'rotate(90deg)' : 'rotate(0deg)'} transition="transform 0.2s ease-in" />
<Icon icon="arrowRight" width="11px" height="20px" color="currentColor" style={{}} transform={isExpanded ? 'rotate(90deg)' : 'rotate(0deg)'} transition="transform 0.2s ease-in" />
</AccordionButton>
</span>
<AccordionPanel padding="0px 4px 4px 4px">
Expand Down Expand Up @@ -648,9 +653,9 @@ function Dashboard() {
</InputRightElement>
</InputGroup>
{modulesExists && (
<Checkbox onChange={(e) => setShowPendingTasks(e.target.checked)} textAlign="right" gridGap="10px" display="flex" flexDirection="row-reverse" color={commonFontColor}>
{t('modules.show-pending-tasks')}
</Checkbox>
<Checkbox onChange={(e) => setShowPendingTasks(e.target.checked)} textAlign="right" gridGap="10px" display="flex" flexDirection="row-reverse" color={commonFontColor}>
{t('modules.show-pending-tasks')}
</Checkbox>
)}
</Box>
</Box>
Expand All @@ -661,7 +666,7 @@ function Dashboard() {
display="flex"
flexDirection="column"
>
{sortedAssignments && sortedAssignments.length >= 1 ? (
{sortedAssignments && sortedAssignments.length >= 1 && !isLoadingAssigments ? (
<>
{sortedAssignmentsSearched.map((assignment, i) => {
const {
Expand Down Expand Up @@ -704,9 +709,9 @@ function Dashboard() {
);
})}
{sortedAssignmentsSearched && sortedAssignmentsSearched.length <= 0 && (
<Text size="l">
{t('modules.search-not-found')}
</Text>
<Text size="l">
{t('modules.search-not-found')}
</Text>
)}
</>
) : <ModuleMapSkeleton />}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/pricing.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ function PricingView() {
<Link
variant="buttonDefault"
borderRadius="3px"
href={`/pricing?course=${course?.slug}`}
href={`/${lang}/pricing?course=${course?.slug}`}
textAlign="center"
width="100%"
opacity="0.9"
Expand Down

0 comments on commit be770c4

Please sign in to comment.