mirror of
https://github.com/MetaFam/TheGame.git
synced 2026-02-09 05:25:15 -05:00
* Added tz column * Updated hasura permissions on new table * Added new dependencies for working with timezones * Added SetupTimeZone component * Bumped spacetime-informal to use their types * Extracted timezone computation into helper, added useMemo hook * Re-added spacetime types
41 lines
843 B
TypeScript
41 lines
843 B
TypeScript
import { PlayerSkillFragment } from '../graphql/autogen/types';
|
|
|
|
export type SkillMap = {
|
|
[category: string]: CategoryOption;
|
|
};
|
|
|
|
export type SkillOption = PlayerSkillFragment & {
|
|
value: string;
|
|
label: string;
|
|
};
|
|
|
|
export type CategoryOption = {
|
|
label: string;
|
|
options: Array<SkillOption>;
|
|
};
|
|
|
|
export const parseSkills = (
|
|
skills: Array<PlayerSkillFragment>,
|
|
): Array<CategoryOption> => {
|
|
const skillsMap: SkillMap = {};
|
|
skills.map((skill) => {
|
|
if (!(skill.category in skillsMap)) {
|
|
skillsMap[skill.category] = {
|
|
label: skill.category,
|
|
options: [],
|
|
};
|
|
}
|
|
return skillsMap[skill.category].options?.push({
|
|
value: skill.id,
|
|
label: skill.name,
|
|
...skill,
|
|
});
|
|
});
|
|
return Object.values(skillsMap);
|
|
};
|
|
|
|
export type TimeZoneOption = {
|
|
value: string;
|
|
label: string;
|
|
};
|