Files
TheGame/packages/web/utils/skillHelpers.ts
Pacien Boisson dfff04ebaa [Quests] Frontend (#437)
* squash frontend changes

* Style quest explorer

* Style quest page

* Dates

* Dates

* Typecheck

* Prettier

* Fix create page layout

* Update only OPEN quests

* Repetition info

* Fix create quest errors

* Quest form Textarea

* Quest form Textarea

* Truncate texts

* Redirect if user not logged in

* Tooltips

* Factorize skills tags

* fix username in completions

* Metafam as default guild on creation

* Layouts

* Remove todo

* cooldown

* Rename to "claim quest"

* squash frontend changes

* Style quest explorer

* Style quest page

* Dates

* Dates

* Typecheck

* Prettier

* Fix create page layout

* Update only OPEN quests

* Repetition info

* Fix create quest errors

* Quest form Textarea

* Quest form Textarea

* Truncate texts

* Redirect if user not logged in

* Tooltips

* Factorize skills tags

* fix username in completions

* Metafam as default guild on creation

* Layouts

* Remove todo

* cooldown

* Rename to "claim quest"

* Move ConfirmModal in ds

* Extract pSeed balance

* Fix "created by me" switch

* Reword complete quest

* Style quest form

* prettier

* lint
2021-04-08 15:32:27 +04:00

41 lines
840 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.forEach((skill) => {
if (!(skill.category in skillsMap)) {
skillsMap[skill.category] = {
label: skill.category,
options: [],
};
}
skillsMap[skill.category].options?.push({
value: skill.id,
label: skill.name,
...skill,
});
});
return Object.values(skillsMap);
};
export type TimeZoneOption = {
value: string;
label: string;
};