This commit is contained in:
Clas Wen 2025-05-24 14:07:41 +08:00
parent c00cdb478c
commit 6a99120e14
2 changed files with 34 additions and 5 deletions

View file

@ -95,7 +95,7 @@ export const EventActionCommit = (props: EventActionProps) => {
})
useEffect(() => {
const description = props.event?.logs.findLast(v => v.action == "commit")?.description
const description = props.event?.logs.findLast(v => v.action == "commit" || v.action == "alterCommit")?.description
setFormData({
size: props.event.size || "",
description: description || "",
@ -127,6 +127,7 @@ export const EventActionCommit = (props: EventActionProps) => {
</EventActionCommitForm>
<Button
variant="flat"
color="primary"
isLoading={props.isLoading === "commit"}
onPress={() => onSubmit()}
>
@ -187,6 +188,8 @@ type JsxHandler = (props: EventActionProps) => JSX.Element
export type EventAction = {
action: string
label?: string
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger"
variant?: "flat" | "solid" | "bordered" | "light" | "faded" | "shadow" | "ghost"
handler?: CommonHandler
jsxHandler: JsxHandler
}
@ -210,9 +213,10 @@ export const getAvailableEventActions = (event: PublicEvent, identityContext: Id
return (
<div className="flex flex-col">
<Button
variant="flat"
isLoading={props.isLoading === action.action}
isDisabled={props.isLoading}
color={action.color || "default"}
variant={action.variant || "flat"}
onPress={() => onAction(action)}
>
{action.label ?? action.action}
@ -228,6 +232,8 @@ export const getAvailableEventActions = (event: PublicEvent, identityContext: Id
jsxHandler: makeCommonJsxHandler({
action: "accept",
label: "接受",
variant: "solid",
color: "primary",
handler: async () => {
return await fetch(`${saturdayApiBaseUrl}/member/events/${event.eventId}/accept`, {
method: "POST",
@ -272,7 +278,8 @@ export const getAvailableEventActions = (event: PublicEvent, identityContext: Id
action: "close",
jsxHandler: makeCommonJsxHandler({
action: "close",
label: "关闭",
color: "success",
label: "完成",
handler: async () => {
return await fetch(`${saturdayApiBaseUrl}/events/${event.eventId}/close`, {
method: "POST",
@ -287,6 +294,7 @@ export const getAvailableEventActions = (event: PublicEvent, identityContext: Id
action: "reject",
jsxHandler: makeCommonJsxHandler({
action: "rejectCommit",
color: "danger",
label: "退回",
handler: async () => {
return await fetch(`${saturdayApiBaseUrl}/events/${event.eventId}/commit`, {

View file

@ -1,4 +1,4 @@
import { forwardRef, useEffect, useImperativeHandle, useState } from "react"
import { forwardRef, useEffect, useImperativeHandle, useMemo, useState } from "react"
import type { components } from "../../types/saturday"
import { saturdayClient } from "../../utils/client"
import { Textarea, Input, Chip, Skeleton } from "@heroui/react"
@ -35,7 +35,7 @@ function EventLogItem(props: {
</span>
</div>
</div>
<div className="flex gap-2 items-center mt-1 text-gray-600">
<div className="flex flex-col gap-2 items-center mt-1 text-gray-600">
{dayjs(props.eventLog.gmtCreate).format("YYYY-MM-DD HH:mm")}
</div>
</div>
@ -126,6 +126,10 @@ const EventDetail = forwardRef<EventDetailRef, {
}
}
const repairDescription = useMemo(() => {
return event?.logs.findLast(v => v.action == "commit" || v.action == "alterCommit")?.description
}, [event])
// 初次加载
useEffect(() => {
refresh()
@ -148,6 +152,11 @@ const EventDetail = forwardRef<EventDetailRef, {
#{event.eventId}
</span>
<EventStatusChip status={event.status}></EventStatusChip>
{
event.size
? <Chip>{"size:" + event.size}</Chip>
: <></>
}
</div>
</div>
<div className="my-6 flex flex-col gap-4">
@ -164,6 +173,18 @@ const EventDetail = forwardRef<EventDetailRef, {
readOnly
>
</Input>
{
repairDescription
? (
<Textarea
label="维修描述"
readOnly
name="description"
value={repairDescription || ""}
/>
)
: <></>
}
<div className="bg-gray-100 rounded-xl text-sm px-3 py-2 mt-2 ">
<div className="text-xs font-semibold text-gray-600 mb-1">