@@ -6,7 +6,10 @@ import { track } from "@vercel/analytics"
66import { Button } from "@/components/ui/button"
77import { FileUpload } from "@/components/upload/file-upload"
88import { uploadFile , getJobStatus , downloadResult , APIError } from "@/lib/api"
9+ < << << << HEAD
910import { useConversionHistoryContext } from "@/components/history/conversion-history-provider"
11+ = === ===
12+ >>> >>> > pr - 35
1013import type { Job } from "@/lib/types"
1114
1215export function UploadSection ( ) {
@@ -17,7 +20,10 @@ export function UploadSection() {
1720 const [ loading , setLoading ] = useState ( false )
1821 const [ error , setError ] = useState < string | null > ( null )
1922 const [ resultUrl , setResultUrl ] = useState < string | null > ( null )
23+ << < < << < HEAD
2024 const { addHistoryItem , updateHistoryItem } = useConversionHistoryContext ( )
25+ === = ===
26+ >>> > >>> pr - 35
2127
2228 const handleFileSelect = ( file : File ) => {
2329 setSelectedFile ( file )
@@ -41,6 +47,7 @@ export function UploadSection() {
4147 setJobId ( response . job_id )
4248 setJobStatus ( "pending" )
4349
50+ << < < << < HEAD
4451 // Create initial history item
4552 const apiUrl = process . env . NEXT_PUBLIC_API_URL | | "https://editbanana.anxin6.cn"
4653 addHistoryItem ( {
@@ -54,6 +61,10 @@ export function UploadSection() {
5461
5562 // Poll for status
5663 pollJobStatus ( response . job_id , selectedFile . name , selectedFile . size )
64+ === = ===
65+ // Poll for status
66+ pollJobStatus ( response . job_id )
67+ >>> > >>> pr - 35
5768 } catch ( err ) {
5869 setLoading ( false )
5970 if ( err instanceof APIError ) {
@@ -64,7 +75,11 @@ export function UploadSection() {
6475 }
6576 }
6677
78+ << < < << < HEAD
6779 const pollJobStatus = async ( id : string , filename : string , fileSize : number ) => {
80+ = === ===
81+ const pollJobStatus = async ( id : string ) => {
82+ > >>> >>> pr - 35
6883 const interval = setInterval ( async ( ) => {
6984 try {
7085 const job = await getJobStatus ( id )
@@ -79,6 +94,7 @@ export function UploadSection() {
7994 clearInterval ( interval )
8095 setLoading ( false )
8196 setProgress ( 100 )
97+ << < < << < HEAD
8298 const apiUrl = process . env . NEXT_PUBLIC_API_URL | | "https://editbanana.anxin6.cn"
8399 const newResultUrl = `${ apiUrl } /api/v1/jobs/${ id } /result`
84100 setResultUrl ( newResultUrl )
@@ -89,27 +105,37 @@ export function UploadSection() {
89105 status : "completed" ,
90106 resultUrl : newResultUrl ,
91107 } )
108+ === = ===
109+ setResultUrl ( `${ process . env . NEXT_PUBLIC_API_URL || "https://editbanana.anxin6.cn" } /api/v1/jobs/${ id } /result` )
110+ track ( "conversion_completed" , { job_id : id } )
111+ >>> > >>> pr - 35
92112 } else if ( job . status === "failed" || job . status === "cancelled" ) {
93113 clearInterval ( interval )
94114 setLoading ( false )
95115 setError ( job . error || "Conversion failed" )
116+ << < < << < HEAD
96117
97118 // Update history item with error status
98119 updateHistoryItem ( id , {
99120 status : job . status as "failed" | "cancelled" ,
100121 error : job . error || "Conversion failed" ,
101122 } )
123+ === = ===
124+ >>> > >>> pr - 35
102125 }
103126 } catch ( err ) {
104127 clearInterval ( interval )
105128 setLoading ( false )
106129 setError ( "Failed to get job status" )
130+ << < < << < HEAD
107131
108132 // Update history item with error
109133 updateHistoryItem ( id , {
110134 status : "failed" ,
111135 error : "Failed to get job status" ,
112136 } )
137+ === = ===
138+ >>> > >>> pr - 35
113139 }
114140 } , 2000 )
115141 }
0 commit comments