Commit 06646611 authored by Pavel Mishakov's avatar Pavel Mishakov

deleted zero from state

parent 82c19fa1
......@@ -11,15 +11,15 @@ import SeparatePeople from '../SeparatePeople/SeparatePeople'
const Bill = () => {
const [paymentType, setPaymentType] = useState<EPaymentType | null>(null)
const [state, setState] = useState<{
amount: number
sum: number
tips: number
delivery: number
amount: string
sum: string
tips: string
delivery: string
}>({
amount: 0,
sum: 0,
tips: 0,
delivery: 0
amount: '',
sum: '',
tips: '',
delivery: ''
})
const [isCalculated, setIsCalculated] = useState<boolean>(false)
......@@ -65,7 +65,7 @@ const Bill = () => {
<div>
<p>SUM: {sum} tenge</p>
<p>PEOPLE: {state.amount} person</p>
<p>EACH PAYS: {Math.ceil(sum / state.amount)}</p>
<p>EACH PAYS: {Math.ceil(sum / Number(state.amount))}</p>
</div>
)
} else if (paymentType === EPaymentType.SEPARATELY) {
......@@ -73,7 +73,7 @@ const Bill = () => {
const peopleAmount = Object.keys(people).length
const peopleArray: React.ReactNode = Object.keys(people).map(id => {
const p = people[id as keyof typeof people]
const tempSum = Math.ceil(Number(p.sum) + Math.ceil(state.delivery / peopleAmount)) + Math.ceil((Number(p.sum) * Number(state.tips) / 100))
const tempSum = Math.ceil(Number(p.sum) + Math.ceil(Number(state.delivery) / peopleAmount)) + Math.ceil((Number(p.sum) * Number(state.tips) / 100))
sum += tempSum
return <p key={id}>{p.name} : {tempSum}</p>
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment