-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ page to schedule mentorship #1607
Merged
tommygonzaleza
merged 145 commits into
breatheco-de:development
from
lumi-tip:development-lumi-7728
Oct 1, 2024
Merged
Changes from 12 commits
Commits
Show all changes
145 commits
Select commit
Hold shift + click to select a range
f4be842
guided experience for lesson and remove unnecesary contextState variable
gustavomm19 853d834
fix colors variables
gustavomm19 21fb3bd
improve sidebar functionality
gustavomm19 54f4b8b
add guided experience for exercises
gustavomm19 d0b0675
fix scroll behavior on guided experience sidebar
gustavomm19 aec5796
refactor useCohortHandler
gustavomm19 f812ee2
remove unused param
gustavomm19 fa031ca
remove promise syntax in cohort handler
gustavomm19 de3590c
Merge branch 'development' of https://github.com/gustavomm19/app into…
gustavomm19 a1a1fc1
remove back to dashboard button
gustavomm19 e1fe4aa
doing projects version
gustavomm19 cc0c7a4
adding guided experience to projects
gustavomm19 1dbd94f
fix conflict
gustavomm19 7b6c9cf
:bug: fix1 when user in basic plan run out of consumables and then up…
lumi-tip cd8b9c6
make markdown mas width 1280px
gustavomm19 4b0ca7c
componetize CodeRevissionsList
gustavomm19 126259d
Merge branch 'development' of https://github.com/gustavomm19/app into…
gustavomm19 d44eaa2
move current task to module handler hook
gustavomm19 3f19ba4
:bug: user will get its consumables if needed and has them
lumi-tip b5ecbf4
:recycle: refactor mentorshipService (was not getting info at all) mo…
lumi-tip 240a54d
added coderevissions to guided-experience
gustavomm19 a7018bd
remove unused code
gustavomm19 e4a70bc
fix code details
gustavomm19 3cd13ce
fix syntax in TaskCodeRevision
gustavomm19 56c0d04
fix code in coderevisionslist
gustavomm19 cd89b02
remove duplicated function nestAssignments
gustavomm19 1b40369
remove duplicated admissions user me call
gustavomm19 aa2f712
fix bug
gustavomm19 2ff0fd1
add button on no info modal to sync cohorts tasks
gustavomm19 50bfd8f
small refactor to useCohortHandler
gustavomm19 a9a0e90
remove option to start code review if there is no commit files
gustavomm19 c7a9ae5
remove comment to force redeploy
gustavomm19 e98549b
:sparkles: new url for students to schedule mentorships
lumi-tip b08bcea
fix visual details
gustavomm19 3de19cd
Merge pull request #1596 from breatheco-de/development
tommygonzaleza 1494445
:recycle: refactor of the code, sort consumables to avoid bug avoid u…
lumi-tip 4ac4844
:recycle: refactor of small pieces of code
lumi-tip 11a4536
:recycle: changes in the code related to colors, padding, margin
lumi-tip 25d8ef0
Merge branch 'development' of https://github.com/gustavomm19/app into…
gustavomm19 2d7f652
fix bug with modal layout
gustavomm19 df18c21
:recycle: refactor of the code of mentoring
lumi-tip aa17be4
sidebar new design
gustavomm19 d1531fa
remove consoles log
gustavomm19 686a0d8
added rigobot ai chat
gustavomm19 5ace6fc
fix conflict
gustavomm19 8809e0a
fix typo
gustavomm19 2d2bb08
replace bottom buttons text by tooltps
gustavomm19 03273a1
Update AuthContext.jsx
tommygonzaleza 791ab1a
Update AuthContext.jsx
tommygonzaleza d82d424
Merge pull request #1601 from breatheco-de/development
tommygonzaleza 8c1acf9
redesign guided experience navbar
gustavomm19 5095bce
redesign bottom controls panel
gustavomm19 f0ac417
change cohortProgram initial value
gustavomm19 e967875
add prop cohort to onlyfor component
gustavomm19 0bcf9a6
fix conflict
gustavomm19 3361653
fix control buttons sizing
gustavomm19 7671db4
:recycle: refactor of the jsx
lumi-tip 5796592
fix some code details
gustavomm19 878c9e0
diminish padding in exercises view
gustavomm19 f87f747
fix issue with related assets
gustavomm19 bd6432b
fix codeviewer excesive scroll length
gustavomm19 b7da943
:sparkles: page to schedule mentorship
lumi-tip 2f75f79
small change
lumi-tip d8f4c46
:bug: fix bug related to consumables when user comes from /program/slug
lumi-tip bc3becf
Update signup.json
tommygonzaleza 29104b9
Update signup.json
tommygonzaleza b6be5ff
Merge pull request #1608 from breatheco-de/tommygonzaleza-patch-6
tommygonzaleza aa9ac91
small change in border color
lumi-tip 3d027e7
small change
lumi-tip bd23ce3
remove log
lumi-tip 0cff98b
Update dashboard.json
tommygonzaleza f1e17e0
hide saas courses for non saas students
gustavomm19 3b2b428
fix details
gustavomm19 168e0b6
fix redirect to origin url from navbar login
gustavomm19 8779ef2
fix responsive bug with assets
gustavomm19 daebe4f
Merge pull request #1602 from lumi-tip/development-lumi-7752-v2
tommygonzaleza 3259741
fix typo
gustavomm19 6b32e2b
Merge pull request #1606 from gustavomm19/fixes
tommygonzaleza 27d4e9f
Update signup.json
tommygonzaleza 157e64f
:recycle: refactor of consumablesCode
lumi-tip 297ec66
:recycle: refactor of consumablesCode
lumi-tip b6a6ad9
Add terms and conditions on signup button
tommygonzaleza 3d736f4
Merge pull request #1570 from gustavomm19/guided-experience
tommygonzaleza d469461
:recycle: refactor of the code
lumi-tip 437e408
:recycle: refactor of the code
lumi-tip 16991aa
:recycle: using Mentoring consumables component
lumi-tip e24dae4
update in dashborad json
lumi-tip c68d956
:recycle: using Mentoring consumables component
lumi-tip 3a28d29
Merge pull request #1609 from breatheco-de/development
tommygonzaleza e91d2de
add classname to controls panel
gustavomm19 115f245
fix solution video component bug
gustavomm19 3e8dc42
fix controlls overflowing container
gustavomm19 1284b53
fix close icon
gustavomm19 0f1923e
Merge branch 'development' of https://github.com/gustavomm19/app into…
gustavomm19 a257de9
do not show option to start code review if there is no commit files
gustavomm19 c31e21c
fix details
gustavomm19 0b9a381
Merge branch 'development' of https://github.com/gustavomm19/app into…
gustavomm19 d144c7b
fix detail
gustavomm19 75f72b0
:recycle: refactor
lumi-tip 06a182b
include call to action to open interactive projects
gustavomm19 bb3bb9d
fix menu bug
gustavomm19 97bfa86
Merge pull request #1605 from gustavomm19/saas-courses
tommygonzaleza cf17d89
Merge pull request #1612 from breatheco-de/main
tommygonzaleza b46523f
small change
lumi-tip 049c09c
hide teachers feedback and codereviews if the asset has delivery_form…
gustavomm19 46ae3a5
fix typo
gustavomm19 37b4976
remove unnecesary manual translation
gustavomm19 ce48758
Merge pull request #1587 from lumi-tip/development-lumi-7659
tommygonzaleza 060ea54
Update dashboard.json
tommygonzaleza 8196a59
Merge pull request #1594 from gustavomm19/sync-cohort
tommygonzaleza 1332ef5
Update index.jsx
tommygonzaleza 29123cb
Merge pull request #1613 from gustavomm19/guided-experience
tommygonzaleza 7a06d81
Update dashboard.json
tommygonzaleza 4c5780e
Update dashboard.json
tommygonzaleza d2edf94
:sparkles: new url for students to schedule mentorships
lumi-tip 10cdedf
:recycle: refactor of the jsx
lumi-tip 8d88f5b
:sparkles: page to schedule mentorship
lumi-tip be69a9c
small change
lumi-tip 326f48f
:recycle: using Mentoring consumables component
lumi-tip 7f50a3e
Update dashboard.json
tommygonzaleza f2c7284
:recycle: using Mentoring consumables component
lumi-tip e9bd61c
small change
lumi-tip 969eee4
merging
lumi-tip 7d41b21
:sparkles: new url for students to schedule mentorships
lumi-tip ded7667
:recycle: refactor of the jsx
lumi-tip b4c5b20
:sparkles: page to schedule mentorship
lumi-tip 677c55d
small change
lumi-tip cd8e313
:recycle: using Mentoring consumables component
lumi-tip 07b45e3
Update dashboard.json
tommygonzaleza 893ecd9
:recycle: using Mentoring consumables component
lumi-tip f397594
small change
lumi-tip 6f50e0b
merge
lumi-tip b285ff6
:recycle: refactor of the jsx
lumi-tip 90cbce5
:sparkles: page to schedule mentorship
lumi-tip 1b4805c
:recycle: using Mentoring consumables component
lumi-tip d8c6346
Update dashboard.json
tommygonzaleza 1735477
Update dashboard.json
tommygonzaleza 07a23b1
Update dashboard.json
tommygonzaleza c2e3894
Update dashboard.json
tommygonzaleza 4bcf4a0
Merge branch 'development-lumi-7728' of https://github.com/lumi-tip/a…
lumi-tip f113aaf
:recycle: small refactor
lumi-tip 576e107
:recycle: samll refactor
lumi-tip da434fc
:bug: fix related to consumables
lumi-tip 2f33cb7
adding max-w and when searching for mentor it will be the only option
lumi-tip 23ed75f
changes in spacing
lumi-tip File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,224 @@ | ||
import { useEffect, useState, useMemo } from 'react'; | ||
import { useColorModeValue, Container, Box } from '@chakra-ui/react'; | ||
import { useRouter } from 'next/router'; | ||
import useTranslation from 'next-translate/useTranslation'; | ||
import { reportDatalayer } from '../../utils/requests'; | ||
import useSubscriptionsHandler from '../../common/store/actions/subscriptionAction'; | ||
import useAuth from '../../common/hooks/useAuth'; | ||
import Icon from '../../common/components/Icon'; | ||
import Link from '../../common/components/NextChakraLink'; | ||
import bc from '../../common/services/breathecode'; | ||
import MentoringConsumables from '../../common/components/SupportSidebar/MentoringConsumables'; | ||
|
||
function MentorshipSchedule() { | ||
let isTabletOrPhone = false; | ||
if (typeof window !== 'undefined') { | ||
isTabletOrPhone = window.innerWidth < 780; | ||
} | ||
const router = useRouter(); | ||
const { t } = useTranslation('dashboard'); | ||
const { fetchSubscriptions } = useSubscriptionsHandler(); | ||
const { service, mentor } = router.query; | ||
const { isLoading, user, isAuthenticated } = useAuth(); | ||
const [mentorshipServices, setMentorshipServices] = useState({ isLoading: true, data: [] }); | ||
const [searchProps, setSearchProps] = useState({ serviceSearch: '', mentorSearch: '' }); | ||
const [mentoryProps, setMentoryProps] = useState({}); | ||
const [admissions, setAdmissions] = useState({}); | ||
const [consumables, setConsumables] = useState([]); | ||
const [allMentorsAvailable, setAllMentorsAvailable] = useState([]); | ||
const [mentorsByService, setMentorsByService] = useState([]); | ||
const [subscriptionData, setSubscriptionData] = useState([]); | ||
|
||
const getServices = async (userRoles) => { | ||
if (userRoles?.length > 0) { | ||
const mentorshipPromises = await userRoles.map((role) => bc.mentorship({ academy: role?.academy?.id }, true).getService() | ||
.then((resp) => { | ||
const data = resp?.data; | ||
if (data !== undefined && data.length > 0) { | ||
return data.map((serv) => ({ | ||
...serv, | ||
academy: { | ||
id: role?.academy.id, | ||
available_as_saas: role?.academy?.available_as_saas, | ||
}, | ||
})); | ||
} | ||
return []; | ||
})); | ||
const mentorshipResults = await Promise.all(mentorshipPromises); | ||
const recopilatedServices = mentorshipResults.flat(); | ||
|
||
setMentorshipServices({ | ||
isLoading: false, | ||
data: recopilatedServices, | ||
}); | ||
} | ||
}; | ||
|
||
const getAdmissionsData = async () => { | ||
try { | ||
const response = await bc.admissions().me(); | ||
const admissionsFromDB = response.data; | ||
setAdmissions(response.data); | ||
getServices(admissionsFromDB.roles); | ||
} catch (error) { | ||
console.error('Error fetching admissions data:', error); | ||
} | ||
}; | ||
|
||
useEffect(() => { | ||
const checkAuthAndFetchData = async () => { | ||
if (!isLoading && !isAuthenticated) { | ||
router.push('/login'); | ||
} else if (isAuthenticated) { | ||
await getAdmissionsData(); | ||
} | ||
}; | ||
|
||
checkAuthAndFetchData(); | ||
}, [isLoading, isAuthenticated]); | ||
|
||
const allSyllabus = useMemo(() => { | ||
const allCohorts = admissions?.cohorts || []; | ||
const syllabus = [...new Set(allCohorts.map(({ cohort }) => cohort.syllabus_version.slug))]; | ||
return syllabus; | ||
}, [admissions]); | ||
|
||
const getAllMentorsAvailable = async () => { | ||
const servicesSlugs = mentorshipServices.data.map(({ slug }) => slug); | ||
|
||
const academies = mentorshipServices.data.reduce((acc, { academy, ...restOfService }) => { | ||
if (!acc[academy.id]) { | ||
acc[academy.id] = { services: [] }; | ||
} | ||
acc[academy.id].services.push(restOfService); | ||
return acc; | ||
}, {}); | ||
|
||
const academyData = Object.entries(academies).map(([id, { services }]) => ({ | ||
id: Number(id), | ||
services, | ||
})); | ||
|
||
const getMentorsForAcademy = async (academy) => { | ||
const res = await bc.mentorship({ | ||
services: academy.services.map((s) => s.slug).join(','), | ||
status: 'ACTIVE', | ||
syllabus: allSyllabus?.join(',') || undefined, | ||
academy: academy.id, | ||
}).getMentor(); | ||
|
||
return res?.data || []; | ||
}; | ||
|
||
if (servicesSlugs.length > 0 || allSyllabus.length > 0) { | ||
const mentorsPromises = academyData.map(getMentorsForAcademy); | ||
const mentorsList = (await Promise.all(mentorsPromises)).flat(); | ||
return mentorsList; | ||
} | ||
|
||
return []; | ||
}; | ||
|
||
const getMentorsAndConsumables = async () => { | ||
const mentors = await getAllMentorsAvailable(); | ||
const reqConsumables = await bc.payment().service().consumable() | ||
.then((res) => res?.data?.mentorship_service_sets.map((mentorshipServiceSet) => bc.mentorship() | ||
.getServiceSet(mentorshipServiceSet?.id) | ||
.then((rs) => ({ | ||
...rs?.data, | ||
...mentorshipServiceSet, | ||
})))); | ||
|
||
const allConsumables = await Promise.all(reqConsumables); | ||
|
||
setConsumables(allConsumables); | ||
setAllMentorsAvailable(mentors); | ||
}; | ||
|
||
useEffect(() => { | ||
if (!mentorshipServices.isLoading && mentorshipServices?.data.length > 0) { | ||
getMentorsAndConsumables(); | ||
} | ||
}, [mentorshipServices]); | ||
|
||
const mentorsFiltered = mentorsByService.filter( | ||
(ment) => { | ||
const fullName = `${ment.user.first_name} ${ment.user.last_name}`.toLowerCase(); | ||
return ( | ||
fullName.includes(searchProps.mentorSearch) | ||
&& ment.services.some((sv) => sv.status === 'ACTIVE' && sv.slug === mentoryProps?.service?.slug) | ||
); | ||
}, | ||
); | ||
|
||
const filterServices = () => { | ||
if (subscriptionData?.selected_mentorship_service_set?.mentorship_services?.length > 0) { | ||
return subscriptionData?.selected_mentorship_service_set?.mentorship_services?.filter( | ||
(l) => l.name.toLowerCase().includes(searchProps.serviceSearch), | ||
); | ||
} | ||
if (mentorshipServices.data.length > 0) { | ||
return mentorshipServices.data?.filter( | ||
(l) => l.name.toLowerCase().includes(searchProps.serviceSearch), | ||
); | ||
} | ||
|
||
return []; | ||
}; | ||
const suscriptionServicesFiltered = filterServices(); | ||
|
||
useEffect(() => { | ||
if (mentoryProps.serviceSelected) { | ||
fetchSubscriptions() | ||
.then((data) => { | ||
setSubscriptionData(data); | ||
reportDatalayer({ | ||
dataLayer: { | ||
event: 'subscriptions_load', | ||
method: 'native', | ||
plan_financings: data?.plan_financings?.filter((s) => s.status === 'ACTIVE').map((s) => s.plans.filter((p) => p.status === 'ACTIVE').map((p) => p.slug).join(',')).join(','), | ||
subscriptions: data?.subscriptions?.filter((s) => s.status === 'ACTIVE').map((s) => s.plans.filter((p) => p.status === 'ACTIVE').map((p) => p.slug).join(',')).join(','), | ||
}, | ||
}); | ||
}); | ||
} | ||
}, [mentoryProps.serviceSelected]); | ||
|
||
return !isLoading && user && !mentorshipServices.isLoading && ( | ||
<Container as="div" height="100%" maxWidth="full" minHeight="87.5vh" display="flex" flexDirection="column" padding={0} background={() => useColorModeValue('#f9f9f9', '#171f2a')} overflow="hidden"> | ||
<Link href="/choose-program" color="#0196d1" display="inline-block" letterSpacing="0.05em" fontWeight="700" width="fit-content" padding="3rem 0 0.6rem 1rem"> | ||
<Box display="flex" alignItems="center" justifyContent="center" gap="5px"> | ||
<Icon icon="arrowLeft2" color="#0196d1" width="15px" height="15px" /> | ||
<Box as="span">{`${t('back-to-dashboard')}`}</Box> | ||
</Box> | ||
</Link> | ||
<Container as="div" display="flex" flexDirection="column" justifyContent="center" alignItems="center" marginTop="2.5rem" textAlign="center" padding="0px" borderRadius="10px"> | ||
<Box textAlign="start"> | ||
<MentoringConsumables | ||
{...{ | ||
mentoryProps, | ||
width: !isTabletOrPhone ? '650px' : '350px', | ||
titleSize: !isTabletOrPhone && '30px', | ||
consumables, | ||
setMentoryProps, | ||
programServices: mentorshipServices.data, | ||
servicesFiltered: suscriptionServicesFiltered, | ||
searchProps, | ||
setSearchProps, | ||
setProgramMentors: setMentorsByService, | ||
mentorsFiltered, | ||
allMentorsAvailable, | ||
subscriptionData, | ||
allSubscriptions: subscriptionData.subscriptions, | ||
queryService: service, | ||
queryMentor: mentor, | ||
}} | ||
/> | ||
</Box> | ||
</Container> | ||
</Container> | ||
); | ||
} | ||
|
||
export default MentorshipSchedule; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the connector for from common.json instead of adding here another line