Skip to content

Commit

Permalink
feat: prices fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
th-release committed Aug 19, 2023
1 parent 8bbb2bb commit 10215f8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/components/CreateModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const CreateModal: FC<Props> = (props) => {
const [, updateState] = useState<any>()
const forceUpdate = useCallback(() => { updateState({}) }, [])
const [status, setStatus] = useState("normal");
const [price, setPrice] = useState(0)
const [price, setPrice] = useState("0")
const [event, dispatch] = useReducer(createModalReducer, {
category: '',
name: '',
Expand All @@ -32,7 +32,7 @@ const CreateModal: FC<Props> = (props) => {
forceUpdate()
await axios.get(`/api/prices/${type ?? 't3a.micro'}`)
.then((res) => {
setPrice(Math.floor(((res.data.body.pricePerHour * 24) * 30) + ((Number.isNaN(storage) ? 0 : storage) * 0.1)))
setPrice(((res.data.body.pricePerHour * 24) * 30) + ((Number.isNaN(storage) ? 0 : storage) * 0.1).toFixed(2))
})
.catch((err) => { console.error(err) })
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/UpdateModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ const UpdateModal: FC<Props> = (props) => {
const [, updateState] = useState<any>()
const forceUpdate = useCallback(() => { updateState({}) }, [])
const [status, setStatus] = useState("normal");
const [price, setPrice] = useState(0)
const [price, setPrice] = useState("0")
const [isIpChange, setChange] = useState(false)

async function getPrice(type: string, storage: number): Promise<void> {
forceUpdate()
await axios.get(`/api/prices/${type ?? 't3a.micro'}`)
.then((res) => {
setPrice(Math.floor(((res.data.body.pricePerHour * 24) * 30) + ((Number.isNaN(storage) ? 0 : storage) * 0.1)))
setPrice(((res.data.body.pricePerHour * 24) * 30) + ((Number.isNaN(storage) ? 0 : storage) * 0.1).toFixed(2))
})
.catch((err) => { console.error(err) })
}
Expand Down

0 comments on commit 10215f8

Please sign in to comment.