Skip to content

Commit

Permalink
Merge pull request #1596 from breatheco-de/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
tommygonzaleza authored Sep 9, 2024
2 parents 39c52b3 + edb37b3 commit 3de19cd
Show file tree
Hide file tree
Showing 16 changed files with 193 additions and 325 deletions.
2 changes: 1 addition & 1 deletion public/locales/en/exercises.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"access-solution": "Now you can access the solution",
"similar-projects": "Now you can access similar projects",
"open-tutorial": "OPEN TUTORIAL ONLINE",
"open-learnpack": "Open with LearnPack",
"open-learnpack": "OPEN WITH LEARNPACK",
"clone": "CLONE LOCALLY",
"clone-tooltip": "Clone repository",
"how-to-clone": "Read more about cloning a project",
Expand Down
2 changes: 1 addition & 1 deletion public/locales/en/footer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"copyright": "©{{name}} LLC 2019",
"copyright": "©{{name}} LLC {{year}}",
"search":"Search in 4Geeks",
"subscribe": "Subscribe for more!",
"newsletter": {
Expand Down
2 changes: 1 addition & 1 deletion public/locales/es/exercises.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"access-solution": "Ahora puedes acceder a la solucion",
"similar-projects": "Ahora puedes acceder a proyectos similares",
"open-tutorial": "Abrir tutorial online",
"open-learnpack": "Abrir con LearnPack",
"open-learnpack": "ABRIR CON LEARNPACK",
"clone": "Clonar localmente",
"clone-tooltip": "Clonar repositorio",
"how-to-clone": "Leer más sobre cómo clonar un proyecto",
Expand Down
8 changes: 4 additions & 4 deletions scripts/prepare-asset-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ async function prepareAssetData() {

console.time('Time fetching data');

const lessons = await getAsset('LESSON,ARTICLE', { exclude_category: excludeCagetoriesFor.lessons, expand: 'technologies' }, 'lesson');
const excersises = await getAsset('EXERCISE', { expand: 'technologies' }, 'excersise');
const projects = await getAsset('PROJECT', { expand: 'technologies' }, 'project');
const howTos = await getAsset('LESSON,ARTICLE', { category: categoriesFor.howTo, expand: 'technologies' }, 'how-to');
const lessons = await getAsset('LESSON,ARTICLE', { exclude_category: excludeCagetoriesFor.lessons, expand: 'technologies,readme' }, 'lesson');
const excersises = await getAsset('EXERCISE', { expand: 'technologies,readme' }, 'excersise');
const projects = await getAsset('PROJECT', { expand: 'technologies,readme' }, 'project');
const howTos = await getAsset('LESSON,ARTICLE', { category: categoriesFor.howTo, expand: 'technologies,readme' }, 'how-to');
const events = await getEvents();
const landingTechnologies = await getLandingTechnologies([...lessons, ...projects, ...excersises, ...howTos]);

Expand Down
2 changes: 1 addition & 1 deletion src/common/components/AttendanceModal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ AttendanceModal.defaultProps = {
title: '',
message: '',
isOpen: true,
onClose: () => {},
onClose: () => { },
};

export default AttendanceModal;
30 changes: 3 additions & 27 deletions src/common/components/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import AlertMessage from './AlertMessage';
import useStyle from '../hooks/useStyle';
import useAuth from '../hooks/useAuth';
import bc from '../services/breathecode';
import logoData from '../../../public/logo.json';
import { GithubIcon, LogoIcon, YoutubeIcon } from './Icon/components';
import { log } from '../../utils/logging';
import FooterTC from './FooterTC';

function Footer({ pageProps }) {
const captcha = useRef(null);
Expand All @@ -34,14 +34,12 @@ function Footer({ pageProps }) {
const [formStatus, setFormStatus] = useState('');
const { isAuthenticated } = useAuth();

const copyrightName = pageProps?.existsWhiteLabel ? logoData.name : '4Geeks';
const actualYear = new Date().getFullYear();
const iconogram = t('iconogram', {}, { returnObjects: true });

const hideDivider = pageProps?.hideDivider === true;
if (pageProps?.previewMode) return null;

if (isAuthenticated) return <Container as="footer" mt="3rem" />;
if (isAuthenticated) return <FooterTC pageProps={pageProps} />;

return (
<Container background={hexColor.backgroundColor} as="footer" maxW="none" padding="20px" position="absolute" top="100%">
Expand Down Expand Up @@ -345,29 +343,7 @@ function Footer({ pageProps }) {
<Divider borderBottomWidth="2px" />
</>
)}
<Flex
key="copyright"
padding="20px 20px 0 20px"
justifyContent={['center', 'center', 'space-between', 'space-between']}
wrap={['wrap', 'wrap', 'nowrap', 'nowrap']}
// alignItems="center"
textAlign="center"
>
<Text marginBottom={['20px', '20px', '0', '0']} fontSize="sm">{t('copyright', { name: copyrightName, year: actualYear })}</Text>
<Flex
wrap={['wrap', 'wrap', 'nowrap', 'nowrap']}
justifyContent={['center', 'center', 'space-between', 'space-between']}
width={['100%', '100%', '35%', '25%']}
// alignItems="center"
>
<NextChakraLink href={t('terms.href')}>
<Text fontSize="sm">{t('terms.label')}</Text>
</NextChakraLink>
<NextChakraLink href={t('privacy.href')}>
<Text fontSize="sm">{t('privacy.label')}</Text>
</NextChakraLink>
</Flex>
</Flex>
<FooterTC />
</Container>
);
}
Expand Down
57 changes: 57 additions & 0 deletions src/common/components/FooterTC.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import React from 'react';
import {
Container,
Text,
Flex,
Divider,
} from '@chakra-ui/react';
import PropTypes from 'prop-types';
import useTranslation from 'next-translate/useTranslation';
import logoData from '../../../public/logo.json';
import NextChakraLink from './NextChakraLink';
import useAuth from '../hooks/useAuth';

function FooterTC({ pageProps }) {
const { t } = useTranslation('footer');
const copyrightName = pageProps?.existsWhiteLabel ? logoData.name : '4Geeks';
const actualYear = new Date().getFullYear();
const { isAuthenticated } = useAuth();

return (
<Container as={isAuthenticated && 'footer'} maxW>
<Divider borderBottomWidth="2px" marginTop={isAuthenticated && '50px'} />
<Flex
key="copyright"
padding="20px 20px 5px 20px"
justifyContent={['center', 'center', 'space-between', 'space-between']}
wrap={['wrap', 'wrap', 'nowrap', 'nowrap']}
// alignItems="center"
textAlign="center"
>
<Text marginBottom={['20px', '20px', '0', '0']} fontSize="sm">{t('copyright', { name: copyrightName, year: actualYear })}</Text>
<Flex
wrap={['wrap', 'wrap', 'nowrap', 'nowrap']}
justifyContent={['center', 'center', 'space-between', 'space-between']}
width={['100%', '100%', '35%', '25%']}
>
<NextChakraLink href={t('terms.href')}>
<Text fontSize="sm">{t('terms.label')}</Text>
</NextChakraLink>
<NextChakraLink href={t('privacy.href')}>
<Text fontSize="sm">{t('privacy.label')}</Text>
</NextChakraLink>
</Flex>
</Flex>
</Container>
);
}

FooterTC.propTypes = {
pageProps: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
};

FooterTC.defaultProps = {
pageProps: {},
};

export default FooterTC;
10 changes: 9 additions & 1 deletion src/common/components/Instructors.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,18 @@ import { adjustNumberBeetwenMinMax } from '../../utils';
import Heading from './Heading';
import Icon from './Icon';

function orderArrayByRole(array) {
return array.sort((a, b) => {
if (a.role === 'TEACHER') return -1;
if (b.role === 'TEACHER') return 1;
return 0;
});
}

function Instructors({ isLoading, list, limit, ...rest }) {
const { t } = useTranslation('common');
const { featuredColor } = useStyle();
const intructorsToShow = list.length > limit ? list.slice(0, limit) : list;
const intructorsToShow = list.length > limit ? orderArrayByRole(list.slice(0, limit)) : orderArrayByRole(list);
const restInstructors = list.length - limit;

return (
Expand Down
7 changes: 4 additions & 3 deletions src/common/components/LiveEvent/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,16 @@ function LiveEvent({

useEffect(() => {
let intervalVar;
// applyFilters();
updateTimes();

setTimeout(() => {
const timeoutId = setTimeout(() => {
updateTimes();
intervalVar = setInterval(updateTimes(), 60 * 1000);
intervalVar = setInterval(updateTimes, 60 * 1000);
}, secondsToNextMinute * 1000);

return () => {
clearInterval(intervalVar);
clearTimeout(timeoutId);
};
}, [mainClasses, otherEvents]);

Expand Down
2 changes: 1 addition & 1 deletion src/common/store/actions/signupAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ const useSignup = () => {
value: selectedPlanCheckoutData?.price,
currency,
payment_type: 'Credit card',
plan: selectedPlanCheckoutData?.slug,
plan: selectedPlanCheckoutData?.plan_slug,
period_label: selectedPlanCheckoutData?.period_label,
items: simplePlans,
},
Expand Down
1 change: 1 addition & 0 deletions src/pages/checkout/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ function Checkout() {
reportDatalayer({
dataLayer: {
event: 'begin_checkout',
plan: defaultPlan,
path: '/checkout',
conversion_info: userSession,
},
Expand Down
11 changes: 0 additions & 11 deletions src/pages/cohort/[cohortSlug]/[slug]/[version]/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import {
includesToLowerCase,
getStorageItem,
sortToNearestTodayDate,
syncInterval,
getBrowserSize,
calculateDifferenceDays,
adjustNumberBeetwenMinMax,
Expand Down Expand Up @@ -266,16 +265,6 @@ function Dashboard() {
},
});
});
syncInterval(() => {
setLiveClasses((prev) => {
const validatedEventList = prev?.length > 0
? prev?.filter((l) => isValidDate(l?.starting_at) && isValidDate(l?.ending_at))
: [];
const sortDateToLiveClass = sortToNearestTodayDate(validatedEventList, TwelveHours);
const existentLiveClasses = sortDateToLiveClass?.filter((l) => l?.hash && l?.starting_at && l?.ending_at);
return existentLiveClasses;
});
});
}, []);

// Fetch cohort data with pathName structure
Expand Down
69 changes: 21 additions & 48 deletions src/pages/how-to/[slug]/index.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable react/jsx-no-useless-fragment */
/* eslint-disable no-continue */
import { useEffect, useState } from 'react';
import { useRouter } from 'next/router';
import {
Expand All @@ -20,12 +18,9 @@ import TagCapsule from '../../../common/components/TagCapsule';
import MktRecommendedCourses from '../../../common/components/MktRecommendedCourses';
import GridContainer from '../../../common/components/GridContainer';
import MktSideRecommendedCourses from '../../../common/components/MktSideRecommendedCourses';
// import DynamicCallToAction from '../../../common/components/DynamicCallToAction';
// import PodcastCallToAction from '../../../common/components/PodcastCallToAction';
import { cleanObject } from '../../../utils/index';
import { ORIGIN_HOST, categoriesFor } from '../../../utils/variables';
import useStyle from '../../../common/hooks/useStyle';
import { getCacheItem, setCacheItem } from '../../../utils/requests';
import RelatedContent from '../../../common/components/RelatedContent';
import MktEventCards from '../../../common/components/MktEventCards';

Expand All @@ -50,44 +45,33 @@ export const getStaticProps = async ({ params, locale, locales }) => {
const { slug } = params;

try {
let data;
let markdown;
data = await getCacheItem(slug);
const langPrefix = locale === 'en' ? '' : `/${locale}`;
if (!data) {
console.log(`${slug} not found on cache`);
const assetList = await import('../../../lib/asset-list.json')
.then((res) => res.default)
.catch(() => []);
data = assetList.howTos.find((l) => l?.slug === slug);

const engPrefix = {
us: 'en',
en: 'en',
};
const assetList = await import('../../../lib/asset-list.json')
.then((res) => res.default)
.catch(() => []);
const data = assetList.howTos.find((l) => l?.slug === slug);

const isCurrenLang = locale === engPrefix[data?.lang] || locale === data?.lang;

if (!isCurrenLang) {
return {
notFound: true,
};
}
const engPrefix = {
us: 'en',
en: 'en',
};

const markdownResp = await fetch(`${process.env.BREATHECODE_HOST}/v1/registry/asset/${slug}.md`);
const isCurrenLang = locale === engPrefix[data?.lang] || locale === data?.lang;

if (markdownResp?.status >= 400) {
return {
notFound: true,
};
}
if (!isCurrenLang) {
return {
notFound: true,
};
}
const langPrefix = locale === 'en' ? '' : `/${locale}`;

markdown = await markdownResp.text();
await setCacheItem(slug, { ...data, markdown });
} else {
markdown = data.markdown;
if (!data.readme?.decoded) {
return {
notFound: true,
};
}

const markdown = data.readme.decoded;

const {
title, description, translations, preview,
} = data;
Expand Down Expand Up @@ -203,17 +187,6 @@ export default function HowToSlug({ data, markdown }) {
<GridContainer gridTemplateColumns="4fr repeat(12, 1fr)" margin={{ base: '0 10px', md: '0 auto' }} gridGap="36px" padding={{ base: '', md: '0 10px' }}>
<Box display={{ base: 'none', md: 'block' }} position={{ base: 'inherit', md: 'sticky' }} top="20px" height="fit-content" gridColumn="1 / span 1" margin={{ base: '0 0 40px', md: '6.2rem 0 0 0' }}>
<MktSideRecommendedCourses technologies={data.technologies} />
{/* <DynamicCallToAction
assetId={data.id}
assetTechnologies={data.technologies?.map((item) => item?.slug)}
assetType={data.asset_type.toLowerCase()}
placement="side"
marginTop="40px"
/>
<PodcastCallToAction
placement="side"
marginTop="40px"
/> */}
</Box>
<Box
gridColumn="2 / span 12"
Expand Down
Loading

0 comments on commit 3de19cd

Please sign in to comment.