beautify: adjust personal register upload id

This commit is contained in:
DeathKaioken 2025-10-22 19:41:11 +02:00
parent e0a18f42ea
commit 97231ee7b6
4 changed files with 26 additions and 14 deletions

View File

@ -37,7 +37,7 @@ export function useCompanyUploadId() {
// File handlers // File handlers
const handleFile = (file: File, which: 'front' | 'extra') => { const handleFile = (file: File, which: 'front' | 'extra') => {
if (file.size > 10 * 1024 * 1024) { if (file.size > 10 * 1024 * 1024) {
setError('Datei größer als 10 MB.') setError('File size exceeds 10 MB.')
return return
} }
setError('') setError('')
@ -81,7 +81,7 @@ export function useCompanyUploadId() {
// Validation // Validation
const validate = () => { const validate = () => {
if (!docNumber.trim() || !docType || !issueDate || !frontFile) { if (!docNumber.trim() || !docType || !issueDate || !frontFile) {
setError('Bitte alle Pflichtfelder (mit *) ausfüllen.') setError('Please complete all required fields (marked with *).')
return false return false
} }
setError('') setError('')
@ -128,7 +128,7 @@ export function useCompanyUploadId() {
}, 1500) }, 1500)
} catch (err: any) { } catch (err: any) {
console.error('Company ID upload error:', err) console.error('Company ID upload error:', err)
setError(err?.message || 'Upload fehlgeschlagen.') setError(err?.message || 'Upload failed.')
} finally { } finally {
setSubmitting(false) setSubmitting(false)
} }

View File

@ -274,7 +274,7 @@ export default function CompanyIdUploadPage() {
)} )}
{success && ( {success && (
<div className="mt-6 rounded-md border border-green-300 bg-green-50 px-4 py-3 text-sm text-green-700"> <div className="mt-6 rounded-md border border-green-300 bg-green-50 px-4 py-3 text-sm text-green-700">
Dokumente erfolgreich hochgeladen. Documents uploaded successfully.
</div> </div>
)} )}

View File

@ -37,7 +37,7 @@ export function usePersonalUploadId() {
// File handlers // File handlers
const handleFile = (f: File, side: 'front' | 'back') => { const handleFile = (f: File, side: 'front' | 'back') => {
if (f.size > 10 * 1024 * 1024) { if (f.size > 10 * 1024 * 1024) {
setError('Datei größer als 10 MB.') setError('File size exceeds 10 MB.')
return return
} }
setError('') setError('')
@ -81,15 +81,15 @@ export function usePersonalUploadId() {
// Validation // Validation
const validate = () => { const validate = () => {
if (!idNumber.trim() || !idType || !expiry) { if (!idNumber.trim() || !idType || !expiry) {
setError('Bitte alle Pflichtfelder ausfüllen.') setError('Please fill out all required fields.')
return false return false
} }
if (!frontFile) { if (!frontFile) {
setError('Vorderseite hochladen.') setError('Please upload the front side.')
return false return false
} }
if (hasBack && !backFile) { if (hasBack && !backFile) {
setError('Rückseite hochladen oder Schalter deaktivieren.') setError('Please upload the back side or disable the switch.')
return false return false
} }
setError('') setError('')
@ -101,7 +101,7 @@ export function usePersonalUploadId() {
e.preventDefault() e.preventDefault()
if (!validate()) return if (!validate()) return
if (!token) { if (!token) {
setError('Nicht authentifiziert. Bitte erneut einloggen.') setError('Not authenticated. Please log in again.')
return return
} }
@ -131,11 +131,11 @@ export function usePersonalUploadId() {
window.location.href = '/quickaction-dashboard' window.location.href = '/quickaction-dashboard'
}, 2000) }, 2000)
} else { } else {
setError(data.message || 'Upload fehlgeschlagen. Bitte erneut versuchen.') setError(data.message || 'Upload failed. Please try again.')
} }
} catch (err) { } catch (err) {
console.error('Upload error:', err) console.error('Upload error:', err)
setError('Netzwerkfehler. Bitte erneut versuchen.') setError('Network error. Please try again.')
} finally { } finally {
setSubmitting(false) setSubmitting(false)
} }

View File

@ -7,6 +7,14 @@ import { useRouter } from 'next/navigation'
import useAuthStore from '../../../store/authStore' import useAuthStore from '../../../store/authStore'
import { DocumentArrowUpIcon, XMarkIcon } from '@heroicons/react/24/outline' import { DocumentArrowUpIcon, XMarkIcon } from '@heroicons/react/24/outline'
// Add back ID types for the dropdown
const ID_TYPES = [
{ value: 'national_id', label: 'National ID Card' },
{ value: 'passport', label: 'Passport' },
{ value: 'driver_license', label: "Driver's License" },
{ value: 'other', label: 'Other' },
]
export default function PersonalIdUploadPage() { export default function PersonalIdUploadPage() {
// NEW: guard company users from accessing personal page // NEW: guard company users from accessing personal page
const user = useAuthStore(s => s.user) const user = useAuthStore(s => s.user)
@ -110,7 +118,11 @@ export default function PersonalIdUploadPage() {
required required
> >
<option value="">Select ID type</option> <option value="">Select ID type</option>
{/* ...existing options... */} {ID_TYPES.map(t => (
<option key={t.value} value={t.value}>
{t.label}
</option>
))}
</select> </select>
</div> </div>
@ -273,7 +285,7 @@ export default function PersonalIdUploadPage() {
)} )}
{success && ( {success && (
<div className="mt-6 rounded-md border border-green-300 bg-green-50 px-4 py-3 text-sm text-green-700"> <div className="mt-6 rounded-md border border-green-300 bg-green-50 px-4 py-3 text-sm text-green-700">
Upload erfolgreich gespeichert. Upload saved successfully.
</div> </div>
)} )}