diff --git a/src/components/header/RepairHeader.astro b/src/components/header/RepairHeader.astro
index 21a585e..f6ae41d 100644
--- a/src/components/header/RepairHeader.astro
+++ b/src/components/header/RepairHeader.astro
@@ -11,7 +11,7 @@ import NavigationUser from "./NavigationUser.vue"
diff --git a/src/pages/repair/EventDetail.tsx b/src/pages/repair/EventDetail.tsx
index 5a2e7c5..829f82b 100644
--- a/src/pages/repair/EventDetail.tsx
+++ b/src/pages/repair/EventDetail.tsx
@@ -94,7 +94,9 @@ const filterEventLog = (event: PublicEvent) => {
return filteredLogs
}
-export default function EventDetail() {
+export default function EventDetail(props: {
+ eventId?: number
+}) {
const [event, setEvent] = useState()
const fetchAndSetEvent = async (eventId: number) => {
const { data } = await saturdayClient.GET("/events/{EventId}", {
@@ -107,9 +109,8 @@ export default function EventDetail() {
setEvent(data)
}
useEffect(() => {
- // get the eventId from the url
const url = new URL(window.location.href)
- const eventId = url.searchParams.get("eventId")
+ const eventId = props.eventId ?? url.searchParams.get("eventId")
if (!eventId) {
return
}
diff --git a/src/pages/repair/TicketForm.tsx b/src/pages/repair/TicketForm.tsx
index fea00d8..038d05e 100644
--- a/src/pages/repair/TicketForm.tsx
+++ b/src/pages/repair/TicketForm.tsx
@@ -1,7 +1,8 @@
+import { SITE_URL } from "../../consts"
import { useEffect, useState } from "react"
import { makeLogtoClient } from "../../utils/auth"
import type { UserInfoResponse } from "@logto/browser"
-import { Form, Input, Button, Textarea } from "@heroui/react"
+import { Alert, Form, Input, Button, Textarea } from "@heroui/react"
import { saturdayClient } from "../../utils/client"
import type { components } from "../../types/saturday"
import QRCode from "qrcode"
@@ -14,8 +15,29 @@ type TicketFormData = {
description?: string
}
+function LoginHintAlert(props: {
+ onLogin: () => void
+}) {
+ return (
+
+
+
+ 登入
+
+ )}
+ >
+ 登入账号来跟踪你的维修进度
+
+
+
+ )
+}
+
function TicketForm(props: {
- userInfo: UserInfoResponse
+ userInfo?: UserInfoResponse
onSubmit: (form: TicketFormData) => Promise
}) {
const [loading, setLoading] = useState()
@@ -27,8 +49,20 @@ function TicketForm(props: {
setLoading(false)
}
+ const onLogin = async () => {
+ makeLogtoClient().signIn({
+ redirectUri: import.meta.env.PUBLIC_LOGTO_CALLBACK_URL,
+ postRedirectUri: window.location.pathname,
+ })
+ }
+
return (
+ {
+ props.userInfo?.sub
+ ? <>>
+ :
+ }
预约维修
@@ -115,56 +149,47 @@ function TicketFormCreated(props: {
const [svg, setSvg] = useState
()
useEffect(() => {
- QRCode.toString(props.event.eventId.toString()).then((res) => {
- // const root = createRoot(
- // document.getElementById("svg-root"),
- // )
- // root.render(res)
+ const url = new URL(`/repair/ticket-detail`, SITE_URL)
+ url.searchParams.append("eventId", props.event.eventId.toString())
+ QRCode.toString(url.toString()).then((res) => {
setSvg(res)
})
})
- // const svg = ref()
- // watch(id, async () => {
- // if (!id.value) {
- // return
- // }
- // svg.value = await QRCode.toString(useGraduationIdURL().constructURL(id.value))
- // })
-
return (
-
-
-
-
-
-
-
- 扫描二维码来查看预约详情
+
+
+
+
+
- 你也可以保存此二维码
+
+
+
+ 保存二维码
+
+
+ 跟踪维修进度
+
+
-
+
-
- //
{props.event.eventId}
+
+
+
)
}
export default function App() {
const [userInfo, setUserInfo] = useState
()
- const [event, setEvent] = useState({
- eventId: 123,
- })
+ const [event, setEvent] = useState()
useEffect(() => {
const check = async () => {
@@ -203,12 +228,11 @@ export default function App() {
return (
<>
-
- (
- event?.eventId
- ?
- :
- )
+ {
+ event?.eventId
+ ?
+ :
+ }
>
)
}