|
| 1 | +import Team from './Team'; |
| 2 | +import { fetchContent } from '../api/apiRoot'; |
| 3 | +import { useState, useEffect } from 'react'; |
| 4 | +import { Tabs, TabsHeader, TabsBody, Tab, TabPanel } from '@material-tailwind/react'; |
| 5 | +import Heading from './Heading'; |
| 6 | +import { UnderlineTypes } from '../utils/underlineType'; |
| 7 | +import { PageIdentifiers } from '../utils/flags'; |
| 8 | + |
| 9 | +const positionToGroupMap = { |
| 10 | + 'Jr VP Marketing': 'Marketing', |
| 11 | + 'VP Marketing': 'Marketing', |
| 12 | + 'Jr VP Events': 'Events', |
| 13 | + 'VP Events': 'Events', |
| 14 | + 'Co President': 'Presidents', |
| 15 | + 'Jr VP Design': 'Design', |
| 16 | + 'VP Design': 'Design', |
| 17 | + 'Jr VP Tech': 'Tech', |
| 18 | + 'VP Tech': 'Tech', |
| 19 | + 'VP External': 'External', |
| 20 | + 'Jr VP External': 'External', |
| 21 | +}; |
| 22 | + |
| 23 | +const InternalTeam = () => { |
| 24 | + const [executives, setExecutives] = useState([]); |
| 25 | + const [groups, setGroups] = useState([]); |
| 26 | + const [activeTab, setActiveTab] = useState(''); |
| 27 | + |
| 28 | + useEffect(() => { |
| 29 | + fetchContent('adminTeamMember').then((data) => { |
| 30 | + const executivesWithGroups = data.map((exec) => ({ |
| 31 | + ...exec, |
| 32 | + group: positionToGroupMap[exec.position] || 'Other', |
| 33 | + })); |
| 34 | + |
| 35 | + setExecutives(executivesWithGroups); |
| 36 | + |
| 37 | + const uniqueGroups = executivesWithGroups |
| 38 | + .map((exec) => exec.group) |
| 39 | + .filter((group, index, self) => self.indexOf(group) === index); |
| 40 | + |
| 41 | + setGroups(uniqueGroups); |
| 42 | + |
| 43 | + if (uniqueGroups.length > 0) { |
| 44 | + setActiveTab(uniqueGroups[0]); |
| 45 | + } |
| 46 | + }); |
| 47 | + }, []); |
| 48 | + |
| 49 | + return ( |
| 50 | + <> |
| 51 | + <div className="mb-12 flex justify-center gap-3"> |
| 52 | + <Heading distanceFromTop={11} underlineType={UnderlineTypes.GREEN_SHORT_UNDERLINE}> |
| 53 | + Internal{' '} |
| 54 | + </Heading> |
| 55 | + <span className="text-5xl font-semibold">Team</span> |
| 56 | + </div> |
| 57 | + {groups.length > 0 && ( |
| 58 | + <Tabs value={activeTab}> |
| 59 | + <TabsHeader className="overflow-x-auto grid place-items-center"> |
| 60 | + <div className="flex flex-row gap-2"> |
| 61 | + {groups.map((group) => ( |
| 62 | + <Tab key={group} value={group} onClick={() => setActiveTab(group)}> |
| 63 | + <div |
| 64 | + className={`rounded-full px-4 py-2 font-medium hover:bg-[#00D3A9] hover:text-white transition-all duration-200 |
| 65 | + ${activeTab === group ? 'bg-[#00D3A9] text-white' : 'text-black'} |
| 66 | + `} |
| 67 | + > |
| 68 | + {group} |
| 69 | + </div> |
| 70 | + </Tab> |
| 71 | + ))} |
| 72 | + </div> |
| 73 | + </TabsHeader> |
| 74 | + <TabsBody> |
| 75 | + {groups.map((group) => ( |
| 76 | + <TabPanel key={group} value={group}> |
| 77 | + <Team |
| 78 | + teamIdentifier={PageIdentifiers.INTERNAL_LEVEL_CONTAINER} |
| 79 | + teamMembers={executives.filter((exec) => exec.group === group)} |
| 80 | + /> |
| 81 | + </TabPanel> |
| 82 | + ))} |
| 83 | + </TabsBody> |
| 84 | + </Tabs> |
| 85 | + )} |
| 86 | + </> |
| 87 | + ); |
| 88 | +}; |
| 89 | + |
| 90 | +export default InternalTeam; |
0 commit comments