Skip to content
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

Pricing change #1763

Merged
merged 8 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bun.lockb
Binary file not shown.
120 changes: 120 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions public/locales/en/profile.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
},
"subscription": {
"what-you-will-get": "What you will get:",
"bootcamp-mentorships": "You have unlimited access to those mentorship services with this icon ∞ because you belong to the bootcamp",
"mentoring-available": "Mentoring sessions available",
"your-mentoring-available": "Your mentoring services available",
"workshop-available": "Workshop sessions available",
Expand Down
1 change: 1 addition & 0 deletions public/locales/es/profile.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
},
"subscription": {
"what-you-will-get": "Lo que obtendrás:",
"bootcamp-mentorships": "Tienes acceso ilimitado a los servicios de mentoría con este ícono ∞ porque perteneces al bootcamp",
"mentoring-available": "Sesiones de mentorías disponibles",
"your-mentoring-available": "Tus servicios de mentorías disponibles",
"workshop-available": "Sesiones de workshops disponibles",
Expand Down
8 changes: 4 additions & 4 deletions src/common/components/ProfileForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ function ProfileForm() {

useEffect(() => {
const userSchema = {
first_name: user.first_name,
last_name: user.last_name,
email: user.email,
phone: user.phone,
first_name: user?.first_name,
last_name: user?.last_name,
email: user?.email,
phone: user?.phone,
};
setUserInfo(userSchema);
setDefaultUserInfo(userSchema);
Expand Down
1 change: 1 addition & 0 deletions src/common/hooks/useCohortHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ function useCohortHandler() {
getTasksWithoutCohort,
userCapabilities,
state,
setMyCohorts,
};
}

Expand Down
156 changes: 93 additions & 63 deletions src/js_modules/profile/Subscriptions/index.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable camelcase */
/* eslint-disable no-unsafe-optional-chaining */
/* eslint-disable react/jsx-no-useless-fragment */
import {
Box,
Flex,
Expand Down Expand Up @@ -64,14 +64,26 @@ function Subscriptions({ cohorts }) {

const getConsumables = async () => {
try {
const nonSaasCohorts = cohorts.filter(({ available_as_saas }) => !available_as_saas);
const academies = [...new Set(nonSaasCohorts.map(({ academy }) => academy.id))];

const allServices = {
mentorships: [],
workshops: [],
};

const cohortsServices = academies.map((academy) => bc.mentorship({ academy }, true).getService());
const responseServices = await Promise.all(cohortsServices);
const nonSaasServices = responseServices.flatMap(({ data }) => data).map((elem) => ({ ...elem, nonSaasAcademy: true }));

const res = await bc.payment().service().consumable();
if (res.status === 200) {
const { data } = res;
setConsumables(data);
const promiseMentorship = data.mentorship_service_sets.map(async (elem) => {
const mentRes = await bc.mentorship().getServiceSet(elem.id);

return mentRes.data.mentorship_services;
return mentRes.data.mentorship_services.map((service) => ({ ...service, unit: elem.balance.unit }));
});

const promiseEvents = data.event_type_sets.map(async (elem) => {
Expand All @@ -81,11 +93,11 @@ function Subscriptions({ cohorts }) {
});
const resMentorships = await Promise.all(promiseMentorship);
const resWorkshops = await Promise.all(promiseEvents);
setServices({
mentorships: resMentorships.flat(),
workshops: resWorkshops.flat(),
});
allServices.mentorships = [...resMentorships.flat(), ...nonSaasServices];
allServices.workshops = resWorkshops.flat();
}

setServices(allServices);
setLoadingServices(false);
} catch (e) {
setLoadingServices(false);
Expand All @@ -109,7 +121,7 @@ function Subscriptions({ cohorts }) {

const allSubscriptions = subscriptionData?.subscriptions
&& subscriptionData?.plan_financings
&& [...subscriptionData?.subscriptions, ...subscriptionData?.plan_financings]
&& [...subscriptionData.subscriptions, ...subscriptionData.plan_financings]
.filter((subscription) => subscription?.plans?.[0]?.slug !== undefined);

const prioritizeStatus = ['fully_paid', 'active', 'payment_issue', 'expired', 'cancelled', 'error'];
Expand Down Expand Up @@ -156,7 +168,7 @@ function Subscriptions({ cohorts }) {
const totalMentorshipsAvailable = consumables.mentorship_service_sets.reduce((acum, service) => acum + service.balance.unit, 0);
const totalWorkshopsAvailable = consumables.event_type_sets.reduce((acum, service) => acum + service.balance.unit, 0);

const existsNoAvailableAsSaas = cohorts.some((c) => c?.cohort?.available_as_saas === false);
const existsNoAvailableAsSaas = cohorts.some((c) => c.available_as_saas === false);

return (
<>
Expand All @@ -165,59 +177,57 @@ function Subscriptions({ cohorts }) {
<title>{t('my-subscriptions')}</title>
</Head>
)}
{!existsNoAvailableAsSaas && (
<Box display="flex" flexWrap="wrap" gap="24px">
{loadingServices ? (
<>
<SimpleSkeleton borderRadius="17px" height="108px" width={{ base: '100%', md: '265px' }} />
<SimpleSkeleton borderRadius="17px" height="108px" width={{ base: '100%', md: '265px' }} />
</>
) : (
<>
<Box borderRadius="17px" padding="12px 16px" background={featuredLight} width={{ base: '100%', md: '265px' }}>
<Text size="sm" mb="10px" fontWeight="700">
{t('subscription.mentoring-available')}
</Text>
<Box display="flex" justifyContent="space-between" alignItems="end">
<Box display="flex" gap="10px" alignItems="center">
<Icon icon="teacher1" color={hexColor.blueDefault} width="34px" height="34px" />
{totalMentorshipsAvailable >= 0 ? (
<Heading color={hexColor.fontColor3} sieze="l" fontWeight="700">
{totalMentorshipsAvailable}
</Heading>
) : (
<Icon icon="infinite" color={hexColor.fontColor3} width="34px" height="34px" />
)}
</Box>
<Button variant="link" onClick={() => setServicesModal('mentorships')}>
{t('subscription.see-details')}
</Button>
<Box display="flex" flexWrap="wrap" gap="24px">
{loadingServices ? (
<>
<SimpleSkeleton borderRadius="17px" height="108px" width={{ base: '100%', md: '265px' }} />
<SimpleSkeleton borderRadius="17px" height="108px" width={{ base: '100%', md: '265px' }} />
</>
) : (
<>
<Box borderRadius="17px" padding="12px 16px" background={featuredLight} width={{ base: '100%', md: '265px' }}>
<Text size="sm" mb="10px" fontWeight="700">
{t('subscription.mentoring-available')}
</Text>
<Box display="flex" justifyContent="space-between" alignItems="end">
<Box display="flex" gap="10px" alignItems="center">
<Icon icon="teacher1" color={hexColor.blueDefault} width="34px" height="34px" />
{(totalMentorshipsAvailable < 0 || existsNoAvailableAsSaas) ? (
<Icon icon="infinite" color={hexColor.fontColor3} width="34px" height="34px" />
) : (
<Heading color={hexColor.fontColor3} sieze="l" fontWeight="700">
{totalMentorshipsAvailable}
</Heading>
)}
</Box>
<Button variant="link" onClick={() => setServicesModal('mentorships')}>
{t('subscription.see-details')}
</Button>
</Box>
<Box borderRadius="17px" padding="12px 16px" background={featuredLight} width={{ base: '100%', md: '265px' }}>
<Text size="sm" mb="10px" fontWeight="700">
{t('subscription.workshop-available')}
</Text>
<Box display="flex" justifyContent="space-between" alignItems="end">
<Box display="flex" gap="10px" alignItems="center">
<Icon icon="community" color={hexColor.blueDefault} fill="none" width="34px" height="34px" />
{totalWorkshopsAvailable >= 0 ? (
<Heading color={hexColor.fontColor3} sieze="l" fontWeight="700">
{totalWorkshopsAvailable}
</Heading>
) : (
<Icon icon="infinite" color={hexColor.fontColor3} width="34px" height="34px" />
)}
</Box>
<Button variant="link" onClick={() => setServicesModal('workshops')}>
{t('subscription.see-details')}
</Button>
</Box>
<Box borderRadius="17px" padding="12px 16px" background={featuredLight} width={{ base: '100%', md: '265px' }}>
<Text size="sm" mb="10px" fontWeight="700">
{t('subscription.workshop-available')}
</Text>
<Box display="flex" justifyContent="space-between" alignItems="end">
<Box display="flex" gap="10px" alignItems="center">
<Icon icon="community" color={hexColor.blueDefault} fill="none" width="34px" height="34px" />
{totalWorkshopsAvailable >= 0 ? (
<Heading color={hexColor.fontColor3} sieze="l" fontWeight="700">
{totalWorkshopsAvailable}
</Heading>
) : (
<Icon icon="infinite" color={hexColor.fontColor3} width="34px" height="34px" />
)}
</Box>
<Button variant="link" onClick={() => setServicesModal('workshops')}>
{t('subscription.see-details')}
</Button>
</Box>
</>
)}
</Box>
)}
</Box>
</>
)}
</Box>
<Modal isOpen={servicesModal !== null} onClose={closeMentorshipsModal}>
<ModalOverlay />
<ModalContent>
Expand All @@ -231,19 +241,39 @@ function Subscriptions({ cohorts }) {
{services[servicesModal].map((service) => {
const logo = service.logo_url || service.icon_url;
return (
<Box mb="10px" background={hexColor.featuredColor} padding="10px" borderRadius="4px">
<Box display="flex" gap="10px" alignItems="center" mb="5px">
{logo && <Image src={logo} width={28} height={28} alt="Service logo" />}
<Heading size="16px">
{service.name}
</Heading>
<Box key={service.slug} mb="10px" background={hexColor.featuredColor} padding="10px" borderRadius="4px">
<Box justifyContent="space-between" display="flex" gap="10px" alignItems="center" mb="5px" width="100%">
<Box display="flex" gap="10px" alignItems="center">
{logo && <Image src={logo} width={28} height={28} alt="Service logo" />}
<Heading size="16px">
{service.name}
</Heading>
</Box>
{servicesModal === 'mentorships' && (
<>
{service.nonSaasAcademy ? (
<Icon icon="infinite" color={hexColor.fontColor3} />
) : (
<Box width="30px" height="30px" background={hexColor.featuredColor3} padding="5px" borderRadius="full">
<Text textAlign="center" size="l" fontWeight="700">
{service.unit}
</Text>
</Box>
)}
</>
)}
</Box>
<Text size="md" color={hexColor.fontColor3}>
{service.description}
</Text>
</Box>
);
})}
{servicesModal === 'mentorships' && existsNoAvailableAsSaas && (
<Text>
{t('subscription.bootcamp-mentorships')}
</Text>
)}
</ModalBody>
</>
)}
Expand Down
Loading