Skip to content

Commit

Permalink
Minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
jotjern committed Jul 22, 2024
1 parent 0fa3fc8 commit e6dd5a2
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/pages/applications/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ import React, { useEffect, useState } from 'react';
import style from '../../applications/committee.less';
import crypto from 'crypto';

const getHourlyUpdatedSortKey = (key: string) => {
const hash = crypto.createHash('sha256');
const hour = Math.floor((+new Date()) / 3600000);
hash.update(key + hour.toString());
return hash.digest('hex');
}

const Committees: React.FC = () => {
const [committees, setCommittees] = useState<IOnlineGroup[]>([]);
const applicationFormUrl = 'https://forms.gle/BpQfh42FXfC85tNd6'; // updated for August 2023
Expand All @@ -22,17 +29,10 @@ const Committees: React.FC = () => {
) {
CommitteeList.push(groups[i]);
}
}

const getKey = (key: string) => {
const hash = crypto.createHash('sha256');
const hour = Math.floor((+new Date()) / 3600000);
hash.update(key + hour.toString());
return hash.digest('hex');
}
}

CommitteeList.sort((a, b) => {
return getKey(a.name_short) > getKey(b.name_short) ? 1 : -1;
return getHourlyUpdatedSortKey(a.name_short) > getHourlyUpdatedSortKey(b.name_short) ? 1 : -1;
});
setCommittees(CommitteeList);
});
Expand Down

0 comments on commit e6dd5a2

Please sign in to comment.