refactor(data): add mock API adapters, id utility, and toast feedback
This commit is contained in:
@@ -12,16 +12,12 @@ import { Label } from "@/components/ui/label"
|
||||
import { Separator } from "@/components/ui/separator"
|
||||
import { Textarea } from "@/components/ui/textarea"
|
||||
import { mockPlayers, mockServices, walletBalance } from "@/lib/mock"
|
||||
import { notifySuccess } from "@/lib/toast"
|
||||
import { useRequireAuth } from "@/lib/use-require-auth"
|
||||
import { useAuthStore } from "@/store/auth"
|
||||
import { useChatStore } from "@/store/chat"
|
||||
import { useOrderStore } from "@/store/orders"
|
||||
|
||||
function showFeedback(message: string) {
|
||||
if (typeof window === "undefined") return
|
||||
window.alert(message)
|
||||
}
|
||||
|
||||
export default function NewOrderPage() {
|
||||
const router = useRouter()
|
||||
const searchParams = useSearchParams()
|
||||
@@ -189,12 +185,12 @@ export default function NewOrderPage() {
|
||||
onClick={() =>
|
||||
requireAuth(async () => {
|
||||
await new Promise((resolve) => setTimeout(resolve, 500))
|
||||
const currentUser = useAuthStore.getState().user
|
||||
if (!currentUser) return
|
||||
const authUser = useAuthStore.getState().user
|
||||
if (!authUser) return
|
||||
|
||||
const order = createOrder({
|
||||
consumerId: currentUser.id,
|
||||
consumerName: currentUser.nickname,
|
||||
consumerId: authUser.id,
|
||||
consumerName: authUser.nickname,
|
||||
playerId: player.id,
|
||||
playerName: player.user.nickname,
|
||||
shopId: player.shopId,
|
||||
@@ -207,7 +203,7 @@ export default function NewOrderPage() {
|
||||
|
||||
ensureOrderSession(order)
|
||||
setSubmitted(true)
|
||||
showFeedback("下单成功")
|
||||
notifySuccess("下单成功")
|
||||
setTimeout(() => {
|
||||
router.push(`/order/${order.id}`)
|
||||
}, 800)
|
||||
|
||||
Reference in New Issue
Block a user