import React from 'react'
import { View, Text, ActivityIndicator } from 'react-native'
import { AppContainer, tw } from 'common-ui'
import OfferForm from '@/components/OfferForm'
import { useRouter, useLocalSearchParams } from 'expo-router'
import { trpc } from '@/src/trpc-client'
export default function EditOffer() {
const router = useRouter()
const { id } = useLocalSearchParams()
const offerId = parseInt(id as string)
const { data: offerData, isLoading } = trpc.admin.offers.getById.useQuery(
{ id: offerId },
{ enabled: !!offerId }
)
const handleOfferUpdated = () => {
router.back()
}
if (isLoading) {
return (
Loading offer...
)
}
if (!offerData?.offer) {
return (
Offer not found
)
}
const offer = offerData.offer
return (
({
productId: item.productId,
quantity: item.quantity,
product: item.product,
}))}
onOfferAdded={handleOfferUpdated}
/>
)
}