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' ...@@ -11,15 +11,15 @@ import SeparatePeople from '../SeparatePeople/SeparatePeople'
const Bill = () => { const Bill = () => {
const [paymentType, setPaymentType] = useState<EPaymentType | null>(null) const [paymentType, setPaymentType] = useState<EPaymentType | null>(null)
const [state, setState] = useState<{ const [state, setState] = useState<{
amount: number amount: string
sum: number sum: string
tips: number tips: string
delivery: number delivery: string
}>({ }>({
amount: 0, amount: '',
sum: 0, sum: '',
tips: 0, tips: '',
delivery: 0 delivery: ''
}) })
const [isCalculated, setIsCalculated] = useState<boolean>(false) const [isCalculated, setIsCalculated] = useState<boolean>(false)
...@@ -65,7 +65,7 @@ const Bill = () => { ...@@ -65,7 +65,7 @@ const Bill = () => {
<div> <div>
<p>SUM: {sum} tenge</p> <p>SUM: {sum} tenge</p>
<p>PEOPLE: {state.amount} person</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> </div>
) )
} else if (paymentType === EPaymentType.SEPARATELY) { } else if (paymentType === EPaymentType.SEPARATELY) {
...@@ -73,7 +73,7 @@ const Bill = () => { ...@@ -73,7 +73,7 @@ const Bill = () => {
const peopleAmount = Object.keys(people).length const peopleAmount = Object.keys(people).length
const peopleArray: React.ReactNode = Object.keys(people).map(id => { const peopleArray: React.ReactNode = Object.keys(people).map(id => {
const p = people[id as keyof typeof people] 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 sum += tempSum
return <p key={id}>{p.name} : {tempSum}</p> 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