Skip to content

Commit

Permalink
Merge pull request #1730 from breatheco-de/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
tommygonzaleza authored Dec 12, 2024
2 parents 3f8ec22 + 52ad012 commit 22eae0a
Show file tree
Hide file tree
Showing 18 changed files with 656 additions and 484 deletions.
2 changes: 1 addition & 1 deletion i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = {
'/workshops/[event_slug]': ['workshops', 'signup'],
'/join/cohort/[id]': ['dashboard', 'signup'],
'/podcast': ['podcast'],
'/accept-invite': ['accept-invite'],
'/accept-invite': ['accept-invite', 'signup'],
'/bootcamp/[course_slug]': ['course', 'dashboard'],
},
locales: ['en', 'es'],
Expand Down
8 changes: 7 additions & 1 deletion public/locales/en/accept-invite.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{
"heading": "You have been invited to {{name}}, please fill out the following information to start learning",
"error": "Something went wrong"
"error": "Something went wrong",
"no-token": "You must include an invite token to see the invite",
"already-accepted": "The invite has been accepted already",
"new-invite": "You have been invited to {{course}}",
"invalid-user": "This invitation belongs to another user",
"accept-and-learn": "Accept and start learning",
"belongs-to-other-user": "This invitation belongs to another user"
}
3 changes: 2 additions & 1 deletion public/locales/en/technologies.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
"loading-workshops": "error loading workshops",
"no-data": "There are no assets for this technology"
},
"start-learning": "Start learning {{technology}}",
"backToLessons": "Back to Lessons",
"title": "{{technology}}",
"search": "Search lesson",
"description": "Browse our list of curated database of projects, exercises, and lessons to learn {{technology}}",
"tech-materials": "{{tech}} learning materials",
"tech-workshops": "{{tech}} workshops",
"request-mentorship": "Request a mentorship",
"request-mentorship": "Get {{tech}} mentorship",
"popular-exercises": "Popular exercises",
"lessons-section": "Lessons section",
"exercises-section": "Exercises section",
Expand Down
8 changes: 7 additions & 1 deletion public/locales/es/accept-invite.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{
"heading": "Has sido invitado a {{name}}, por favor completa la siguiente información para comenzar a aprender",
"error": "Algo ha salido mal"
"error": "Algo ha salido mal",
"no-token": "Debes incluir un token de invitación para ver la invitación",
"already-accepted": "La invitacion ya fue aceptada",
"new-invite": "Has sido invitado a {{course}}",
"invalid-user": "Esta invitacion pertenece a otro usuario",
"accept-and-learn": "Acepta y empieza a aprender",
"belongs-to-other-user": "Esta invitacion pertenece a otro usuario"
}
3 changes: 2 additions & 1 deletion public/locales/es/technologies.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
"loading-workshops": "error cargando los workshops",
"no-data": "No se encontró assets para esta tecnología"
},
"start-learning": "Empezar a aprender {{technology}}",
"backToLessons": "Regresar a lecciones",
"title": "{{technology}}",
"search": "Buscar lección",
"description": "Explore nuestra lista seleccionada de proyectos, ejercicios y lecciones para aprender {{technology}}",
"tech-materials": "Materiales de aprendizaje de {{tech}}",
"tech-workshops": "{{tech}} workshops",
"request-mentorship": "Solicitar una mentoria",
"request-mentorship": "Obtener mentoria de {{tech}}",
"popular-exercises": "Ejercicios populares",
"lessons-section": "Sección de lecciones",
"exercises-section": "Sección de ejercicios",
Expand Down
23 changes: 23 additions & 0 deletions src/common/components/Icon/set/arrowLeft3.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const arrowLeft3 = ({
style, width, height, color,
}) => (
<svg
style={style}
width={width || '20px'}
height={height || '20px'}
viewBox="0 0 8 14"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M7 1L1 7L7 13"
stroke={color || '#0097CF'}
strokeWidth="2"
strokeMiterlimit="10"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
);

export default arrowLeft3;
6 changes: 3 additions & 3 deletions src/common/components/MarkDownParser/ArticleMarkdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Toc from './toc';
import ContentHeading from './ContentHeading';
import SubTasks from './SubTasks';
import MarkDownParser from './index';
import OpenWithLearnpackCTA from '../../../js_modules/syllabus/OpenWithLearnpackCTA';
import ProjectInstructions from '../../../js_modules/syllabus/ProjectInstructions';

