feat: assign orders to companies directly and support admin reassignment
All checks were successful
Staging Build / build (push) Successful in 3m36s
All checks were successful
Staging Build / build (push) Successful in 3m36s
This commit is contained in:
@@ -81,16 +81,23 @@ export function OrderWizard({
|
||||
initialProfile,
|
||||
initialEndCustomers,
|
||||
initialOrder,
|
||||
isAdmin = false,
|
||||
companies = [],
|
||||
}: {
|
||||
products: Product[]
|
||||
categories: Category[]
|
||||
initialProfile: Profile | null
|
||||
initialEndCustomers: EndCustomer[]
|
||||
initialOrder?: Order | null
|
||||
isAdmin?: boolean
|
||||
companies?: any[]
|
||||
}) {
|
||||
const router = useRouter()
|
||||
const [step, setStep] = useState(initialOrder ? 3 : 1)
|
||||
const [isSubmitting, setIsSubmitting] = useState(false)
|
||||
const [selectedCompanyId, setSelectedCompanyId] = useState<string | null>(
|
||||
initialOrder?.company_id ?? null
|
||||
)
|
||||
|
||||
// Partner-Profil (Fallback)
|
||||
const [customerData] = useState<Partial<Profile>>(initialProfile || {})
|
||||
@@ -414,6 +421,7 @@ export function OrderWizard({
|
||||
endCustomer: selectedEndCustomer,
|
||||
billingInterval: selectedBillingInterval,
|
||||
lastLicenseDate: lastLicenseDate || null,
|
||||
companyId: selectedCompanyId,
|
||||
})
|
||||
} else {
|
||||
order = await submitOrder({
|
||||
@@ -482,6 +490,29 @@ export function OrderWizard({
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-6">
|
||||
{/* Admin Company Selector */}
|
||||
{isAdmin && (
|
||||
<div className="p-4 rounded-xl bg-white/5 border border-white/10 space-y-3">
|
||||
<Label htmlFor="order-company" className="text-white font-medium flex items-center gap-2">
|
||||
<Building2 className="w-4 h-4 text-primary" />
|
||||
Zugeordnetes Unternehmen (Admin-Option)
|
||||
</Label>
|
||||
<select
|
||||
id="order-company"
|
||||
value={selectedCompanyId || ''}
|
||||
onChange={(e) => setSelectedCompanyId(e.target.value || null)}
|
||||
className="flex h-9 w-full rounded-md border border-white/10 bg-slate-900 px-3 py-1 text-sm shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary text-white"
|
||||
>
|
||||
<option value="">Keine Firma zugewiesen</option>
|
||||
{companies.map((c: any) => (
|
||||
<option key={c.id} value={c.id}>
|
||||
{c.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Modus-Toggle */}
|
||||
<div className="flex gap-2">
|
||||
<Button
|
||||
|
||||
Reference in New Issue
Block a user