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

Open
wants to merge 7 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 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 this mentoring service 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 este servicio de mentorías porque eres miembro del 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
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
152 changes: 96 additions & 56 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 @@ -44,6 +44,7 @@ function Subscriptions({ cohorts }) {
service_sets: [],
});
const [services, setServices] = useState({
nonSaasMentorships: [],
mentorships: [],
workshops: [],
});
Expand All @@ -64,6 +65,21 @@ 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 = {
nonSaasMentorships: [],
mentorships: [],
workshops: [],
};

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

if (Array.isArray(nonSaasServices)) allServices.nonSaasMentorships = nonSaasServices;

const res = await bc.payment().service().consumable();
if (res.status === 200) {
const { data } = res;
Expand All @@ -81,11 +97,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();
allServices.workshops = resWorkshops.flat();
}

setServices(allServices);
setLoadingServices(false);
} catch (e) {
setLoadingServices(false);
Expand All @@ -109,7 +125,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 @@ -147,6 +163,10 @@ function Subscriptions({ cohorts }) {
icon: 'teacher1',
title: t('subscription.your-mentoring-available'),
},
nonSaasMentorships: {
icon: 'teacher1',
title: t('subscription.your-mentoring-available'),
},
workshops: {
icon: 'community',
title: t('subscription.your-workshop-available'),
Expand All @@ -156,7 +176,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 +185,79 @@ 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 display="flex" flexWrap="wrap" gap="24px">
{services.nonSaasMentorships.length > 0 && (
<Box borderRadius="17px" padding="12px 16px" background={featuredLight} width={{ base: '100%', md: '265px' }}>
<Text size="sm" mb="10px" fontWeight="700">
{t('subscription.bootcamp-mentorships')}
</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" />
<Heading color={hexColor.fontColor3} sieze="l" fontWeight="700">
{services.nonSaasMentorships.length}
</Heading>
</Box>
<Button variant="link" onClick={() => setServicesModal('nonSaasMentorships')}>
{t('subscription.see-details')}
</Button>
</Box>
</Box>
)}
{!existsNoAvailableAsSaas && (
<>
{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.bootcamp-mentorships')}
</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>
<Button variant="link" onClick={() => setServicesModal('mentorships')}>
{t('subscription.see-details')}
</Button>
</Box>
</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 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>
<Button variant="link" onClick={() => setServicesModal('workshops')}>
{t('subscription.see-details')}
</Button>
</Box>
</Box>
</>
)}
</Box>
)}
</>
)}
</>
)}
</Box>
<Modal isOpen={servicesModal !== null} onClose={closeMentorshipsModal}>
<ModalOverlay />
<ModalContent>
Expand Down
Loading