Skip to content

Commit f40e669

Browse files
committed
fix: fix 2024 diversity route
1 parent 5c20e64 commit f40e669

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1329
-1373
lines changed

src/2023/Cfp/CfpSection2023.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ describe("CfpSection2023", () => {
9898
render(<CfpSection2023 />);
9999
await waitFor(() => {
100100
expect(document.title).toBe(
101-
`CFP Committee - DevBcn - ${conferenceData.edition}`,
101+
`CFP Committee DevBcn - Barcelona Developers Conference — ${conferenceData.edition}`,
102102
);
103103
});
104104
});

src/2023/Cfp/CfpSection2023.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
StyledAboutImage,
2222
StyledSocialIconsWrapper,
2323
} from "../../views/About/components/Style.AboutCard";
24+
import { useDocumentTitleUpdater } from "../../services/useDocumentTitleUpdate";
2425

2526
const TrackName = styled.h2`
2627
padding-top: 1.2rem;
@@ -75,9 +76,8 @@ const CfpTrackComponent: FC<React.PropsWithChildren<CfpTrackProps>> = ({
7576

7677
const CfpSection2023: FC<React.PropsWithChildren<unknown>> = () => {
7778
const { width } = useWindowSize();
78-
React.useEffect(() => {
79-
document.title = `CFP Committee - DevBcn - ${conferenceData.edition}`;
80-
}, []);
79+
80+
useDocumentTitleUpdater("CFP Committee", conferenceData.edition);
8181
return (
8282
<>
8383
<SectionWrapper color={Color.WHITE} marginTop={5}>

src/2023/Communities/Communities2023.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import styled from "styled-components";
33
import TwitterIcon from "../../components/Icons/Twitter";
44
import { Color } from "../../styles/colors";
55
import WebsiteIcon from "../../components/Icons/website";
6+
import { useDocumentTitleUpdater } from "../../services/useDocumentTitleUpdate";
67

78
const Heading = styled.h1`
89
padding-top: 10rem;
@@ -29,9 +30,7 @@ const FoSS = styled.div`
2930
`;
3031

