+ {selectedType && selectedType.customInputs.length > 0 && (
+
+ {selectedType.customInputs.map((input) => {
+ const name = `customFields.${input.customInput.name}`
+ return (
+ (
+
+ {input.label}
+
+ {input.inputType === "textarea" ? (
+
+ ) : input.inputType === "number" ? (
+
+ ) : input.inputType === "checkbox" ? (
+ field.onChange(e.target.checked)}
+ />
+ ) : input.inputType === "date" ? (
+
+ ) : input.inputType === "select" ? (
+ // Placeholder select – populate with options if needed
+
+ ) : (
+
+ )}
+
+
+
+ )}
+ />
+ )
+ })}
+
+ )}
+
Reference Images
@@ -237,7 +281,10 @@ export function CommissionOrderForm({ types }: Props) {
- Estimated Price: €{price.toFixed(2)}
+ Estimated Price:{" "}
+ {minPrice === maxPrice
+ ? `€${minPrice.toFixed(2)}`
+ : `€${minPrice.toFixed(2)} – €${maxPrice.toFixed(2)}`}
diff --git a/src/components/global/TopNav.tsx b/src/components/global/TopNav.tsx
index 6b33239..de86749 100644
--- a/src/components/global/TopNav.tsx
+++ b/src/components/global/TopNav.tsx
@@ -22,6 +22,11 @@ export default function TopNav() {
Terms of Service
+
+
+ todo (temp)
+
+
);
diff --git a/src/schemas/commissionOrder.ts b/src/schemas/commissionOrder.ts
index 887e6fb..8ad27fb 100644
--- a/src/schemas/commissionOrder.ts
+++ b/src/schemas/commissionOrder.ts
@@ -4,6 +4,7 @@ export const commissionOrderSchema = z.object({
typeId: z.string().min(1, "Please select a type"),
optionId: z.string().min(1, "Please choose a base option"),
extraIds: z.array(z.string()).optional(),
+ customFields: z.record(z.string(), z.any()).optional(),
customerName: z.string().min(2, "Enter your name"),
customerEmail: z.string().email("Invalid email"),
message: z.string().min(5, "Please describe what you want"),
diff --git a/src/utils/calculatePrice.ts b/src/utils/calculatePrice.ts
index 7a27aa3..99b9c1d 100644
--- a/src/utils/calculatePrice.ts
+++ b/src/utils/calculatePrice.ts
@@ -1,36 +1,3 @@
-// export function calculatePrice(
-// option: { price?: number; pricePercent?: number; priceRange?: string },
-// extras: { price?: number; pricePercent?: number; priceRange?: string }[]
-// ): number | [number, number] {
-// const base = option.price ?? 0
-
-// let total = base
-// let hasRange = false
-// let min = base
-// let max = base
-
-// for (const ext of extras) {
-// if (ext.price !== undefined) {
-// total += ext.price
-// min += ext.price
-// max += ext.price
-// } else if (ext.pricePercent !== undefined) {
-// const delta = base * (ext.pricePercent / 100)
-// total += delta
-// min += delta
-// max += delta
-// } else if (ext.priceRange) {
-// const [rMin, rMax] = ext.priceRange.split("–").map(Number)
-// hasRange = true
-// min += rMin
-// max += rMax
-// }
-// }
-
-// return hasRange ? [min, max] : total
-// }
-
-
type PriceSource = {
price?: number | null
pricePercent?: number | null
@@ -46,4 +13,36 @@ export function calculatePrice(source: PriceSource, base: number): number {
return isNaN(max) ? 0 : max
}
return 0
+}
+
+export function calculatePriceRange(
+ baseSource: PriceSource | undefined,
+ extras: PriceSource[]
+): [number, number] {
+ if (!baseSource) return [0, 0]
+
+ const base = calculatePrice(baseSource, 0)
+
+ let minExtra = 0
+ let maxExtra = 0
+
+ for (const extra of extras) {
+ if (extra.price != null) {
+ minExtra += extra.price
+ maxExtra += extra.price
+ } else if (extra.pricePercent != null) {
+ const val = base * (extra.pricePercent / 100)
+ minExtra += val
+ maxExtra += val
+ } else if (extra.priceRange) {
+ const [minStr, maxStr] = extra.priceRange.split("–")
+ const min = Number(minStr)
+ const max = Number(maxStr)
+
+ if (!isNaN(min)) minExtra += min
+ if (!isNaN(max)) maxExtra += max
+ }
+ }
+
+ return [base + minExtra, base + maxExtra]
}
\ No newline at end of file