From b0534db2d8f12c430ecfabf6700288689f15a4bf Mon Sep 17 00:00:00 2001 From: sdjdd Date: Tue, 12 Dec 2023 11:26:03 +0800 Subject: [PATCH] fix(in-app): type errors --- in-app/v1/src/App/Tickets/Ticket/index.tsx | 6 +++--- in-app/v1/src/types/index.ts | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/in-app/v1/src/App/Tickets/Ticket/index.tsx b/in-app/v1/src/App/Tickets/Ticket/index.tsx index c7675e96a..4a93dc3a4 100644 --- a/in-app/v1/src/App/Tickets/Ticket/index.tsx +++ b/in-app/v1/src/App/Tickets/Ticket/index.tsx @@ -17,7 +17,7 @@ import { produce } from 'immer'; import { Helmet } from 'react-helmet-async'; import { auth, db, http } from '@/leancloud'; -import { Reply, Ticket } from '@/types'; +import { Evaluation, Reply, Ticket } from '@/types'; import { PageContent, PageHeader } from '@/components/Page'; import { QueryWrapper } from '@/components/QueryWrapper'; import styles from './index.module.css'; @@ -214,7 +214,7 @@ function useWatchStatus(ticketId: string, callback: (status: number) => void) { }, [ticketId]); } -async function commitEvaluation(ticketId: string, data: Ticket['evaluation']) { +async function commitEvaluation(ticketId: string, data: Evaluation) { await http.patch(`/api/2/tickets/${ticketId}`, { evaluation: data }); } @@ -289,7 +289,7 @@ export default function TicketDetail() { const [editEval, setEditEval] = useState(false); const { mutate: evaluate, isLoading: isEvaluating } = useMutation({ - mutationFn: (data: Ticket['evaluation']) => commitEvaluation(id, data), + mutationFn: (data: Evaluation) => commitEvaluation(id, data), onSuccess: (_, evaluation) => { setEditEval(false); queryClient.setQueryData(['ticket', id], (data) => { diff --git a/in-app/v1/src/types/index.ts b/in-app/v1/src/types/index.ts index 06e963c28..62d1957e9 100644 --- a/in-app/v1/src/types/index.ts +++ b/in-app/v1/src/types/index.ts @@ -17,7 +17,8 @@ export interface File { export interface Evaluation { star: 0 | 1; - content: string; + content?: string; + selections?: string[]; } export interface EvaluationTag { @@ -37,7 +38,7 @@ export interface TicketListItem { title: string; status: number; files?: File[]; - evaluation: Evaluation | null; + evaluation?: Evaluation; unreadCount: number; createdAt: string; updatedAt: string;