diff --git a/bun.lockb b/bun.lockb index fe7c4344b..f479aac6b 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package-lock.json b/package-lock.json index 3a335a312..fee068f51 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33578,6 +33578,126 @@ "type": "github", "url": "https://github.com/sponsors/wooorm" } + }, + "node_modules/@next/swc-darwin-x64": { + "version": "13.5.3", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.5.3.tgz", + "integrity": "sha512-UpBKxu2ob9scbpJyEq/xPgpdrgBgN3aLYlxyGqlYX5/KnwpJpFuIHU2lx8upQQ7L+MEmz+fA1XSgesoK92ppwQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-gnu": { + "version": "13.5.3", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.5.3.tgz", + "integrity": "sha512-5AzM7Yx1Ky+oLY6pHs7tjONTF22JirDPd5Jw/3/NazJ73uGB05NqhGhB4SbeCchg7SlVYVBeRMrMSZwJwq/xoA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-musl": { + "version": "13.5.3", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.5.3.tgz", + "integrity": "sha512-A/C1shbyUhj7wRtokmn73eBksjTM7fFQoY2v/0rTM5wehpkjQRLOXI8WJsag2uLhnZ4ii5OzR1rFPwoD9cvOgA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-gnu": { + "version": "13.5.3", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.5.3.tgz", + "integrity": "sha512-FubPuw/Boz8tKkk+5eOuDHOpk36F80rbgxlx4+xty/U71e3wZZxVYHfZXmf0IRToBn1Crb8WvLM9OYj/Ur815g==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-musl": { + "version": "13.5.3", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.5.3.tgz", + "integrity": "sha512-DPw8nFuM1uEpbX47tM3wiXIR0Qa+atSzs9Q3peY1urkhofx44o7E1svnq+a5Q0r8lAcssLrwiM+OyJJgV/oj7g==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-arm64-msvc": { + "version": "13.5.3", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.5.3.tgz", + "integrity": "sha512-zBPSP8cHL51Gub/YV8UUePW7AVGukp2D8JU93IHbVDu2qmhFAn9LWXiOOLKplZQKxnIPUkJTQAJDCWBWU4UWUA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-ia32-msvc": { + "version": "13.5.3", + "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.5.3.tgz", + "integrity": "sha512-ONcL/lYyGUj4W37D4I2I450SZtSenmFAvapkJQNIJhrPMhzDU/AdfLkW98NvH1D2+7FXwe7yclf3+B7v28uzBQ==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-x64-msvc": { + "version": "13.5.3", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.5.3.tgz", + "integrity": "sha512-2Vz2tYWaLqJvLcWbbTlJ5k9AN6JD7a5CN2pAeIzpbecK8ZF/yobA39cXtv6e+Z8c5UJuVOmaTldEAIxvsIux/Q==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } } } } diff --git a/public/locales/en/profile.json b/public/locales/en/profile.json index 7d5c49ede..f16ceda2d 100644 --- a/public/locales/en/profile.json +++ b/public/locales/en/profile.json @@ -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", diff --git a/public/locales/es/profile.json b/public/locales/es/profile.json index 3378fa00c..4724802a8 100644 --- a/public/locales/es/profile.json +++ b/public/locales/es/profile.json @@ -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", diff --git a/src/common/components/ProfileForm.jsx b/src/common/components/ProfileForm.jsx index 1be515b07..a8e1a1fd5 100644 --- a/src/common/components/ProfileForm.jsx +++ b/src/common/components/ProfileForm.jsx @@ -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); diff --git a/src/common/hooks/useCohortHandler.js b/src/common/hooks/useCohortHandler.js index 16b0bd4a0..b2ee9f26e 100644 --- a/src/common/hooks/useCohortHandler.js +++ b/src/common/hooks/useCohortHandler.js @@ -265,6 +265,7 @@ function useCohortHandler() { getTasksWithoutCohort, userCapabilities, state, + setMyCohorts, }; } diff --git a/src/js_modules/profile/Subscriptions/index.jsx b/src/js_modules/profile/Subscriptions/index.jsx index 77defd8a1..bb0afa44e 100644 --- a/src/js_modules/profile/Subscriptions/index.jsx +++ b/src/js_modules/profile/Subscriptions/index.jsx @@ -1,5 +1,5 @@ +/* eslint-disable camelcase */ /* eslint-disable no-unsafe-optional-chaining */ -/* eslint-disable react/jsx-no-useless-fragment */ import { Box, Flex, @@ -64,6 +64,18 @@ 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; @@ -71,7 +83,7 @@ function Subscriptions({ cohorts }) { 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) => { @@ -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); @@ -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']; @@ -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 ( <> @@ -165,59 +177,57 @@ function Subscriptions({ cohorts }) {