1- import { ExternalLink , History , Clock , CheckCircle2 , AlertCircle , XCircle } from "lucide-react" ;
2- import { useState } from "react" ;
3- interface Submission {
4- id : number ;
5- phoneNumber : string ;
6- productLink : string ;
7- codeLink : string ;
8- submittedAt : string ;
9- status : "pending" | "approved" | "rejected" ;
10- }
1+ import { ExternalLink , History , Clock } from "lucide-react" ;
2+ import { useQuery } from "@tanstack/react-query" ;
3+ import TeamApi from "~/api-requests/team.requests" ;
4+ import { useAppSelector } from "~/hooks/useRedux" ;
5+ import Loading from "~/components/Loading" ;
116
127const HistorySubmit = ( ) => {
13- const [ submissions ] = useState < Submission [ ] > ( [
14- {
15- id : 1 ,
16- phoneNumber : "0123456789" ,
17- productLink : "https://demo.example.com" ,
18- codeLink : "https://github.com/user/project" ,
19- submittedAt : "2025-12-19 14:30:00" ,
20- status : "approved" ,
21- } ,
22- {
23- id : 2 ,
24- phoneNumber : "0123456789" ,
25- productLink : "https://demo-v2.example.com" ,
26- codeLink : "https://github.com/user/project-v2" ,
8+ const userInfo = useAppSelector ( ( state ) => state . user . userInfo ) ;
9+ const teamId = userInfo . candidate ?. teamId || "" ;
2710
28- submittedAt : "2025-12-19 16:45:00" ,
29- status : "pending" ,
11+ const { data : submissions , isLoading } = useQuery ( {
12+ queryKey : [ "submissions" , teamId ] ,
13+ queryFn : async ( ) => {
14+ if ( ! teamId ) return [ ] ;
15+ const res = await TeamApi . getSubmissionInTeam ( teamId ) ;
16+ return res . result ;
3017 } ,
31- ] ) ;
18+ enabled : ! ! teamId ,
19+ } ) ;
3220
33- const getStatusBadge = ( status : Submission [ "status" ] ) => {
34- switch ( status ) {
35- case "approved" :
36- return (
37- < span className = "inline-flex items-center gap-1.5 rounded-md border border-green-200/50 bg-green-50 px-2.5 py-1 text-xs font-medium text-green-700" >
38- < CheckCircle2 className = "h-3.5 w-3.5" />
39- Đã ghi nhận
40- </ span >
41- ) ;
42- case "rejected" :
43- return (
44- < span className = "inline-flex items-center gap-1.5 rounded-md border border-red-200/50 bg-red-50 px-2.5 py-1 text-xs font-medium text-red-700" >
45- < XCircle className = "h-3.5 w-3.5" />
46- Không hợp lệ
47- </ span >
48- ) ;
49- case "pending" :
50- default :
51- return (
52- < span className = "inline-flex items-center gap-1.5 rounded-md border border-yellow-200/50 bg-yellow-50 px-2.5 py-1 text-xs font-medium text-yellow-700" >
53- < AlertCircle className = "h-3.5 w-3.5" />
54- Chờ xác nhận
55- </ span >
56- ) ;
57- }
58- } ;
21+ if ( isLoading ) return < Loading /> ;
5922
6023 return (
6124 < div className = "overflow-hidden rounded-md border border-gray-200/70 bg-white" >
@@ -67,7 +30,7 @@ const HistorySubmit = () => {
6730 </ div >
6831
6932 < div className = "overflow-x-auto" >
70- { submissions . length === 0 ? (
33+ { ! submissions || submissions . length === 0 ? (
7134 < div className = "py-16 text-center" >
7235 < div className = "mx-auto flex h-16 w-16 items-center justify-center rounded-full bg-gray-100" >
7336 < History className = "h-8 w-8 text-gray-400" />
@@ -88,9 +51,8 @@ const HistorySubmit = () => {
8851 < th className = "px-4 py-3 text-left text-xs font-semibold tracking-wide text-gray-600 uppercase sm:px-6 sm:py-3.5" >
8952 Link sản phẩm
9053 </ th >
91-
9254 < th className = "px-4 py-3 text-left text-xs font-semibold tracking-wide text-gray-600 uppercase sm:px-6 sm:py-3.5" >
93- Trạng thái
55+ Ghi chú
9456 </ th >
9557 </ tr >
9658 </ thead >
@@ -123,30 +85,33 @@ const HistorySubmit = () => {
12385 < td className = "px-4 py-3.5 text-sm sm:px-6 sm:py-4" >
12486 < div className = "flex flex-col gap-2" >
12587 < a
126- href = { submission . productLink }
88+ href = { submission . presentationLink }
12789 target = "_blank"
12890 rel = "noopener noreferrer"
12991 className = "text-primary hover:text-primary/80 flex items-center gap-1.5 font-medium transition-colors"
13092 >
13193 < ExternalLink className = "h-3.5 w-3.5" />
132- < span > Xem sản phẩm </ span >
94+ < span > Slide & Sheet </ span >
13395 </ a >
134- { submission . codeLink && (
96+ { submission . productLink && (
13597 < a
136- href = { submission . codeLink }
98+ href = { submission . productLink }
13799 target = "_blank"
138100 rel = "noopener noreferrer"
139101 className = "flex items-center gap-1.5 text-gray-600 transition-colors hover:text-gray-900"
140102 >
141103 < ExternalLink className = "h-3.5 w-3.5" />
142- < span > Mã nguồn </ span >
104+ < span > Source/Figma </ span >
143105 </ a >
144106 ) }
145107 </ div >
146108 </ td >
147-
148- < td className = "px-4 py-3.5 text-sm whitespace-nowrap sm:px-6 sm:py-4" >
149- { getStatusBadge ( submission . status ) }
109+ < td className = "px-4 py-3.5 text-sm text-gray-600 sm:px-6 sm:py-4" >
110+ < p className = "max-w-xs truncate" >
111+ { submission . note || (
112+ < span className = "text-gray-400 italic" > Không có ghi chú</ span >
113+ ) }
114+ </ p >
150115 </ td >
151116 </ tr >
152117 ) ;
0 commit comments