mirror of
https://github.com/tjsga/tj-sga-website-react.git
synced 2025-04-03 20:00:17 -04:00
Fix class council page bug
This commit is contained in:
parent
ca66eb23c8
commit
e82a33b0b9
|
@ -17,7 +17,7 @@ const roleOrder = [
|
|||
|
||||
export default function ClassCouncil() {
|
||||
let members = useQuery<SGA.MemberDocument[]>(
|
||||
`*[_type == 'member' && committee == 'class'] | order (year desc)`
|
||||
`*[_type == 'member' && committee == 'class'] | order year`
|
||||
);
|
||||
|
||||
if (!members) {
|
||||
|
@ -28,18 +28,26 @@ export default function ClassCouncil() {
|
|||
let currentYearMembers: SGA.MemberDocument[] = [];
|
||||
let currentYear = '';
|
||||
|
||||
const saveCurrentYear = () => {
|
||||
// Clear the members of the current year
|
||||
years.push([currentYear, sortCommittee(currentYearMembers, roleOrder)]);
|
||||
currentYearMembers = [];
|
||||
};
|
||||
|
||||
for (let member of members) {
|
||||
if (member.year !== currentYear) {
|
||||
if (currentYear !== '') {
|
||||
// Clear the members of the current year
|
||||
years.push([currentYear, sortCommittee(currentYearMembers, roleOrder)]);
|
||||
currentYearMembers = [];
|
||||
saveCurrentYear();
|
||||
}
|
||||
currentYear = member.year;
|
||||
}
|
||||
currentYearMembers.push(member);
|
||||
}
|
||||
|
||||
if (currentYearMembers.length > 0) {
|
||||
saveCurrentYear();
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Hero heading='Class Council' />
|
||||
|
|
Loading…
Reference in New Issue
Block a user