function ArticleMarkdown({
content, withToc, frontMatter, titleRightSide, currentTask, currentData,
Expand All @@ -20,8 +20,8 @@ function ArticleMarkdown({
{!isGuidedExperience && (
<ContentHeading
titleRightSide={titleRightSide}
callToAction={(currentData?.interactive || currentData?.asset_type === 'PROJECT') && (
<OpenWithLearnpackCTA currentAsset={currentData} />
callToAction={(currentData?.interactive || currentData?.template_url) && (
<ProjectInstructions currentAsset={currentData} />
)}
content={frontMatter}
currentData={currentData}
Expand Down
6 changes: 1 addition & 5 deletions src/common/components/MarkDownParser/MDComponents/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,7 @@ function QuoteVersion4({ ...props }) {
);
}
export function Quote({ children }) {
const [version, setVersion] = useState(2);

useEffect(() => {
setVersion(Math.floor(Math.random() * 4) + 1);
}, []);
const version = 1;
if (version === 1 && children.length > 0) {
return (
<QuoteVersion1>
Expand Down
53 changes: 49 additions & 4 deletions src/common/components/Navbar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ function NavbarWithSubNavigation({ translations, pageProps }) {
const isUtmMediumAcademy = userSession?.utm_medium === 'academy';
const { isAuthenticated, isLoading, user, logout } = useAuth();
const [ITEMS, setITEMS] = useState([]);
const [allSubscriptions, setAllSubscriptions] = useState([]);
const [mktCourses, setMktCourses] = useState([]);
const [userCohorts, setUserCohorts] = useState([]);
const { state } = useCohortHandler();
Expand Down Expand Up @@ -85,9 +86,53 @@ function NavbarWithSubNavigation({ translations, pageProps }) {
selectedProgramSlug: '/choose-program',
}, { returnObjects: true });

const items = t('ITEMS', {
selectedProgramSlug: selectedProgramSlug || '/choose-program',
}, { returnObjects: true });
useEffect(() => {
if (cohortSession?.available_as_saas) {
bc.payment({
status: 'ACTIVE,FREE_TRIAL,FULLY_PAID,CANCELLED,PAYMENT_ISSUE',
}).subscriptions()
.then(async ({ data }) => {
const planFinancings = data?.plan_financings?.length > 0 ? data?.plan_financings : [];
const subscriptions = data?.subscriptions?.length > 0 ? data?.subscriptions : [];

setAllSubscriptions([...planFinancings, ...subscriptions]);
});
}
}, [cohortSession]);

const allowNavigation = () => {
const getAdditionalInfo = () => {
if (allSubscriptions) {
const currentSessionSubs = allSubscriptions?.filter((sub) => sub.academy?.id === cohortSession?.academy?.id);
const cohortSubscriptions = currentSessionSubs?.filter((sub) => sub.selected_cohort_set?.cohorts.some((cohort) => cohort.id === cohortSession.id));

if (cohortSubscriptions.length === 0) {
return false;
}

const fullyPaidSub = cohortSubscriptions.find((sub) => sub.status === 'FULLY_PAID' || sub.status === 'ACTIVE');
if (fullyPaidSub) {
return true;
}

const freeTrialSub = cohortSubscriptions.find((sub) => sub.status === 'FREE_TRIAL');
const freeTrialExpDate = new Date(freeTrialSub?.valid_until);
const todayDate = new Date();

if (todayDate > freeTrialExpDate) {
return false;
}
return true;
}
return false;
};

if (cohortSession?.available_as_saas === true && cohortSession.cohort_role === 'STUDENT') return getAdditionalInfo();
if (Object.keys(cohortSession).length > 0 && (cohortSession.cohort_role !== 'STUDENT' || cohortSession.available_as_saas === false)) return true;
return false;
};

const items = t('ITEMS', { selectedProgramSlug: allowNavigation() ? selectedProgramSlug : '/choose-program' }, { returnObjects: true });

axios.defaults.headers.common['Accept-Language'] = locale;

Expand Down Expand Up @@ -165,7 +210,7 @@ function NavbarWithSubNavigation({ translations, pageProps }) {
setITEMS(
preFilteredItems
.filter((item) => (item.disabled !== true && item.hide_on_auth !== true)
&& (item.id !== 'bootcamps' || !isBootcampStudent)),
&& (item.id !== 'bootcamps' || !isBootcampStudent)),
);
} else {
setITEMS(preFilteredItems.filter((item) => item.disabled !== true));
Expand Down
3 changes: 2 additions & 1 deletion src/common/hooks/useModuleHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ function useModuleHandler() {
};

try {
await bc.todo({}).update(taskToUpdate);
const { cohort, ...taskData } = taskToUpdate;
await bc.todo().update(taskData);
const keyIndex = taskTodo.findIndex((x) => x.id === task.id);
setTaskTodo([
...taskTodo.slice(0, keyIndex), // before keyIndex (inclusive)
Expand Down
4 changes: 2 additions & 2 deletions src/js_modules/syllabus/ExerciseGuidedExperience.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import useTranslation from 'next-translate/useTranslation';
import PropTypes from 'prop-types';
import { intervalToDuration } from 'date-fns';
import { intervalToHours } from '../../utils';
import OpenWithLearnpackCTA from './OpenWithLearnpackCTA';
import ProjectInstructions from './ProjectInstructions';
import useStyle from '../../common/hooks/useStyle';
import ReactPlayerV2 from '../../common/components/ReactPlayerV2';
import KPI from '../../common/components/KPI';
Expand Down Expand Up @@ -168,7 +168,7 @@ function ExerciseGuidedExperience({ currentTask, currentAsset, handleStartLearnp
</Box>
)}
</Box>
<OpenWithLearnpackCTA currentAsset={currentAsset} handleStartLearnpack={handleStartLearnpack} />
<ProjectInstructions currentAsset={currentAsset} handleStartLearnpack={handleStartLearnpack} />
</>
)}
</Box>
Expand Down
4 changes: 2 additions & 2 deletions src/js_modules/syllabus/ProjectBoardGuidedExperience.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import SubtasksPill from './SubtasksPill';
import StatusPill from './StatusPill';
import Topbar from './Topbar';
import TaskCodeRevisions from './TaskCodeRevisions';
import OpenWithLearnpackCTA from './OpenWithLearnpackCTA';
import ProjectInstructions from './ProjectInstructions';
import useModuleHandler from '../../common/hooks/useModuleHandler';
import useStyle from '../../common/hooks/useStyle';
import ReactPlayerV2 from '../../common/components/ReactPlayerV2';
Expand Down Expand Up @@ -59,7 +59,7 @@ function ProjectHeading({ currentAsset, isDelivered, handleStartLearnpack }) {
)}
</Box>
<Box>
<OpenWithLearnpackCTA variant="small" currentAsset={currentAsset} handleStartLearnpack={handleStartLearnpack} />
<ProjectInstructions variant="small" currentAsset={currentAsset} handleStartLearnpack={handleStartLearnpack} />
</Box>
</Box>
</Box>
Expand Down
Loading

0 comments on commit 22eae0a

Please sign in to comment.