-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSeveranceWhatIf.tsx
117 lines (110 loc) · 3.35 KB
/
SeveranceWhatIf.tsx
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import React from 'react';
import { styled } from '@mui/material/styles';
import Card from '@mui/material/Card';
import CardContent from '@mui/material/CardContent';
import CardActions from '@mui/material/CardActions';
import Button from '@mui/material/Button';
import Typography from '@mui/material/Typography';
import {
calculateSeveranceData,
WORK_WEEKS_IN_A_YEAR,
getWorkingDurationMilis,
WORK_MILIS_IN_A_YEAR,
SeveranceFormData,
SeveranceData,
} from './severanceUtils';
import { SeveranceDescriptionProps } from './SeveranceDescription';
const PREFIX = 'SeveranceWhatIf';
const classes = {
container: `${PREFIX}-container`,
title: `${PREFIX}-title`,
paper: `${PREFIX}-paper`,
workDurationDesc: `${PREFIX}-workDurationDesc`,
};
const StyledCard = styled(Card)(() => ({
[`&.${classes.container}`]: {
marginTop: 14,
width: '100%',
},
[`& .${classes.title}`]: {
fontSize: 14,
},
[`& .${classes.paper}`]: {
padding: 5,
margin: 7,
},
[`& .${classes.workDurationDesc}`]: {
marginTop: 12,
},
}));
function SeveranceWhatIf(props: SeveranceDescriptionProps) {
const stopWorkDate = new Date('2021-02-01');
const severanceFormData: SeveranceFormData = {
...props.severanceFormData,
stopWorkDate,
};
const severanceData: SeveranceData =
calculateSeveranceData(severanceFormData);
const { salary } = severanceFormData;
const baseMultiplier =
severanceData.baseMultiplier *
(severanceFormData.specialReason
? severanceData.effectiveLaw.specialMultiplier
: 1);
const severanceMultiplier = baseMultiplier + severanceData.rewardMultiplier;
const severance = severanceMultiplier * salary;
const workDurationYear = (
getWorkingDurationMilis(severanceFormData) / WORK_MILIS_IN_A_YEAR
).toLocaleString('id-ID', { maximumFractionDigits: 1 });
return (
severanceMultiplier < 0 ?
<></> :
<StyledCard className={classes.container}>
<CardContent>
<Typography variant='h3'>Kalau</Typography>
<Typography
className={classes.title}
color='textSecondary'
gutterBottom
>
anda diberhentikan tanggal 1 Februari 2021 (sebelum ciptaker) pesangon
anda bisa berjumlah
</Typography>
{salary > 0 && (
<>
<Typography variant='h5' component='h2'>
{salary > 0 ? 'Rp ' + severance.toLocaleString() : ''}
</Typography>
<Typography variant='h5' color='textSecondary'>
atau
</Typography>
</>
)}
<Typography variant='h5'>
{severanceMultiplier + 'x upah bulanan'}
</Typography>
<Typography
variant='body2'
component='p'
className={classes.workDurationDesc}
>
Dengan rincian uang pesangon sebesar
</Typography>
<Typography variant='h6' color='textSecondary'>
{baseMultiplier + 'x upah bulanan'}
</Typography>
<Typography
variant='body2'
component='p'
className={classes.workDurationDesc}
>
Dan uang penghargaan masa kerja sebesar
</Typography>
<Typography variant='h6' color='textSecondary'>
{severanceData.rewardMultiplier + 'x upah bulanan'}
</Typography>
</CardContent>
</StyledCard>
);
}
export default SeveranceWhatIf;