3132
const Communities2023: FC<React.PropsWithChildren<unknown>> = () => {
32-
React.useEffect(() => {
33-
document.title = "Communities";
34-
});
33+
useDocumentTitleUpdater("Communities", "2023");
3534
return (
3635
<>
3736
<Heading>FOSS & Diversity Communities</Heading>

src/2023/Diversity/Diversity2023.tsx

+29-30
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FC, useEffect } from "react";
1+
import { FC } from "react";
22
import { Color } from "../../styles/colors";
33
import data from "../../data/2023.json";
44
import styled from "styled-components";
@@ -8,25 +8,26 @@ import {
88
ROUTE_CODE_OF_CONDUCT,
99
ROUTE_CONDITIONS,
1010
} from "../../constants/routes";
11+
import { useDocumentTitleUpdater } from "../../services/useDocumentTitleUpdate";
1112

1213
const StyledSection = styled.section`
13-
{
14+
{
1415
padding-top: 48px;
15-
}
16+
}
1617
17-
.top {
18-
clip-path: polygon(0 0, 100% 0, 100% 100%, 0 calc(100% - 50px));
19-
height: 51px;
20-
background-color: ${Color.DARK_BLUE};
21-
border-top: 1px solid ${Color.DARK_BLUE};
22-
}
18+
.top {
19+
clip-path: polygon(0 0, 100% 0, 100% 100%, 0 calc(100% - 50px));
20+
height: 51px;
21+
background-color: ${Color.DARK_BLUE};
22+
border-top: 1px solid ${Color.DARK_BLUE};
23+
}
2324
24-
.bottom {
25-
clip-path: polygon(0 0, 100% 50px, 100% 100%, 0 100%);
26-
margin-top: -50px;
27-
height: 50px;
28-
background-color: ${Color.WHITE};
29-
}
25+
.bottom {
26+
clip-path: polygon(0 0, 100% 50px, 100% 100%, 0 100%);
27+
margin-top: -50px;
28+
height: 50px;
29+
background-color: ${Color.WHITE};
30+
}
3031
`;
3132

3233
const StyledWave = styled.section`
@@ -36,15 +37,15 @@ const StyledWave = styled.section`
3637
`;
3738

3839
const StyledLogo = styled.img`
39-
{
40+
{
4041
max-width: 30vw;
4142
flex: 2 1 auto;
4243
padding-bottom: 50px;
43-
}
44-
@media only screen and (max-width: ${BIG_BREAKPOINT}px) {
45-
padding-bottom: 20px;
46-
max-width: 65vw;
47-
}
44+
}
45+
@media only screen and (max-width: ${BIG_BREAKPOINT}px) {
46+
padding-bottom: 20px;
47+
max-width: 65vw;
48+
}
4849
`;
4950

5051
const Heading = styled.h1`
@@ -68,17 +69,17 @@ const StyledP = styled.p`
6869
`;
6970

7071
const FlexDiv = styled.div`
71-
{
72+
{
7273
display: flex;
7374
width: 20%;
7475
margin: 0 auto;
7576
flex-direction: column;
7677
padding-bottom: 20px;
77-
}
78-
@media only screen and (max-width: ${BIG_BREAKPOINT}px) {
79-
width: 60%;
80-
padding-bottom: 0.5rem;
81-
}
78+
}
79+
@media only screen and (max-width: ${BIG_BREAKPOINT}px) {
80+
width: 60%;
81+
padding-bottom: 0.5rem;
82+
}
8283
`;
8384

8485
const StyledParagraph = styled.section`
@@ -96,9 +97,7 @@ const StyledParagraph = styled.section`
9697
}
9798
`;
9899
const Diversity2023: FC<React.PropsWithChildren<unknown>> = () => {
99-
useEffect(() => {
100-
document.title = `Diversity - DevBcn ${data.edition}`;
101-
});
100+
useDocumentTitleUpdater("Diversity", data.edition);
102101

103102
return (
104103
<StyledSection className="styled-section">

src/2023/Home/Home2023Wrapper.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Sponsors from "./components/Sponsors/Sponsors";
77
import styled from "styled-components";
88
import data from "../../data/2023.json";
99
import { useLocation } from "react-router";
10+
import { useDocumentTitleUpdater } from "../../services/useDocumentTitleUpdate";
1011

1112
const StyledContainer = styled.div`
1213
padding-bottom: 10rem;
@@ -20,12 +21,13 @@ export const Home2023Wrapper: FC<React.PropsWithChildren<unknown>> = () => {
2021
const { hash } = useLocation();
2122

2223
React.useEffect(() => {
23-
document.title = `Home - DevBcn - ${data.edition}`;
2424
if (hash != null && hash !== "") {
2525
const scroll = document.getElementById(hash.substring(1));
2626
scroll?.scrollIntoView();
2727
}
2828
}, [hash]);
29+
30+
useDocumentTitleUpdater("Home", data.edition);
2931
return (
3032
<StyledContainer id="home-wrapper">
3133
<Home />

src/2023/Home/components/SpeakersCarousel/SpeakerSwiper.tsx

+24-5
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ import "swiper/swiper-bundle.min.css";
77
import "./SpeakersCarousel.scss";
88
import { Link } from "react-router";
99
import { ROUTE_SPEAKER_DETAIL } from "../../../../constants/routes";
10-
import * as Sentry from "@sentry/react";
1110

1211
import conferenceData from "../../../../data/2023.json";
1312
import { useFetchSpeakers } from "../../../../views/Speakers/UseFetchSpeakers";
13+
import { useSentryErrorReport } from "../../../../services/useSentryErrorReport";
14+
import { ISpeaker } from "../../../../types/speakers";
1415

1516
const StyledSlideImage = styled.img`
1617
display: block;
@@ -36,16 +37,34 @@ const StyledSlideText = styled.p`
3637
font-size: 0.875rem;
3738
color: white;
3839
`;
40+
41+
/** Fisher-Yates shuffle algorithm using window.crypto.getRandomValues() */
42+
export const shuffleArray = <T,>(array: T[]): T[] => {
43+
if (!array) {
44+
return [];
45+
}
46+
const shuffledArray = [...array]; // Create a copy to avoid modifying the original array
47+
for (let i = shuffledArray.length - 1; i > 0; i--) {
48+
const j = Math.floor(
49+
(window.crypto.getRandomValues(new Uint32Array(1))[0] /
50+
(0xffffffff + 1)) *
51+
(i + 1),
52+
);
53+
[shuffledArray[i], shuffledArray[j]] = [shuffledArray[j], shuffledArray[i]];
54+
}
55+
return shuffledArray;
56+
};
57+
3958
const SpeakerSwiper: FC<React.PropsWithChildren<unknown>> = () => {
4059
const { isLoading, data, error } = useFetchSpeakers(
4160
conferenceData.sessionizeUrl,
4261
);
4362

44-
const swiperSpeakers = data?.sort(() => 0.5 - Math.random()).slice(0, 20);
63+
const swiperSpeakers: ISpeaker[] = data
64+
? shuffleArray(data).slice(0, 20)
65+
: [];
4566

46-
if (error) {
47-
Sentry.captureException(error);
48-
}
67+
useSentryErrorReport(error);
4968

5069
return (
5170
<>

src/2023/JobOffers/JobOffers2023.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
StyledTitleContainer,
1818
} from "./JobOffers.Style";
1919
import CompanyOffers from "./CompanyOffers";
20+
import { useDocumentTitleUpdater } from "../../services/useDocumentTitleUpdate";
2021

2122
const NoOffersAvailable = () => (
2223
<>
@@ -40,9 +41,7 @@ const MoreThanLessThan = (props: { width: number }) => (
4041
const JobOffers2023: FC<React.PropsWithChildren<unknown>> = () => {
4142
const { width } = useWindowSize();
4243

43-
React.useEffect(() => {
44-
document.title = `Job Offers - DevBcn - ${data.edition}`;
45-
}, []);
44+
useDocumentTitleUpdater("Job Offers", data.edition);
4645

4746
return (
4847
<SectionWrapper color={Color.WHITE} marginTop={6} paddingBottom={100}>

src/2023/Schedule/Schedule2023.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ import {
1313
StyledScheduleSection,
1414
} from "./Schedule.style";
1515
import * as Sentry from "@sentry/react";
16+
import { useDocumentTitleUpdater } from "../../services/useDocumentTitleUpdate";
1617

1718
const Schedule2023: FC<React.PropsWithChildren<unknown>> = () => {
1819
const { width } = useWindowSize();
1920

20-
React.useEffect(() => {
21-
document.title = `Schedule - DevBcn - ${data.edition}`;
21+
useDocumentTitleUpdater("Schedule", data.edition);
2222

23+
React.useEffect(() => {
2324
fetch("https://sessionize.com/api/v2/a2sw0wks/view/GridSmart")
2425
.then((value) => value.text())
2526
.then((value) => {

src/2023/SessionFeedback/SessionFeedback2023.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { FilterMatchMode } from "primereact/api";
1515
import { Color } from "../../styles/colors";
1616
import { Link } from "react-router";
1717
import { ROUTE_TALK_DETAIL } from "../../constants/routes";
18+
import { useDocumentTitleUpdater } from "../../services/useDocumentTitleUpdate";
1819

1920
const SessionFeedback2023: FC<React.PropsWithChildren<unknown>> = () => {
2021
const bodyTemplate = React.useCallback(
@@ -64,9 +65,7 @@ const SessionFeedback2023: FC<React.PropsWithChildren<unknown>> = () => {
6465
</div>
6566
);
6667

67-
React.useEffect(() => {
68-
document.title = "DevBcn 2023 - Session Feedback";
69-
});
68+
useDocumentTitleUpdater("Session Feedback", "2023");
7069

7170
const header = renderHeader();
7271

src/2023/SpeakerDetail/SpeakerDetailContainer2023.tsx

+6-9
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ import SpeakerDetail2023 from "./SpeakerDetail2023";
66
import { useParams } from "react-router";
77
import { StyledContainer, StyledWaveContainer } from "./Speaker.style";
88
import conferenceData from "../../data/2023.json";
9-
import * as Sentry from "@sentry/react";
109
import { useFetchSpeakers } from "../../views/Speakers/UseFetchSpeakers";
10+
import { useSentryErrorReport } from "../../services/useSentryErrorReport";
11+
import { useDocumentTitleUpdater } from "../../services/useDocumentTitleUpdate";
1112

1213
const SpeakerDetailContainer2023: FC<React.PropsWithChildren<unknown>> = () => {
1314
const { id } = useParams<{ id: string }>();
@@ -17,14 +18,10 @@ const SpeakerDetailContainer2023: FC<React.PropsWithChildren<unknown>> = () => {
1718
id,
1819
);
1920

20-
if (error) {
21-
Sentry.captureException(error);
22-
}
23-
React.useEffect(() => {
24-
if (data) {
25-
document.title = `${data[0]?.fullName} - DevBcn - ${conferenceData.edition}`;
26-
}
27-
}, [id, data]);
21+
useSentryErrorReport(error);
22+
23+
useDocumentTitleUpdater(data?.[0]?.fullName ?? "", conferenceData.edition);
24+
2825
return (
2926
<StyledContainer>
3027
<SectionWrapper color={Color.BLUE} marginTop={4}>

src/2023/Speakers/Speakers2023.tsx

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { MOBILE_BREAKPOINT } from "../../constants/BreakPoints";
22
import { Color } from "../../styles/colors";
3-
import { FC, useCallback, useEffect } from "react";
3+
import { FC, useCallback } from "react";
44
import LessThanBlueIcon from "../../assets/images/LessThanBlueIcon.svg";
55
import MoreThanBlueIcon from "../../assets/images/MoreThanBlueIcon.svg";
66
import SectionWrapper from "../../components/SectionWrapper/SectionWrapper";
@@ -20,9 +20,10 @@ import {
2020
import webData from "../../data/2023.json";
2121
import Button from "../../components/UI/Button";
2222
import { gaEventTracker } from "../../components/analytics/Analytics";
23-
import * as Sentry from "@sentry/react";
2423
import { ISpeaker } from "../../types/speakers";
2524
import { useFetchSpeakers } from "../../views/Speakers/UseFetchSpeakers";
25+
import { useSentryErrorReport } from "../../services/useSentryErrorReport";
26+
import { useDocumentTitleUpdater } from "../../services/useDocumentTitleUpdate";
2627

2728
const LessThanGreaterThan = (props: { width: number }) => (
2829
<>
@@ -45,17 +46,13 @@ const Speakers2023: FC<React.PropsWithChildren<unknown>> = () => {
4546
`${webData.sessionizeUrl}/view/Speakers`,
4647
);
4748

48-
if (error) {
49-
Sentry.captureException(error);
50-
}
49+
useSentryErrorReport(error);
5150

5251
const trackCFP = useCallback(() => {
5352
gaEventTracker("CFP", "CFP");
5453
}, []);
5554

56-
useEffect(() => {
57-
document.title = `Speakers2023 - DevBcn ${webData.edition}`;
58-
});
55+
useDocumentTitleUpdater("Speakers 2023", webData.edition);
5956

6057
const CFPStartDay = new Date(webData.cfp.startDay);
6158
const CFPEndDay = new Date(webData.cfp.endDay);

src/2023/TalkDetail/TalkDetail.tsx

+5-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
MOBILE_BREAKPOINT,
55
} from "../../constants/BreakPoints";
66
import {Color} from "../../styles/colors";
7-
import React, {FC, Suspense, useEffect} from "react";
7+
import React, { FC, Suspense } from "react";
88
import LessThanIconWhite from "../../assets/images/LessThanIconWhite.svg";
99
import LessThanIcon from "../../assets/images/LessThanBlueIcon.svg";
1010
import MoreThanIcon from "../../assets/images/MoreThanBlueIcon.svg";
@@ -33,8 +33,9 @@ import {
3333
ROUTE_2023_TALKS,
3434
} from "../../constants/routes";
3535
import conferenceData from "../../data/2023.json";
36-
import {Tag} from "../../components/Tag/Tag";
37-
import {IMeetingDetailProps, MyType} from "../../types/sessions";
36+
import { Tag } from "../../components/Tag/Tag";
37+
import { IMeetingDetailProps, MyType } from "../../types/sessions";
38+
import { useDocumentTitleUpdater } from "../../services/useDocumentTitleUpdate";
3839

3940
const getVideoHeight = (windowWidth: number) => {
4041
let videoHeight;
@@ -102,9 +103,7 @@ const TalkDetail: FC<React.PropsWithChildren<IMeetingDetailProps>> = ({
102103
}) => {
103104
const { width } = useWindowSize();
104105

105-
useEffect(() => {
106-
document.title = `${meeting.title} - DevBcn ${conferenceData.edition}`;
107-
}, [meeting.title]);
106+
useDocumentTitleUpdater(meeting.title, conferenceData.edition);
108107

109108
const finalMeetingInfo: MyType = {
110109
...meeting,

0 commit comments

Comments
 (0)