refactor: ♻️ merge multiple trait getter into single function

This commit is contained in:
Sebin Nyshkim 2025-04-10 02:31:59 +02:00
parent a4416c1811
commit 1ca13d330f
2 changed files with 70 additions and 24 deletions

View file

@ -114,17 +114,23 @@ const getDateOfBirth = () => `${dateFormat.format(dateOfBirth)} (${getAge(dateOf
const getHeight = () => `${height} cm (${toImperial(height)})`;
const getWeight = () => `${weight} kg (${toLbs(weight)} lbs)`;
const getTraits = () => [
{ icon: 'cake-candles', type: 'Date of Birth', text: getDateOfBirth() },
{ icon: 'mars', type: 'Sex/Gender', text: `${gender} (${pronouns})` },
{ icon: 'ruler', type: 'Height', text: getHeight() },
{ icon: 'weight-hanging', type: 'Weight', text: getWeight() }
];
const getTraits = (type) => {
switch (type) {
case 'naughty':
return [
{ icon: 'heart', type: 'Orientation', text: orientation },
{ icon: 'arrows-up-down', type: 'Role', text: role }
];
const getSexTraits = () => [
{ icon: 'heart', type: 'Orientation', text: orientation },
{ icon: 'arrows-up-down', type: 'Role', text: role }
];
default:
return [
{ icon: 'cake-candles', type: 'Date of Birth', text: getDateOfBirth() },
{ icon: 'mars', type: 'Sex/Gender', text: `${gender} (${pronouns})` },
{ icon: 'ruler', type: 'Height', text: getHeight() },
{ icon: 'weight-hanging', type: 'Weight', text: getWeight() }
];
}
};
const getColors = () => [
{ name: 'Front', value: color.front },
@ -147,6 +153,5 @@ export default {
jobs,
getFullName,
getTraits,
getSexTraits,
getColors
};