Skip to content

Commit

Permalink
Fix order detail card api call
Browse files Browse the repository at this point in the history
  • Loading branch information
didrikmunther committed Aug 6, 2024
1 parent cc137a4 commit 9dc3752
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions apps/dashboard/src/forms/receipt/order_details.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { HOST } from "@/shared/vars"
import { cx } from "@/utils/cx"
import { formatCurrency } from "@/utils/format_currency"
import { FormWrapper } from "../FormWrapper"
import { useParams } from "@tanstack/react-router"

type Order = {
comment: string
Expand All @@ -24,18 +25,21 @@ const getOrderPrice = (order: Order) => {

export const OrderDetails = () => {
const [orders, setOrders] = useState<Order[] | undefined>()
const { companyId } = useParams({
from: "/$companyId/*"
})

// Todo: Move to redux
useEffect(() => {
const update = async () => {
fetch(`${HOST}/api/dashboard/`, {}).then(async raw => {
fetch(`${HOST}/api/dashboard/${companyId}`, {}).then(async raw => {
const data = await raw.json()
setOrders(data.orders)
})
}

update()
}, [setOrders])
}, [setOrders, companyId])

if (!orders) {
return <>Loading</>
Expand Down

0 comments on commit 9dc3752

Please sign in to comment.