Fakultas Ilmu Komputer UI

index.ts 2.03 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { DietProfileResponse } from 'services/dietelaQuiz/models';
import { bodyMassStatus } from 'services/dietelaQuiz/quizResult';
import { ResultPageContent } from '../types';

const statusBeratBadan = (response: DietProfileResponse): ResultPageContent => {
  const result = response.quiz_result;
  const bmi = result.body_mass_index.toString();
  const nutritionStatus = result.nutrition_status;
  const infoStatus = bodyMassStatus[nutritionStatus].status;
  const weight = result.weight.toFixed(0).toString();
  const height = result.height.toString();
  const minimum = result.ideal_weight_range.min.toFixed(1).toString();
  const maximum = result.ideal_weight_range.max.toFixed(1).toString();

  return {
    title: 'Status Berat Badan',
    mainInfo: {
      infos: [
        {
          label: 'Indeks massa tubuh',
          content: bmi,
        },
        {
          label: 'Status',
          content: nutritionStatus,
        },
      ],
      status: infoStatus,
    },
    sections: [
      {
        header: 'Dihitung berdasarkan data:',
        content: {
          statistics: [
            [
              {
                label: 'berat badan',
                emote: '⚖️',
                content: `${weight} kg`,
              },
              {
                label: 'tinggi badan',
                emote: '📐',
                content: `${height} cm`,
              },
            ],
          ],
        },
      },
      {
51
        header: `Untuk orang dengan tinggi ${height} cm, berikut rentang berat badan yang ideal:`,
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
        content: {
          statistics: [
            [
              {
                label: 'minimal',
                emote: '◀️',
                content: `${minimum} kg`,
              },
              {
                label: 'maksimal',
                emote: '▶️',
                content: `${maximum} kg`,
              },
            ],
          ],
          textCard: ['Usahakan berat badan kamu masuk ke rentang ideal, ya!'],
        },
      },
    ],
  };
};

export default statusBeratBadan;