'use client' import PageLayout from '../../../components/PageLayout' import { DocumentArrowUpIcon, XMarkIcon } from '@heroicons/react/24/outline' import { useCompanyUploadId } from './hooks/useCompanyUploadId' import useAuthStore from '../../../store/authStore' // NEW import { useEffect, useState } from 'react' // NEW import { useRouter } from 'next/navigation' // NEW const DOC_TYPES = ['Personalausweis', 'Reisepass', 'Führerschein', 'Aufenthaltstitel'] export default function CompanyIdUploadPage() { const { // values docNumber, setDocNumber, docType, setDocType, issueDate, setIssueDate, hasBack, setHasBack, setExtraFile, frontFile, extraFile, frontPreview, extraPreview, submitting, error, success, frontRef, extraRef, inputBase, // handlers handleFile, onDrop, clearFile, dropHandlers, openPicker, submit, } = useCompanyUploadId() const user = useAuthStore(s => s.user) // NEW const router = useRouter() // NEW const [blocked, setBlocked] = useState(false) // NEW // Guard: only 'company' users allowed on this page useEffect(() => { const ut = (user as any)?.userType || (user as any)?.role console.log('🧭 UploadID Guard [company]: userType =', ut) if (ut && ut !== 'company') { console.warn('🚫 UploadID Guard [company]: access denied for userType:', ut, '-> redirecting to personal upload') setBlocked(true) router.replace('/quickaction-dashboard/register-upload-id/personal') } else if (ut === 'company') { console.log('✅ UploadID Guard [company]: access granted') } }, [user, router]) if (blocked) { return (
Redirecting to the correct upload page…
) } return (
{/* Background (same as personal) */}

Company Contact Person Identity Verification

Please upload clear photos of both sides of the company contact person's ID document.

{/* Fields: 3 in one row on md+ with unified inputs */}
setDocNumber(e.target.value)} className={`${inputBase} ${docNumber ? 'text-gray-900' : 'text-gray-700'}`} placeholder="Enter contact person's ID number" required />

Enter the ID number exactly as shown on the document

setIssueDate(e.target.value)} placeholder="tt.mm.jjjj" className={`${inputBase} ${issueDate ? 'text-gray-900' : 'text-gray-700'} appearance-none [&::-webkit-calendar-picker-indicator]:opacity-80`} required />

Enter the expiry date shown on your document

{/* Back side toggle */}
Does ID have a Backside? {hasBack ? 'Yes' : 'No'}
{/* Upload Areas */}
{/* Upload ID Front Side */}
onDrop(e, 'front')} onClick={() => openPicker('front')} className="group relative flex flex-col items-center justify-center rounded-lg border-2 border-dashed border-gray-300 bg-gray-50/60 px-4 py-6 sm:py-10 text-center hover:border-indigo-400 hover:bg-indigo-50/40 cursor-pointer transition" > { const f = e.target.files?.[0]; if (f) handleFile(f, 'front') }} /> {frontFile ? (
{/* Preview only for images */} {frontPreview && ( Primary document preview )}

{frontFile.name}

) : ( <>

Click to upload front side

or drag and drop
PNG, JPG, JPEG up to 10MB

)}
{/* Upload ID Back Side */} {hasBack && (
onDrop(e, 'extra')} onClick={() => openPicker('extra')} className="group relative flex flex-col items-center justify-center rounded-lg border-2 border-dashed border-gray-300 bg-gray-50/60 px-4 py-6 sm:py-10 text-center hover:border-indigo-400 hover:bg-indigo-50/40 cursor-pointer transition" > { const f = e.target.files?.[0]; if (f) handleFile(f, 'extra') }} /> {extraFile ? (
{/* Preview only for images */} {extraPreview && ( Supporting document preview )}

{extraFile.name}

) : ( <>

Click to upload back side

or drag and drop
PNG, JPG, JPEG up to 10MB

)}
)}
{/* Info */}

Please ensure your ID documents:

  • Are clearly visible and readable
  • Show all four corners
  • Are not expired
  • Have good lighting (no shadows or glare)
  • {hasBack ? 'Both front and back sides are uploaded' : 'Front side is uploaded'}
{error && (
{error}
)} {success && (
Dokumente erfolgreich hochgeladen.
)}
) }