Includes business, customer, and super-admin apps with shared packages and production deploy scripts. Co-authored-by: Cursor <cursoragent@cursor.com>
44 lines
1.4 KiB
TypeScript
44 lines
1.4 KiB
TypeScript
import type { ProductVariant } from '../types/productVariant'
|
|
import { buildVariantLabel } from '../types/productVariant'
|
|
import { DEFAULT_VARIATIONS } from '../types/variation'
|
|
|
|
function makeVariant(
|
|
id: string,
|
|
color: string,
|
|
capacity: string,
|
|
guarantee: string,
|
|
): ProductVariant {
|
|
const selections = [
|
|
{ attributeId: 'default-color', attributeName: 'Color', optionId: `opt-color-${color}`, value: color },
|
|
{ attributeId: 'default-capacity', attributeName: 'Capacity', optionId: `opt-capacity-${capacity}`, value: capacity },
|
|
{ attributeId: 'default-guarantee', attributeName: 'Guarantee', optionId: `opt-guarantee-${guarantee}`, value: guarantee },
|
|
]
|
|
return {
|
|
id,
|
|
selections,
|
|
label: buildVariantLabel(selections),
|
|
}
|
|
}
|
|
|
|
const seeded: Record<string, ProductVariant[]> = {
|
|
'1': [
|
|
makeVariant('v-1-1', 'Red', '128GB', '1 Year'),
|
|
makeVariant('v-1-2', 'Blue', '256GB', '2 Years'),
|
|
],
|
|
'3': [makeVariant('v-3-1', 'Black', '64GB', '1 Year')],
|
|
'5': [
|
|
makeVariant('v-5-1', 'Silver', '128GB', '2 Years'),
|
|
makeVariant('v-5-2', 'Gold', '256GB', '2 Years'),
|
|
makeVariant('v-5-3', 'Navy', '512GB', '1 Year'),
|
|
],
|
|
'13': [makeVariant('v-13-1', 'Red', '64GB', '1 Year')],
|
|
}
|
|
|
|
export function getInitialProductVariants(): Record<string, ProductVariant[]> {
|
|
return { ...seeded }
|
|
}
|
|
|
|
export function getProductAttributes() {
|
|
return DEFAULT_VARIATIONS
|
|
}
|