diff --git a/new-dti-website/components/team/TeamAbout.tsx b/new-dti-website/components/team/TeamAbout.tsx new file mode 100644 index 000000000..445d6e302 --- /dev/null +++ b/new-dti-website/components/team/TeamAbout.tsx @@ -0,0 +1,244 @@ +import { Dispatch, SetStateAction, useState } from 'react'; +import Image from 'next/image'; +import { ibm_plex_mono } from '../../src/app/layout'; +import FA23Members from '../../../backend/src/members-archive/fa23.json'; + +type roleStatistics = { + [key: string]: { + name: string; + color: string; + people: number; + majors: Set; + colleges: Set; + }; +}; + +type PieChartProps = { + width: number; + height: number; + chartSection: string | undefined; + setChartSection: Dispatch>; + roleStats: roleStatistics; + allMembers: WebsiteMember[]; +}; + +const PieChart: React.FC = ({ + width, + height, + chartSection, + setChartSection, + roleStats, + allMembers +}) => { + const radius = 175; + const hoverRadius = 190; + let previousPoint = [0, -radius]; + let totalAngle = 0; + + const polarToRect = (angle: number, radius: number) => { + const newX = -radius * Math.cos(angle + Math.PI / 2); + const newY = -radius * Math.sin(angle + Math.PI / 2); + return [newX, newY]; + }; + + const pointAsString = (point: number[]) => point.join(' '); + const scale = (point: number[], scalar: number) => point.map((x) => scalar * x); + + return ( + + {Object.keys(roleStats).map((role) => { + const percentage = roleStats[role].people / allMembers.length; + const theta = 2 * Math.PI * percentage; + + const arcPoint1 = + role === chartSection ? scale(previousPoint, hoverRadius / radius) : previousPoint; + const currentRadius = role === chartSection ? hoverRadius : radius; + + totalAngle += theta; + const arcPoint2 = polarToRect(totalAngle, role === chartSection ? hoverRadius : radius); + + const nextPoint = polarToRect(totalAngle, radius); + const textLocation = polarToRect((2 * totalAngle - theta) / 2, (3 * radius) / 4); + previousPoint = nextPoint; + + return ( + setChartSection(role)} + onMouseLeave={() => setChartSection(undefined)} + > + Math.PI ? `1` : `0` + } 1 ${pointAsString(arcPoint2)} L 0 0`} + fill={roleStats[role].color} + /> + + {`${Math.round(percentage * 100)}%`} + + + ); + })} + + ); +}; + +const TeamStatistics = () => { + const [chartSection, setChartSection] = useState(undefined); + + const allMembers = FA23Members.members; + + const roleStats: roleStatistics = { + designer: { + name: 'Design', + color: '#FFBCBC', + people: 0, + majors: new Set(), + colleges: new Set() + }, + developer: { + name: 'Development', + color: '#D63D3D', + people: 0, + majors: new Set(), + colleges: new Set() + }, + pm: { name: 'Product', color: '#FFFFFF', people: 0, majors: new Set(), colleges: new Set() }, + business: { + name: 'Business', + color: '#B7B7B7', + people: 0, + majors: new Set(), + colleges: new Set() + }, + lead: { name: 'Leads', color: '#484848', people: 0, majors: new Set(), colleges: new Set() } + }; + + allMembers.forEach((member: WebsiteMember) => { + const fullRoleName = member.role === 'tpm' ? 'developer' : member.role; + roleStats[fullRoleName].people += 1; + if (member.major) roleStats[fullRoleName].majors.add(member.major); + if (member.doubleMajor) roleStats[fullRoleName].majors.add(member.doubleMajor); + }); + + return ( +
+
+
+
+

+ {chartSection ? roleStats[chartSection].people : allMembers.length} +

+

Members

+
+
+

+ {chartSection + ? roleStats[chartSection].majors.size + : allMembers.reduce((acc, val) => { + if (val.major) acc.add(val.major); + if (val.doubleMajor) acc.add(val.doubleMajor); + return acc; + }, new Set()).size} +

+

Different majors

+
+
+

7

+

Represented colleges

+
+
+
+
+ +
+
+ {Object.keys(roleStats).map((role) => ( +
setChartSection(role)} + onMouseLeave={() => setChartSection(undefined)} + > +
+

+ {roleStats[role].name} +

+
+ ))} +
+
+ ); +}; + +const TeamAbout = () => ( +
+
+
+
+
+

We are Cornell DTI

+

+ Founded in 2017, DTI is a project team of{' '} + + 80+ designers, developers, product managers, and business members + {' '} + passionate about making change on campus and beyond. +

+
+
+

@2022

+ 2022 DTI Team +
+
+
+

@2017

+ 2022 DTI Team +
+
+
+

Who we are

+

+ More than just being inclusive, our team strives to{' '} + bring many backgrounds and perspectives together to + solve community problems. These statistics come from recruiting across campus and seeking + applicants with the best skills and potential for growth on the team. Updated Fall 2023. +

+
+ +
+
+); +export default TeamAbout;