mirror of
https://github.com/m1ngsama/FUJI.git
synced 2025-12-24 10:51:27 +00:00
change loading
This commit is contained in:
parent
5a175875ae
commit
e33b81775e
2 changed files with 12 additions and 55 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
import { useState, useEffect } from "react"
|
import { useState, useEffect } from "react"
|
||||||
import { Button, Card, CardBody, CardFooter } from "@heroui/react"
|
import { Button } from "@heroui/react"
|
||||||
import { makeLogtoClient } from "../../utils/auth"
|
import { makeLogtoClient } from "../../utils/auth"
|
||||||
import { saturdayClient } from "../../utils/client"
|
import { saturdayClient } from "../../utils/client"
|
||||||
import RepairHistoryCard from "./RepairHistoryCard"
|
import RepairHistoryCard from "./RepairHistoryCard"
|
||||||
|
|
@ -75,31 +75,6 @@ export default function RepairLandingSection() {
|
||||||
window.location.href = createRepairPath
|
window.location.href = createRepairPath
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleEdit = (event: PublicEvent) => {
|
|
||||||
setSelectedEvent(event)
|
|
||||||
setIsEditOpen(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleCancel = async (event: PublicEvent) => {
|
|
||||||
try {
|
|
||||||
const logtoToken = await makeLogtoClient().getAccessToken()
|
|
||||||
await saturdayClient.DELETE("/client/events/{EventId}", {
|
|
||||||
params: {
|
|
||||||
path: {
|
|
||||||
EventId: event.eventId,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
headers: {
|
|
||||||
Authorization: `Bearer ${logtoToken}`,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
await fetchRecentEvents()
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
console.error("Error cancelling event:", error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleViewDetail = (event: PublicEvent) => {
|
const handleViewDetail = (event: PublicEvent) => {
|
||||||
window.location.href = `/repair/ticket-detail?eventId=${event.eventId}`
|
window.location.href = `/repair/ticket-detail?eventId=${event.eventId}`
|
||||||
}
|
}
|
||||||
|
|
@ -142,7 +117,7 @@ export default function RepairLandingSection() {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Recent events section - only for authenticated users */}
|
{/* Recent events section - only for authenticated users */}
|
||||||
{userInfo && (
|
{userInfo && recentEvents.length > 0 && (
|
||||||
<div className="mt-16 section-content">
|
<div className="mt-16 section-content">
|
||||||
<div className="flex justify-between items-center mb-6">
|
<div className="flex justify-between items-center mb-6">
|
||||||
<h2 className="text-2xl font-bold">最近的维修</h2>
|
<h2 className="text-2xl font-bold">最近的维修</h2>
|
||||||
|
|
@ -156,32 +131,15 @@ export default function RepairLandingSection() {
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{recentEvents.length > 0
|
|
||||||
? (
|
|
||||||
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
|
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
|
||||||
{recentEvents.map(event => (
|
{recentEvents.map(event => (
|
||||||
<RepairHistoryCard
|
<RepairHistoryCard
|
||||||
key={event.eventId}
|
key={event.eventId}
|
||||||
event={event}
|
event={event}
|
||||||
onEdit={handleEdit}
|
|
||||||
onCancel={handleCancel}
|
|
||||||
onViewDetail={handleViewDetail}
|
onViewDetail={handleViewDetail}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
)
|
|
||||||
: (
|
|
||||||
<Card className="w-full">
|
|
||||||
<CardBody className="text-center py-8">
|
|
||||||
<p className="text-gray-500">暂无进行中的维修预约</p>
|
|
||||||
</CardBody>
|
|
||||||
<CardFooter className="justify-center">
|
|
||||||
<Button color="primary" onPress={handleCreateTicketClick}>
|
|
||||||
创建新预约
|
|
||||||
</Button>
|
|
||||||
</CardFooter>
|
|
||||||
</Card>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,12 @@ import RepairHeader from "../../components/header/RepairHeader.astro"
|
||||||
import RepairLandingSection from "./RepairLandingSection.tsx"
|
import RepairLandingSection from "./RepairLandingSection.tsx"
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<BaseLayout>
|
<BaseLayout>
|
||||||
<section class="box-border">
|
<section class="box-border">
|
||||||
<RepairHeader></RepairHeader>
|
<RepairHeader></RepairHeader>
|
||||||
|
|
||||||
<!-- Dynamic content based on authentication status -->
|
<!-- Dynamic content based on authentication status -->
|
||||||
<RepairLandingSection client:only="react"></RepairLandingSection>
|
<RepairLandingSection client:load></RepairLandingSection>
|
||||||
|
|
||||||
<div class="w-full bg-white pb-24 flex flex-col gap-12">
|
<div class="w-full bg-white pb-24 flex flex-col gap-12">
|
||||||
<div class="component">
|
<div class="component">
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue