File tree Expand file tree Collapse file tree
admin/projects/[id]/share Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -505,6 +505,7 @@ export default function AdminSharePage() {
505505 selectedVideo = { videoState . selectedVideo }
506506 displayLabel = { videoState . displayLabel }
507507 isVideoApproved = { videoState . isVideoApproved }
508+ projectId = { project . id }
508509 projectTitle = { project . title }
509510 projectDescription = { project . description }
510511 clientName = { project . clientName }
Original file line number Diff line number Diff line change @@ -862,6 +862,7 @@ export default function SharePageClient({ token }: SharePageClientProps) {
862862 selectedVideo = { videoState . selectedVideo }
863863 displayLabel = { videoState . displayLabel }
864864 isVideoApproved = { videoState . isVideoApproved }
865+ projectId = { project . id }
865866 projectTitle = { project . title }
866867 projectDescription = { project . description }
867868 clientName = { project . clientName }
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ interface ProjectInfoProps {
2121 selectedVideo : Video & { name ?: string ; approved ?: boolean ; downloadUrl ?: string ; cleanPreview720Path ?: string | null ; cleanPreview1080Path ?: string | null }
2222 displayLabel : string
2323 isVideoApproved : boolean
24+ projectId : string
2425 projectTitle ?: string
2526 projectDescription ?: string
2627 clientName ?: string
@@ -44,6 +45,7 @@ export default function ProjectInfo({
4445 selectedVideo,
4546 displayLabel,
4647 isVideoApproved,
48+ projectId,
4749 projectTitle,
4850 projectDescription,
4951 clientName,
@@ -131,13 +133,35 @@ export default function ProjectInfo({
131133 }
132134
133135 const handleApprove = async ( ) => {
134- if ( ! onApprove ) return
135-
136136 setLoading ( true )
137+
138+ const authHeaders = buildAuthHeaders ( shareToken )
139+
137140 try {
138- await onApprove ( )
141+ const response = await fetch ( `/api/projects/${ projectId } /approve` , {
142+ method : 'POST' ,
143+ headers : { 'Content-Type' : 'application/json' , ...authHeaders } ,
144+ body : JSON . stringify ( {
145+ selectedVideoId : selectedVideo . id ,
146+ } ) ,
147+ } )
148+
149+ if ( ! response . ok ) {
150+ const errorData = await response . json ( )
151+ throw new Error ( errorData . error || 'Failed to approve project' )
152+ }
153+
154+ // Store the current video group name in sessionStorage to restore after reload
155+ if ( activeVideoName ) {
156+ sessionStorage . setItem ( 'approvedVideoName' , activeVideoName )
157+ }
158+
159+ // Call the optional callback if provided (for parent component to refresh data)
160+ if ( onApprove ) {
161+ await onApprove ( )
162+ }
139163 } catch ( error ) {
140- alert ( 'Failed to approve project' )
164+ alert ( error instanceof Error ? error . message : 'Failed to approve project' )
141165 } finally {
142166 setLoading ( false )
143167 setShowApprovalConfirm ( false )
Original file line number Diff line number Diff line change @@ -750,6 +750,7 @@ export default function VideoPlayer({
750750 selectedVideo = { selectedVideo }
751751 displayLabel = { displayLabel }
752752 isVideoApproved = { isVideoApproved }
753+ projectId = { projectId }
753754 projectTitle = { projectTitle }
754755 projectDescription = { projectDescription }
755756 clientName = { clientName }
You can’t perform that action at this time.
0 commit comments