From 3f798432a0fd962b89351e10db580d954fed42b6 Mon Sep 17 00:00:00 2001 From: Priec Date: Mon, 22 Jun 2026 15:44:02 +0200 Subject: [PATCH] now products have different options, like different parameters --- assets/i18n/en/main.ftl | 5 + assets/i18n/sk/main.ftl | 5 + assets/static/css/app.css | 2 +- assets/views/account/order_detail.html | 2 +- assets/views/admin/catalog/product_form.html | 95 +++- assets/views/admin/catalog/products.html | 21 +- assets/views/admin/customers/price_form.html | 8 +- assets/views/admin/customers/show.html | 9 +- assets/views/admin/orders/show.html | 2 +- assets/views/shop/_card.html | 11 +- assets/views/shop/_cart_body.html | 5 +- assets/views/shop/_cart_preview.html | 1 + assets/views/shop/order_confirmed.html | 2 +- assets/views/shop/show.html | 90 +++- migration/src/lib.rs | 2 + .../src/m20260622_000002_product_variants.rs | 204 +++++++ src/controllers/admin_customers.rs | 88 +-- src/controllers/admin_form.rs | 17 + src/controllers/admin_products.rs | 499 +++++++++--------- src/controllers/cart.rs | 67 ++- src/controllers/shop.rs | 67 ++- .../_entities/account_discount_profiles.rs | 31 +- .../_entities/account_product_prices.rs | 35 +- .../_entities/account_product_resolutions.rs | 62 ++- .../_entities/audience_discount_profiles.rs | 5 +- src/models/_entities/audit_logs.rs | 2 +- src/models/_entities/categories.rs | 8 +- src/models/_entities/customer_profiles.rs | 15 +- .../_entities/discount_profile_products.rs | 3 +- src/models/_entities/discount_profiles.rs | 37 +- src/models/_entities/mod.rs | 7 +- src/models/_entities/o_auth2_sessions.rs | 11 +- src/models/_entities/order_items.rs | 18 +- src/models/_entities/orders.rs | 16 +- src/models/_entities/prelude.rs | 3 +- src/models/_entities/product_images.rs | 2 +- src/models/_entities/product_product_tags.rs | 2 +- src/models/_entities/product_tags.rs | 2 +- src/models/_entities/product_variants.rs | 63 +++ src/models/_entities/products.rs | 23 +- src/models/_entities/shipping_methods.rs | 2 +- src/models/_entities/users.rs | 44 +- src/models/account_product_prices.rs | 18 +- src/models/mod.rs | 1 + src/models/o_auth2_sessions.rs | 10 +- src/models/orders.rs | 32 +- src/models/product_variants.rs | 89 ++++ src/models/products.rs | 27 +- src/seed.rs | 21 +- src/shared/pricing.rs | 75 +-- src/views/checkout.rs | 1 + src/views/shop.rs | 42 +- 52 files changed, 1281 insertions(+), 628 deletions(-) create mode 100644 migration/src/m20260622_000002_product_variants.rs create mode 100644 src/models/_entities/product_variants.rs create mode 100644 src/models/product_variants.rs diff --git a/assets/i18n/en/main.ftl b/assets/i18n/en/main.ftl index f63c974..72683cc 100644 --- a/assets/i18n/en/main.ftl +++ b/assets/i18n/en/main.ftl @@ -209,6 +209,11 @@ product = Product name = Name price = Price sale-price = Sale price +variants-options = Variants / options +add-option = Add option +option-label = Option label +choose-option = Choose an option +from-price = from { $price } admin-discounts = Discounts admin-discounts-desc = Set discounted product prices. A discount shows up as a sale in the shop. business-discount-desc = A baseline discount for all business accounts (off the regular price). Profiles and negotiated prices apply on top (lowest price wins). diff --git a/assets/i18n/sk/main.ftl b/assets/i18n/sk/main.ftl index b7cd1bf..776cb2e 100644 --- a/assets/i18n/sk/main.ftl +++ b/assets/i18n/sk/main.ftl @@ -209,6 +209,11 @@ product = Produkt name = Názov price = Cena sale-price = Zľavnená cena +variants-options = Varianty / možnosti +add-option = Pridať možnosť +option-label = Označenie možnosti +choose-option = Vyberte možnosť +from-price = od { $price } admin-discounts = Zľavy admin-discounts-desc = Nastavte zľavnené ceny produktov. Zľava sa v obchode zobrazí ako akcia. business-discount-desc = Základná zľava pre všetky firemné účty (z bežnej ceny). Profily a dohodnuté ceny sa uplatnia navyše (platí najnižšia cena). diff --git a/assets/static/css/app.css b/assets/static/css/app.css index 21f093e..5346523 100644 --- a/assets/static/css/app.css +++ b/assets/static/css/app.css @@ -1,2 +1,2 @@ /*! tailwindcss v4.3.1 | MIT License | https://tailwindcss.com */ -@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-divide-y-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-content:""}}}@layer theme{:root,:host{--font-sans:ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-red-600:oklch(57.7% .245 27.325);--color-amber-500:oklch(76.9% .188 70.08);--color-green-600:oklch(62.7% .194 149.214);--color-emerald-600:oklch(59.6% .145 163.225);--color-sky-500:oklch(68.5% .169 237.323);--color-indigo-400:oklch(67.3% .182 276.935);--color-indigo-600:oklch(51.1% .262 276.966);--color-slate-100:oklch(96.8% .007 247.896);--color-slate-300:oklch(86.9% .022 252.894);--color-slate-600:oklch(44.6% .043 257.281);--color-slate-700:oklch(37.2% .044 257.287);--color-slate-800:oklch(27.9% .041 260.031);--color-slate-900:oklch(20.8% .042 265.755);--color-slate-950:oklch(12.9% .042 264.695);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-sm:24rem;--container-md:28rem;--container-xl:36rem;--container-2xl:42rem;--container-3xl:48rem;--container-5xl:64rem;--container-7xl:80rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height:calc(1.5 / 1);--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75 / 1.25);--text-2xl:1.5rem;--text-2xl--line-height:calc(2 / 1.5);--text-3xl:1.875rem;--text-3xl--line-height:calc(2.25 / 1.875);--text-4xl:2.25rem;--text-4xl--line-height:calc(2.5 / 2.25);--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-tight:-.025em;--tracking-wide:.025em;--tracking-wider:.05em;--leading-tight:1.25;--leading-relaxed:1.625;--radius-sm:.25rem;--ease-in:cubic-bezier(.4, 0, 1, 1);--ease-out:cubic-bezier(0, 0, .2, 1);--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--color-surface:var(--color-white);--color-surface-alt:var(--color-slate-100);--color-on-surface:var(--color-slate-700);--color-on-surface-strong:var(--color-slate-900);--color-primary:var(--color-indigo-600);--color-on-primary:var(--color-white);--color-secondary:var(--color-slate-600);--color-on-secondary:var(--color-white);--color-outline:var(--color-slate-300);--color-outline-strong:var(--color-slate-800);--color-surface-dark:var(--color-slate-900);--color-surface-dark-alt:var(--color-slate-800);--color-on-surface-dark:var(--color-slate-300);--color-on-surface-dark-strong:var(--color-white);--color-primary-dark:var(--color-indigo-400);--color-on-primary-dark:var(--color-slate-950);--color-secondary-dark:var(--color-slate-300);--color-on-secondary-dark:var(--color-slate-950);--color-outline-dark:var(--color-slate-700);--color-outline-dark-strong:var(--color-slate-300);--color-info:var(--color-sky-500);--color-on-info:var(--color-white);--color-success:var(--color-green-600);--color-on-success:var(--color-white);--color-warning:var(--color-amber-500);--color-on-warning:var(--color-white);--color-danger:var(--color-red-600);--color-on-danger:var(--color-white);--radius-radius:.375rem}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab, currentcolor 50%, transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.pointer-events-auto{pointer-events:auto}.pointer-events-none{pointer-events:none}.collapse{visibility:collapse}.invisible{visibility:hidden}.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.inset-0{inset:0}.inset-x-0{inset-inline:0}.inset-x-8{inset-inline:calc(var(--spacing) * 8)}.inset-y-0{inset-block:0}.-top-1{top:calc(var(--spacing) * -1)}.top-0{top:0}.top-1\/2{top:50%}.top-full{top:100%}.-right-1{right:calc(var(--spacing) * -1)}.right-0{right:0}.right-3{right:calc(var(--spacing) * 3)}.left-0{left:0}.left-1\/2{left:50%}.left-3{left:calc(var(--spacing) * 3)}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-99{z-index:99}.container{width:100%}@media (min-width:40rem){.container{max-width:40rem}}@media (min-width:48rem){.container{max-width:48rem}}@media (min-width:64rem){.container{max-width:64rem}}@media (min-width:80rem){.container{max-width:80rem}}@media (min-width:96rem){.container{max-width:96rem}}.mx-4{margin-inline:calc(var(--spacing) * 4)}.mx-auto{margin-inline:auto}.mt-0\.5{margin-top:calc(var(--spacing) * .5)}.mt-1{margin-top:var(--spacing)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mt-4{margin-top:calc(var(--spacing) * 4)}.mt-5{margin-top:calc(var(--spacing) * 5)}.mt-6{margin-top:calc(var(--spacing) * 6)}.mt-8{margin-top:calc(var(--spacing) * 8)}.mr-2{margin-right:calc(var(--spacing) * 2)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-3{margin-bottom:calc(var(--spacing) * 3)}.ml-0\.5{margin-left:calc(var(--spacing) * .5)}.ml-1{margin-left:var(--spacing)}.ml-2{margin-left:calc(var(--spacing) * 2)}.ml-3{margin-left:calc(var(--spacing) * 3)}.ml-auto{margin-left:auto}.block{display:block}.contents{display:contents}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.table{display:table}.aspect-square{aspect-ratio:1}.size-3{width:calc(var(--spacing) * 3);height:calc(var(--spacing) * 3)}.size-3\.5{width:calc(var(--spacing) * 3.5);height:calc(var(--spacing) * 3.5)}.size-4{width:calc(var(--spacing) * 4);height:calc(var(--spacing) * 4)}.size-5{width:calc(var(--spacing) * 5);height:calc(var(--spacing) * 5)}.size-6{width:calc(var(--spacing) * 6);height:calc(var(--spacing) * 6)}.size-7{width:calc(var(--spacing) * 7);height:calc(var(--spacing) * 7)}.size-9{width:calc(var(--spacing) * 9);height:calc(var(--spacing) * 9)}.size-10{width:calc(var(--spacing) * 10);height:calc(var(--spacing) * 10)}.size-11{width:calc(var(--spacing) * 11);height:calc(var(--spacing) * 11)}.size-12{width:calc(var(--spacing) * 12);height:calc(var(--spacing) * 12)}.size-14{width:calc(var(--spacing) * 14);height:calc(var(--spacing) * 14)}.size-16{width:calc(var(--spacing) * 16);height:calc(var(--spacing) * 16)}.size-24{width:calc(var(--spacing) * 24);height:calc(var(--spacing) * 24)}.size-48{width:calc(var(--spacing) * 48);height:calc(var(--spacing) * 48)}.size-full{width:100%;height:100%}.h-4{height:calc(var(--spacing) * 4)}.h-6{height:calc(var(--spacing) * 6)}.h-16{height:calc(var(--spacing) * 16)}.h-44{height:calc(var(--spacing) * 44)}.h-fit{height:fit-content}.h-px{height:1px}.max-h-56{max-height:calc(var(--spacing) * 56)}.max-h-72{max-height:calc(var(--spacing) * 72)}.max-h-80{max-height:calc(var(--spacing) * 80)}.min-h-screen{min-height:100vh}.w-4{width:calc(var(--spacing) * 4)}.w-7{width:calc(var(--spacing) * 7)}.w-8{width:calc(var(--spacing) * 8)}.w-11{width:calc(var(--spacing) * 11)}.w-20{width:calc(var(--spacing) * 20)}.w-24{width:calc(var(--spacing) * 24)}.w-28{width:calc(var(--spacing) * 28)}.w-56{width:calc(var(--spacing) * 56)}.w-60{width:calc(var(--spacing) * 60)}.w-64{width:calc(var(--spacing) * 64)}.w-80{width:calc(var(--spacing) * 80)}.w-fit{width:fit-content}.w-full{width:100%}.max-w-2xl{max-width:var(--container-2xl)}.max-w-3xl{max-width:var(--container-3xl)}.max-w-5xl{max-width:var(--container-5xl)}.max-w-7xl{max-width:var(--container-7xl)}.max-w-full{max-width:100%}.max-w-md{max-width:var(--container-md)}.max-w-none{max-width:none}.max-w-sm{max-width:var(--container-sm)}.max-w-xl{max-width:var(--container-xl)}.min-w-0{min-width:0}.min-w-4{min-width:calc(var(--spacing) * 4)}.min-w-40{min-width:calc(var(--spacing) * 40)}.min-w-48{min-width:calc(var(--spacing) * 48)}.flex-1{flex:1}.shrink-0{flex-shrink:0}.grow{flex-grow:1}.-translate-x-1\/2{--tw-translate-x:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.-translate-x-24{--tw-translate-x:calc(var(--spacing) * -24);translate:var(--tw-translate-x) var(--tw-translate-y)}.-translate-x-60{--tw-translate-x:calc(var(--spacing) * -60);translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-x-0{--tw-translate-x:0;translate:var(--tw-translate-x) var(--tw-translate-y)}.-translate-y-1\/2{--tw-translate-y:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-y-0{--tw-translate-y:0;translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-y-8{--tw-translate-y:calc(var(--spacing) * 8);translate:var(--tw-translate-x) var(--tw-translate-y)}.rotate-0{rotate:0deg}.rotate-180{rotate:180deg}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.cursor-pointer{cursor:pointer}.appearance-none{appearance:none}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-\[auto_1fr\]{grid-template-columns:auto 1fr}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-baseline{align-items:baseline}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.items-stretch{align-items:stretch}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-0\.5{gap:calc(var(--spacing) * .5)}.gap-1{gap:var(--spacing)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-2\.5{gap:calc(var(--spacing) * 2.5)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-4{gap:calc(var(--spacing) * 4)}.gap-5{gap:calc(var(--spacing) * 5)}.gap-6{gap:calc(var(--spacing) * 6)}.gap-8{gap:calc(var(--spacing) * 8)}.gap-10{gap:calc(var(--spacing) * 10)}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(var(--spacing) * var(--tw-space-y-reverse));margin-block-end:calc(var(--spacing) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 1.5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 1.5) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 2) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 3) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 4) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 5) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-6>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 6) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 6) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-8>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 8) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 8) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-12>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 12) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 12) * calc(1 - var(--tw-space-y-reverse)))}.gap-x-4{column-gap:calc(var(--spacing) * 4)}.gap-y-1{row-gap:var(--spacing)}:where(.divide-y>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(1px * var(--tw-divide-y-reverse));border-bottom-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)))}:where(.divide-outline>:not(:last-child)){border-color:var(--color-outline)}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-clip{overflow:clip}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-full{border-radius:3.40282e38px}.rounded-radius{border-radius:var(--radius-radius)}.rounded-sm{border-radius:var(--radius-sm)}.rounded-l-radius{border-top-left-radius:var(--radius-radius);border-bottom-left-radius:var(--radius-radius)}.rounded-r-radius{border-top-right-radius:var(--radius-radius);border-bottom-right-radius:var(--radius-radius)}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-danger{border-color:var(--color-danger)}.border-danger\/40{border-color:#e4001466}@supports (color:color-mix(in lab, red, red)){.border-danger\/40{border-color:color-mix(in oklab, var(--color-danger) 40%, transparent)}}.border-info{border-color:var(--color-info)}.border-outline{border-color:var(--color-outline)}.border-primary{border-color:var(--color-primary)}.border-primary\/40{border-color:#4f39f666}@supports (color:color-mix(in lab, red, red)){.border-primary\/40{border-color:color-mix(in oklab, var(--color-primary) 40%, transparent)}}.border-secondary{border-color:var(--color-secondary)}.border-secondary\/60{border-color:#45556c99}@supports (color:color-mix(in lab, red, red)){.border-secondary\/60{border-color:color-mix(in oklab, var(--color-secondary) 60%, transparent)}}.border-success{border-color:var(--color-success)}.border-warning{border-color:var(--color-warning)}.border-warning\/60{border-color:#f99c0099}@supports (color:color-mix(in lab, red, red)){.border-warning\/60{border-color:color-mix(in oklab, var(--color-warning) 60%, transparent)}}.bg-black\/50{background-color:#00000080}@supports (color:color-mix(in lab, red, red)){.bg-black\/50{background-color:color-mix(in oklab, var(--color-black) 50%, transparent)}}.bg-danger{background-color:var(--color-danger)}.bg-danger\/5{background-color:#e400140d}@supports (color:color-mix(in lab, red, red)){.bg-danger\/5{background-color:color-mix(in oklab, var(--color-danger) 5%, transparent)}}.bg-danger\/10{background-color:#e400141a}@supports (color:color-mix(in lab, red, red)){.bg-danger\/10{background-color:color-mix(in oklab, var(--color-danger) 10%, transparent)}}.bg-danger\/15{background-color:#e4001426}@supports (color:color-mix(in lab, red, red)){.bg-danger\/15{background-color:color-mix(in oklab, var(--color-danger) 15%, transparent)}}.bg-info{background-color:var(--color-info)}.bg-info\/10{background-color:#00a5ef1a}@supports (color:color-mix(in lab, red, red)){.bg-info\/10{background-color:color-mix(in oklab, var(--color-info) 10%, transparent)}}.bg-info\/15{background-color:#00a5ef26}@supports (color:color-mix(in lab, red, red)){.bg-info\/15{background-color:color-mix(in oklab, var(--color-info) 15%, transparent)}}.bg-outline{background-color:var(--color-outline)}.bg-primary{background-color:var(--color-primary)}.bg-primary\/5{background-color:#4f39f60d}@supports (color:color-mix(in lab, red, red)){.bg-primary\/5{background-color:color-mix(in oklab, var(--color-primary) 5%, transparent)}}.bg-primary\/10{background-color:#4f39f61a}@supports (color:color-mix(in lab, red, red)){.bg-primary\/10{background-color:color-mix(in oklab, var(--color-primary) 10%, transparent)}}.bg-secondary{background-color:var(--color-secondary)}.bg-success{background-color:var(--color-success)}.bg-success\/10{background-color:#00a5441a}@supports (color:color-mix(in lab, red, red)){.bg-success\/10{background-color:color-mix(in oklab, var(--color-success) 10%, transparent)}}.bg-success\/15{background-color:#00a54426}@supports (color:color-mix(in lab, red, red)){.bg-success\/15{background-color:color-mix(in oklab, var(--color-success) 15%, transparent)}}.bg-surface{background-color:var(--color-surface)}.bg-surface-alt{background-color:var(--color-surface-alt)}.bg-surface-alt\/40{background-color:#f1f5f966}@supports (color:color-mix(in lab, red, red)){.bg-surface-alt\/40{background-color:color-mix(in oklab, var(--color-surface-alt) 40%, transparent)}}.bg-surface-alt\/50{background-color:#f1f5f980}@supports (color:color-mix(in lab, red, red)){.bg-surface-alt\/50{background-color:color-mix(in oklab, var(--color-surface-alt) 50%, transparent)}}.bg-surface\/40{background-color:#fff6}@supports (color:color-mix(in lab, red, red)){.bg-surface\/40{background-color:color-mix(in oklab, var(--color-surface) 40%, transparent)}}.bg-surface\/95{background-color:#fffffff2}@supports (color:color-mix(in lab, red, red)){.bg-surface\/95{background-color:color-mix(in oklab, var(--color-surface) 95%, transparent)}}.bg-transparent{background-color:#0000}.bg-warning{background-color:var(--color-warning)}.bg-warning\/10{background-color:#f99c001a}@supports (color:color-mix(in lab, red, red)){.bg-warning\/10{background-color:color-mix(in oklab, var(--color-warning) 10%, transparent)}}.bg-warning\/15{background-color:#f99c0026}@supports (color:color-mix(in lab, red, red)){.bg-warning\/15{background-color:color-mix(in oklab, var(--color-warning) 15%, transparent)}}.bg-white{background-color:var(--color-white)}.object-cover{object-fit:cover}.p-0\.5{padding:calc(var(--spacing) * .5)}.p-1{padding:var(--spacing)}.p-2{padding:calc(var(--spacing) * 2)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.p-5{padding:calc(var(--spacing) * 5)}.p-6{padding:calc(var(--spacing) * 6)}.px-1{padding-inline:var(--spacing)}.px-1\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-2\.5{padding-inline:calc(var(--spacing) * 2.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.px-5{padding-inline:calc(var(--spacing) * 5)}.px-6{padding-inline:calc(var(--spacing) * 6)}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:var(--spacing)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-2\.5{padding-block:calc(var(--spacing) * 2.5)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-6{padding-block:calc(var(--spacing) * 6)}.py-8{padding-block:calc(var(--spacing) * 8)}.py-10{padding-block:calc(var(--spacing) * 10)}.py-12{padding-block:calc(var(--spacing) * 12)}.py-16{padding-block:calc(var(--spacing) * 16)}.pt-0{padding-top:0}.pt-1{padding-top:var(--spacing)}.pt-2{padding-top:calc(var(--spacing) * 2)}.pt-3{padding-top:calc(var(--spacing) * 3)}.pt-20{padding-top:calc(var(--spacing) * 20)}.pr-7{padding-right:calc(var(--spacing) * 7)}.pr-8{padding-right:calc(var(--spacing) * 8)}.pb-2{padding-bottom:calc(var(--spacing) * 2)}.pb-3{padding-bottom:calc(var(--spacing) * 3)}.pl-1{padding-left:var(--spacing)}.pl-3{padding-left:calc(var(--spacing) * 3)}.pl-6{padding-left:calc(var(--spacing) * 6)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.font-mono{font-family:var(--font-mono)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-3xl{font-size:var(--text-3xl);line-height:var(--tw-leading,var(--text-3xl--line-height))}.text-4xl{font-size:var(--text-4xl);line-height:var(--tw-leading,var(--text-4xl--line-height))}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[10px\]{font-size:10px}.leading-4{--tw-leading:calc(var(--spacing) * 4);line-height:calc(var(--spacing) * 4)}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-tight{--tw-tracking:var(--tracking-tight);letter-spacing:var(--tracking-tight)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.text-pretty{text-wrap:pretty}.break-all{word-break:break-all}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-line{white-space:pre-line}.text-danger{color:var(--color-danger)}.text-info{color:var(--color-info)}.text-on-danger{color:var(--color-on-danger)}.text-on-info{color:var(--color-on-info)}.text-on-primary{color:var(--color-on-primary)}.text-on-primary\/90{color:#ffffffe6}@supports (color:color-mix(in lab, red, red)){.text-on-primary\/90{color:color-mix(in oklab, var(--color-on-primary) 90%, transparent)}}.text-on-secondary{color:var(--color-on-secondary)}.text-on-success{color:var(--color-on-success)}.text-on-surface{color:var(--color-on-surface)}.text-on-surface-strong{color:var(--color-on-surface-strong)}.text-on-surface\/40{color:#31415866}@supports (color:color-mix(in lab, red, red)){.text-on-surface\/40{color:color-mix(in oklab, var(--color-on-surface) 40%, transparent)}}.text-on-surface\/50{color:#31415880}@supports (color:color-mix(in lab, red, red)){.text-on-surface\/50{color:color-mix(in oklab, var(--color-on-surface) 50%, transparent)}}.text-on-surface\/60{color:#31415899}@supports (color:color-mix(in lab, red, red)){.text-on-surface\/60{color:color-mix(in oklab, var(--color-on-surface) 60%, transparent)}}.text-on-surface\/70{color:#314158b3}@supports (color:color-mix(in lab, red, red)){.text-on-surface\/70{color:color-mix(in oklab, var(--color-on-surface) 70%, transparent)}}.text-on-surface\/80{color:#314158cc}@supports (color:color-mix(in lab, red, red)){.text-on-surface\/80{color:color-mix(in oklab, var(--color-on-surface) 80%, transparent)}}.text-on-warning{color:var(--color-on-warning)}.text-outline{color:var(--color-outline)}.text-primary{color:var(--color-primary)}.text-secondary{color:var(--color-secondary)}.text-success{color:var(--color-success)}.text-warning{color:var(--color-warning)}.uppercase{text-transform:uppercase}.italic{font-style:italic}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,)}.line-through{text-decoration-line:line-through}.underline{text-decoration-line:underline}.underline-offset-2{text-underline-offset:2px}.antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.opacity-0{opacity:0}.opacity-100{opacity:1}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.outline-danger{outline-color:var(--color-danger)}.outline-primary{outline-color:var(--color-primary)}.outline-secondary{outline-color:var(--color-secondary)}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.backdrop-blur{--tw-backdrop-blur:blur(8px);-webkit-backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-\[margin\]{transition-property:margin;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-300{--tw-duration:.3s;transition-duration:.3s}.duration-700{--tw-duration:.7s;transition-duration:.7s}.ease-in{--tw-ease:var(--ease-in);transition-timing-function:var(--ease-in)}.ease-out{--tw-ease:var(--ease-out);transition-timing-function:var(--ease-out)}@media (hover:hover){.group-hover\:scale-105:is(:where(.group):hover *){--tw-scale-x:105%;--tw-scale-y:105%;--tw-scale-z:105%;scale:var(--tw-scale-x) var(--tw-scale-y)}}.peer-checked\:visible:is(:where(.peer):checked~*){visibility:visible}.peer-checked\:bg-primary:is(:where(.peer):checked~*){background-color:var(--color-primary)}.peer-focus\:outline-2:is(:where(.peer):focus~*){outline-style:var(--tw-outline-style);outline-width:2px}.peer-focus\:outline-offset-2:is(:where(.peer):focus~*){outline-offset:2px}.peer-focus\:outline-outline-strong:is(:where(.peer):focus~*){outline-color:var(--color-outline-strong)}.peer-focus\:peer-checked\:outline-primary:is(:where(.peer):focus~*):is(:where(.peer):checked~*){outline-color:var(--color-primary)}.peer-active\:outline-offset-0:is(:where(.peer):active~*){outline-offset:0px}.file\:mr-4::file-selector-button{margin-right:calc(var(--spacing) * 4)}.file\:border-none::file-selector-button{--tw-border-style:none;border-style:none}.file\:bg-surface-alt::file-selector-button{background-color:var(--color-surface-alt)}.file\:px-4::file-selector-button{padding-inline:calc(var(--spacing) * 4)}.file\:py-2::file-selector-button{padding-block:calc(var(--spacing) * 2)}.file\:font-medium::file-selector-button{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.file\:text-on-surface-strong::file-selector-button{color:var(--color-on-surface-strong)}.before\:invisible:before{content:var(--tw-content);visibility:hidden}.before\:absolute:before{content:var(--tw-content);position:absolute}.before\:inset-0:before{content:var(--tw-content);inset:0}.before\:top-1\/2:before{content:var(--tw-content);top:50%}.before\:left-1\/2:before{content:var(--tw-content);left:50%}.before\:h-1\.5:before{content:var(--tw-content);height:calc(var(--spacing) * 1.5)}.before\:w-1\.5:before{content:var(--tw-content);width:calc(var(--spacing) * 1.5)}.before\:-translate-x-1\/2:before{content:var(--tw-content);--tw-translate-x:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.before\:-translate-y-1\/2:before{content:var(--tw-content);--tw-translate-y:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.before\:rounded-full:before{content:var(--tw-content);border-radius:3.40282e38px}.before\:bg-on-primary:before{content:var(--tw-content);background-color:var(--color-on-primary)}.after\:absolute:after{content:var(--tw-content);position:absolute}.after\:top-0:after{content:var(--tw-content);top:0}.after\:bottom-0:after{content:var(--tw-content);bottom:0}.after\:left-\[0\.0625rem\]:after{content:var(--tw-content);left:.0625rem}.after\:my-auto:after{content:var(--tw-content);margin-block:auto}.after\:h-5:after{content:var(--tw-content);height:calc(var(--spacing) * 5)}.after\:w-5:after{content:var(--tw-content);width:calc(var(--spacing) * 5)}.after\:rounded-full:after{content:var(--tw-content);border-radius:3.40282e38px}.after\:bg-on-surface:after{content:var(--tw-content);background-color:var(--color-on-surface)}.after\:transition-all:after{content:var(--tw-content);transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.after\:content-\[\'\'\]:after{--tw-content:"";content:var(--tw-content)}.peer-checked\:after\:translate-x-5:is(:where(.peer):checked~*):after{content:var(--tw-content);--tw-translate-x:calc(var(--spacing) * 5);translate:var(--tw-translate-x) var(--tw-translate-y)}.peer-checked\:after\:bg-on-primary:is(:where(.peer):checked~*):after{content:var(--tw-content);background-color:var(--color-on-primary)}.checked\:border-primary:checked{border-color:var(--color-primary)}.checked\:bg-primary:checked{background-color:var(--color-primary)}.checked\:before\:visible:checked:before{content:var(--tw-content);visibility:visible}.checked\:before\:bg-primary:checked:before{content:var(--tw-content);background-color:var(--color-primary)}@media (hover:hover){.hover\:border-primary:hover{border-color:var(--color-primary)}.hover\:bg-danger\/5:hover{background-color:#e400140d}@supports (color:color-mix(in lab, red, red)){.hover\:bg-danger\/5:hover{background-color:color-mix(in oklab, var(--color-danger) 5%, transparent)}}.hover\:bg-info\/5:hover{background-color:#00a5ef0d}@supports (color:color-mix(in lab, red, red)){.hover\:bg-info\/5:hover{background-color:color-mix(in oklab, var(--color-info) 5%, transparent)}}.hover\:bg-primary\/5:hover{background-color:#4f39f60d}@supports (color:color-mix(in lab, red, red)){.hover\:bg-primary\/5:hover{background-color:color-mix(in oklab, var(--color-primary) 5%, transparent)}}.hover\:bg-surface-alt:hover{background-color:var(--color-surface-alt)}.hover\:bg-surface-dark-alt\/5:hover{background-color:#1d293d0d}@supports (color:color-mix(in lab, red, red)){.hover\:bg-surface-dark-alt\/5:hover{background-color:color-mix(in oklab, var(--color-surface-dark-alt) 5%, transparent)}}.hover\:bg-surface\/60:hover{background-color:#fff9}@supports (color:color-mix(in lab, red, red)){.hover\:bg-surface\/60:hover{background-color:color-mix(in oklab, var(--color-surface) 60%, transparent)}}.hover\:text-on-surface-strong:hover{color:var(--color-on-surface-strong)}.hover\:text-primary:hover{color:var(--color-primary)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-75:hover{opacity:.75}.hover\:opacity-90:hover{opacity:.9}}.focus\:outline-hidden:focus{--tw-outline-style:none;outline-style:none}@media (forced-colors:active){.focus\:outline-hidden:focus{outline-offset:2px;outline:2px solid #0000}}.focus\:outline-2:focus{outline-style:var(--tw-outline-style);outline-width:2px}.focus\:outline-offset-2:focus{outline-offset:2px}.focus\:outline-outline-strong:focus{outline-color:var(--color-outline-strong)}.focus\:outline-primary:focus,.checked\:focus\:outline-primary:checked:focus{outline-color:var(--color-primary)}.focus-visible\:bg-primary\/10:focus-visible{background-color:#4f39f61a}@supports (color:color-mix(in lab, red, red)){.focus-visible\:bg-primary\/10:focus-visible{background-color:color-mix(in oklab, var(--color-primary) 10%, transparent)}}.focus-visible\:bg-surface-dark-alt\/10:focus-visible{background-color:#1d293d1a}@supports (color:color-mix(in lab, red, red)){.focus-visible\:bg-surface-dark-alt\/10:focus-visible{background-color:color-mix(in oklab, var(--color-surface-dark-alt) 10%, transparent)}}.focus-visible\:text-on-surface-strong:focus-visible{color:var(--color-on-surface-strong)}.focus-visible\:underline:focus-visible{text-decoration-line:underline}.focus-visible\:outline-hidden:focus-visible{--tw-outline-style:none;outline-style:none}@media (forced-colors:active){.focus-visible\:outline-hidden:focus-visible{outline-offset:2px;outline:2px solid #0000}}.focus-visible\:outline-2:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px}.focus-visible\:outline-offset-2:focus-visible{outline-offset:2px}.focus-visible\:outline-danger:focus-visible{outline-color:var(--color-danger)}.focus-visible\:outline-info:focus-visible{outline-color:var(--color-info)}.focus-visible\:outline-outline:focus-visible{outline-color:var(--color-outline)}.focus-visible\:outline-primary:focus-visible{outline-color:var(--color-primary)}.focus-visible\:outline-secondary:focus-visible{outline-color:var(--color-secondary)}.focus-visible\:outline-success:focus-visible{outline-color:var(--color-success)}.focus-visible\:outline-warning:focus-visible{outline-color:var(--color-warning)}.active\:opacity-100:active{opacity:1}.active\:outline-offset-0:active{outline-offset:0px}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-75:disabled{opacity:.75}.has-checked\:text-on-surface-strong:has(:checked){color:var(--color-on-surface-strong)}.has-disabled\:cursor-not-allowed:has(:disabled){cursor:not-allowed}.has-disabled\:opacity-75:has(:disabled){opacity:.75}.has-\[\:checked\]\:border-primary:has(:checked){border-color:var(--color-primary)}.aria-\[current\=page\]\:bg-primary\/10[aria-current=page]{background-color:#4f39f61a}@supports (color:color-mix(in lab, red, red)){.aria-\[current\=page\]\:bg-primary\/10[aria-current=page]{background-color:color-mix(in oklab, var(--color-primary) 10%, transparent)}}.aria-\[current\=page\]\:font-semibold[aria-current=page]{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.aria-\[current\=page\]\:text-on-surface-strong[aria-current=page]{color:var(--color-on-surface-strong)}.aria-\[current\=page\]\:text-primary[aria-current=page]{color:var(--color-primary)}@media (min-width:40rem){.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}}@media (min-width:48rem){.md\:top-\[unset\]{top:unset}.md\:right-0{right:0}.md\:bottom-0{bottom:0}.md\:left-\[unset\]{left:unset}.md\:ml-0{margin-left:0}.md\:ml-60{margin-left:calc(var(--spacing) * 60)}.md\:flex{display:flex}.md\:hidden{display:none}.md\:inline-flex{display:inline-flex}.md\:h-64{height:calc(var(--spacing) * 64)}.md\:w-56{width:calc(var(--spacing) * 56)}.md\:max-w-sm{max-width:var(--container-sm)}.md\:-translate-x-60{--tw-translate-x:calc(var(--spacing) * -60);translate:var(--tw-translate-x) var(--tw-translate-y)}.md\:translate-x-0{--tw-translate-x:0;translate:var(--tw-translate-x) var(--tw-translate-y)}.md\:translate-x-24{--tw-translate-x:calc(var(--spacing) * 24);translate:var(--tw-translate-x) var(--tw-translate-y)}.md\:flex-row{flex-direction:row}.md\:items-start{align-items:flex-start}}@media (min-width:64rem){.lg\:static{position:static}.lg\:z-auto{z-index:auto}.lg\:col-span-2{grid-column:span 2/span 2}.lg\:hidden{display:none}.lg\:w-64{width:calc(var(--spacing) * 64)}.lg\:shrink-0{flex-shrink:0}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:self-start{align-self:flex-start}.lg\:overflow-visible{overflow:visible}.lg\:rounded-radius{border-radius:var(--radius-radius)}.lg\:border{border-style:var(--tw-border-style);border-width:1px}.lg\:p-3{padding:calc(var(--spacing) * 3)}}@media (min-width:80rem){.xl\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}:where(.dark\:divide-outline-dark:where([data-theme=dark],[data-theme=dark] *)>:not(:last-child)){border-color:var(--color-outline-dark)}.dark\:border-danger:where([data-theme=dark],[data-theme=dark] *){border-color:var(--color-danger)}.dark\:border-info:where([data-theme=dark],[data-theme=dark] *){border-color:var(--color-info)}.dark\:border-outline-dark:where([data-theme=dark],[data-theme=dark] *){border-color:var(--color-outline-dark)}.dark\:border-primary-dark:where([data-theme=dark],[data-theme=dark] *){border-color:var(--color-primary-dark)}.dark\:border-primary-dark\/40:where([data-theme=dark],[data-theme=dark] *){border-color:#7d87ff66}@supports (color:color-mix(in lab, red, red)){.dark\:border-primary-dark\/40:where([data-theme=dark],[data-theme=dark] *){border-color:color-mix(in oklab, var(--color-primary-dark) 40%, transparent)}}.dark\:border-secondary-dark:where([data-theme=dark],[data-theme=dark] *){border-color:var(--color-secondary-dark)}.dark\:border-secondary-dark\/60:where([data-theme=dark],[data-theme=dark] *){border-color:#cad5e299}@supports (color:color-mix(in lab, red, red)){.dark\:border-secondary-dark\/60:where([data-theme=dark],[data-theme=dark] *){border-color:color-mix(in oklab, var(--color-secondary-dark) 60%, transparent)}}.dark\:border-success:where([data-theme=dark],[data-theme=dark] *){border-color:var(--color-success)}.dark\:border-warning:where([data-theme=dark],[data-theme=dark] *){border-color:var(--color-warning)}.dark\:bg-danger:where([data-theme=dark],[data-theme=dark] *){background-color:var(--color-danger)}.dark\:bg-info:where([data-theme=dark],[data-theme=dark] *){background-color:var(--color-info)}.dark\:bg-outline-dark:where([data-theme=dark],[data-theme=dark] *){background-color:var(--color-outline-dark)}.dark\:bg-primary-dark:where([data-theme=dark],[data-theme=dark] *){background-color:var(--color-primary-dark)}.dark\:bg-primary-dark\/10:where([data-theme=dark],[data-theme=dark] *){background-color:#7d87ff1a}@supports (color:color-mix(in lab, red, red)){.dark\:bg-primary-dark\/10:where([data-theme=dark],[data-theme=dark] *){background-color:color-mix(in oklab, var(--color-primary-dark) 10%, transparent)}}.dark\:bg-secondary-dark:where([data-theme=dark],[data-theme=dark] *){background-color:var(--color-secondary-dark)}.dark\:bg-success:where([data-theme=dark],[data-theme=dark] *){background-color:var(--color-success)}.dark\:bg-surface-dark:where([data-theme=dark],[data-theme=dark] *){background-color:var(--color-surface-dark)}.dark\:bg-surface-dark-alt:where([data-theme=dark],[data-theme=dark] *){background-color:var(--color-surface-dark-alt)}.dark\:bg-surface-dark-alt\/40:where([data-theme=dark],[data-theme=dark] *){background-color:#1d293d66}@supports (color:color-mix(in lab, red, red)){.dark\:bg-surface-dark-alt\/40:where([data-theme=dark],[data-theme=dark] *){background-color:color-mix(in oklab, var(--color-surface-dark-alt) 40%, transparent)}}.dark\:bg-surface-dark-alt\/50:where([data-theme=dark],[data-theme=dark] *){background-color:#1d293d80}@supports (color:color-mix(in lab, red, red)){.dark\:bg-surface-dark-alt\/50:where([data-theme=dark],[data-theme=dark] *){background-color:color-mix(in oklab, var(--color-surface-dark-alt) 50%, transparent)}}.dark\:bg-surface-dark\/40:where([data-theme=dark],[data-theme=dark] *){background-color:#0f172b66}@supports (color:color-mix(in lab, red, red)){.dark\:bg-surface-dark\/40:where([data-theme=dark],[data-theme=dark] *){background-color:color-mix(in oklab, var(--color-surface-dark) 40%, transparent)}}.dark\:bg-surface-dark\/95:where([data-theme=dark],[data-theme=dark] *){background-color:#0f172bf2}@supports (color:color-mix(in lab, red, red)){.dark\:bg-surface-dark\/95:where([data-theme=dark],[data-theme=dark] *){background-color:color-mix(in oklab, var(--color-surface-dark) 95%, transparent)}}.dark\:bg-warning:where([data-theme=dark],[data-theme=dark] *){background-color:var(--color-warning)}.dark\:text-danger:where([data-theme=dark],[data-theme=dark] *){color:var(--color-danger)}.dark\:text-on-danger:where([data-theme=dark],[data-theme=dark] *){color:var(--color-on-danger)}.dark\:text-on-info:where([data-theme=dark],[data-theme=dark] *){color:var(--color-on-info)}.dark\:text-on-primary-dark:where([data-theme=dark],[data-theme=dark] *){color:var(--color-on-primary-dark)}.dark\:text-on-primary-dark\/90:where([data-theme=dark],[data-theme=dark] *){color:#020618e6}@supports (color:color-mix(in lab, red, red)){.dark\:text-on-primary-dark\/90:where([data-theme=dark],[data-theme=dark] *){color:color-mix(in oklab, var(--color-on-primary-dark) 90%, transparent)}}.dark\:text-on-secondary-dark:where([data-theme=dark],[data-theme=dark] *){color:var(--color-on-secondary-dark)}.dark\:text-on-success:where([data-theme=dark],[data-theme=dark] *){color:var(--color-on-success)}.dark\:text-on-surface-dark:where([data-theme=dark],[data-theme=dark] *){color:var(--color-on-surface-dark)}.dark\:text-on-surface-dark-strong:where([data-theme=dark],[data-theme=dark] *){color:var(--color-on-surface-dark-strong)}.dark\:text-on-surface-dark\/40:where([data-theme=dark],[data-theme=dark] *){color:#cad5e266}@supports (color:color-mix(in lab, red, red)){.dark\:text-on-surface-dark\/40:where([data-theme=dark],[data-theme=dark] *){color:color-mix(in oklab, var(--color-on-surface-dark) 40%, transparent)}}.dark\:text-on-surface-dark\/50:where([data-theme=dark],[data-theme=dark] *){color:#cad5e280}@supports (color:color-mix(in lab, red, red)){.dark\:text-on-surface-dark\/50:where([data-theme=dark],[data-theme=dark] *){color:color-mix(in oklab, var(--color-on-surface-dark) 50%, transparent)}}.dark\:text-on-surface-dark\/60:where([data-theme=dark],[data-theme=dark] *){color:#cad5e299}@supports (color:color-mix(in lab, red, red)){.dark\:text-on-surface-dark\/60:where([data-theme=dark],[data-theme=dark] *){color:color-mix(in oklab, var(--color-on-surface-dark) 60%, transparent)}}.dark\:text-on-surface-dark\/70:where([data-theme=dark],[data-theme=dark] *){color:#cad5e2b3}@supports (color:color-mix(in lab, red, red)){.dark\:text-on-surface-dark\/70:where([data-theme=dark],[data-theme=dark] *){color:color-mix(in oklab, var(--color-on-surface-dark) 70%, transparent)}}.dark\:text-on-surface-dark\/80:where([data-theme=dark],[data-theme=dark] *){color:#cad5e2cc}@supports (color:color-mix(in lab, red, red)){.dark\:text-on-surface-dark\/80:where([data-theme=dark],[data-theme=dark] *){color:color-mix(in oklab, var(--color-on-surface-dark) 80%, transparent)}}.dark\:text-on-warning:where([data-theme=dark],[data-theme=dark] *){color:var(--color-on-warning)}.dark\:text-outline-dark:where([data-theme=dark],[data-theme=dark] *){color:var(--color-outline-dark)}.dark\:text-primary-dark:where([data-theme=dark],[data-theme=dark] *){color:var(--color-primary-dark)}.dark\:text-secondary-dark:where([data-theme=dark],[data-theme=dark] *){color:var(--color-secondary-dark)}.dark\:text-warning:where([data-theme=dark],[data-theme=dark] *){color:var(--color-warning)}.dark\:peer-checked\:bg-primary-dark:where([data-theme=dark],[data-theme=dark] *):is(:where(.peer):checked~*){background-color:var(--color-primary-dark)}.dark\:peer-focus\:outline-outline-dark-strong:where([data-theme=dark],[data-theme=dark] *):is(:where(.peer):focus~*){outline-color:var(--color-outline-dark-strong)}.dark\:peer-focus\:peer-checked\:outline-primary-dark:where([data-theme=dark],[data-theme=dark] *):is(:where(.peer):focus~*):is(:where(.peer):checked~*){outline-color:var(--color-primary-dark)}.dark\:file\:bg-surface-dark-alt:where([data-theme=dark],[data-theme=dark] *)::file-selector-button{background-color:var(--color-surface-dark-alt)}.dark\:file\:text-on-surface-dark-strong:where([data-theme=dark],[data-theme=dark] *)::file-selector-button{color:var(--color-on-surface-dark-strong)}.dark\:before\:bg-on-primary-dark:where([data-theme=dark],[data-theme=dark] *):before{content:var(--tw-content);background-color:var(--color-on-primary-dark)}.dark\:after\:bg-on-surface-dark:where([data-theme=dark],[data-theme=dark] *):after{content:var(--tw-content);background-color:var(--color-on-surface-dark)}.dark\:peer-checked\:after\:bg-on-primary-dark:where([data-theme=dark],[data-theme=dark] *):is(:where(.peer):checked~*):after{content:var(--tw-content);background-color:var(--color-on-primary-dark)}.dark\:checked\:border-primary-dark:where([data-theme=dark],[data-theme=dark] *):checked{border-color:var(--color-primary-dark)}.dark\:checked\:bg-primary-dark:where([data-theme=dark],[data-theme=dark] *):checked{background-color:var(--color-primary-dark)}.dark\:checked\:before\:bg-primary-dark:where([data-theme=dark],[data-theme=dark] *):checked:before{content:var(--tw-content);background-color:var(--color-primary-dark)}@media (hover:hover){.dark\:hover\:border-primary-dark:where([data-theme=dark],[data-theme=dark] *):hover{border-color:var(--color-primary-dark)}.dark\:hover\:bg-primary-dark\/5:where([data-theme=dark],[data-theme=dark] *):hover{background-color:#7d87ff0d}@supports (color:color-mix(in lab, red, red)){.dark\:hover\:bg-primary-dark\/5:where([data-theme=dark],[data-theme=dark] *):hover{background-color:color-mix(in oklab, var(--color-primary-dark) 5%, transparent)}}.dark\:hover\:bg-surface-alt\/5:where([data-theme=dark],[data-theme=dark] *):hover{background-color:#f1f5f90d}@supports (color:color-mix(in lab, red, red)){.dark\:hover\:bg-surface-alt\/5:where([data-theme=dark],[data-theme=dark] *):hover{background-color:color-mix(in oklab, var(--color-surface-alt) 5%, transparent)}}.dark\:hover\:bg-surface-dark:where([data-theme=dark],[data-theme=dark] *):hover{background-color:var(--color-surface-dark)}.dark\:hover\:bg-surface-dark-alt:where([data-theme=dark],[data-theme=dark] *):hover{background-color:var(--color-surface-dark-alt)}.dark\:hover\:bg-surface-dark\/60:where([data-theme=dark],[data-theme=dark] *):hover{background-color:#0f172b99}@supports (color:color-mix(in lab, red, red)){.dark\:hover\:bg-surface-dark\/60:where([data-theme=dark],[data-theme=dark] *):hover{background-color:color-mix(in oklab, var(--color-surface-dark) 60%, transparent)}}.dark\:hover\:text-on-surface-dark-strong:where([data-theme=dark],[data-theme=dark] *):hover{color:var(--color-on-surface-dark-strong)}.dark\:hover\:text-primary-dark:where([data-theme=dark],[data-theme=dark] *):hover{color:var(--color-primary-dark)}}.dark\:focus\:outline-outline-dark-strong:where([data-theme=dark],[data-theme=dark] *):focus{outline-color:var(--color-outline-dark-strong)}.dark\:checked\:focus\:outline-primary-dark:where([data-theme=dark],[data-theme=dark] *):checked:focus{outline-color:var(--color-primary-dark)}.dark\:focus-visible\:bg-surface-alt\/10:where([data-theme=dark],[data-theme=dark] *):focus-visible{background-color:#f1f5f91a}@supports (color:color-mix(in lab, red, red)){.dark\:focus-visible\:bg-surface-alt\/10:where([data-theme=dark],[data-theme=dark] *):focus-visible{background-color:color-mix(in oklab, var(--color-surface-alt) 10%, transparent)}}.dark\:focus-visible\:text-on-surface-dark-strong:where([data-theme=dark],[data-theme=dark] *):focus-visible{color:var(--color-on-surface-dark-strong)}.dark\:focus-visible\:outline-danger:where([data-theme=dark],[data-theme=dark] *):focus-visible{outline-color:var(--color-danger)}.dark\:focus-visible\:outline-info:where([data-theme=dark],[data-theme=dark] *):focus-visible{outline-color:var(--color-info)}.dark\:focus-visible\:outline-outline-dark:where([data-theme=dark],[data-theme=dark] *):focus-visible{outline-color:var(--color-outline-dark)}.dark\:focus-visible\:outline-primary-dark:where([data-theme=dark],[data-theme=dark] *):focus-visible{outline-color:var(--color-primary-dark)}.dark\:focus-visible\:outline-secondary-dark:where([data-theme=dark],[data-theme=dark] *):focus-visible{outline-color:var(--color-secondary-dark)}.dark\:focus-visible\:outline-success:where([data-theme=dark],[data-theme=dark] *):focus-visible{outline-color:var(--color-success)}.dark\:focus-visible\:outline-warning:where([data-theme=dark],[data-theme=dark] *):focus-visible{outline-color:var(--color-warning)}.dark\:has-checked\:text-on-surface-dark-strong:where([data-theme=dark],[data-theme=dark] *):has(:checked){color:var(--color-on-surface-dark-strong)}.dark\:has-\[\:checked\]\:border-primary-dark:where([data-theme=dark],[data-theme=dark] *):has(:checked){border-color:var(--color-primary-dark)}.dark\:aria-\[current\=page\]\:bg-primary-dark\/10:where([data-theme=dark],[data-theme=dark] *)[aria-current=page]{background-color:#7d87ff1a}@supports (color:color-mix(in lab, red, red)){.dark\:aria-\[current\=page\]\:bg-primary-dark\/10:where([data-theme=dark],[data-theme=dark] *)[aria-current=page]{background-color:color-mix(in oklab, var(--color-primary-dark) 10%, transparent)}}.dark\:aria-\[current\=page\]\:text-on-surface-dark-strong:where([data-theme=dark],[data-theme=dark] *)[aria-current=page]{color:var(--color-on-surface-dark-strong)}.dark\:aria-\[current\=page\]\:text-primary-dark:where([data-theme=dark],[data-theme=dark] *)[aria-current=page]{color:var(--color-primary-dark)}}[x-cloak]{display:none!important}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-divide-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-content{syntax:"*";inherits:false;initial-value:""} \ No newline at end of file +@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-divide-y-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-content:""}}}@layer theme{:root,:host{--font-sans:ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-red-600:oklch(57.7% .245 27.325);--color-amber-500:oklch(76.9% .188 70.08);--color-green-600:oklch(62.7% .194 149.214);--color-emerald-600:oklch(59.6% .145 163.225);--color-sky-500:oklch(68.5% .169 237.323);--color-indigo-400:oklch(67.3% .182 276.935);--color-indigo-600:oklch(51.1% .262 276.966);--color-slate-100:oklch(96.8% .007 247.896);--color-slate-300:oklch(86.9% .022 252.894);--color-slate-600:oklch(44.6% .043 257.281);--color-slate-700:oklch(37.2% .044 257.287);--color-slate-800:oklch(27.9% .041 260.031);--color-slate-900:oklch(20.8% .042 265.755);--color-slate-950:oklch(12.9% .042 264.695);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-sm:24rem;--container-md:28rem;--container-xl:36rem;--container-2xl:42rem;--container-3xl:48rem;--container-5xl:64rem;--container-7xl:80rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height:calc(1.5 / 1);--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75 / 1.25);--text-2xl:1.5rem;--text-2xl--line-height:calc(2 / 1.5);--text-3xl:1.875rem;--text-3xl--line-height:calc(2.25 / 1.875);--text-4xl:2.25rem;--text-4xl--line-height:calc(2.5 / 2.25);--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-tight:-.025em;--tracking-wide:.025em;--tracking-wider:.05em;--leading-tight:1.25;--leading-relaxed:1.625;--radius-sm:.25rem;--ease-in:cubic-bezier(.4, 0, 1, 1);--ease-out:cubic-bezier(0, 0, .2, 1);--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--color-surface:var(--color-white);--color-surface-alt:var(--color-slate-100);--color-on-surface:var(--color-slate-700);--color-on-surface-strong:var(--color-slate-900);--color-primary:var(--color-indigo-600);--color-on-primary:var(--color-white);--color-secondary:var(--color-slate-600);--color-on-secondary:var(--color-white);--color-outline:var(--color-slate-300);--color-outline-strong:var(--color-slate-800);--color-surface-dark:var(--color-slate-900);--color-surface-dark-alt:var(--color-slate-800);--color-on-surface-dark:var(--color-slate-300);--color-on-surface-dark-strong:var(--color-white);--color-primary-dark:var(--color-indigo-400);--color-on-primary-dark:var(--color-slate-950);--color-secondary-dark:var(--color-slate-300);--color-on-secondary-dark:var(--color-slate-950);--color-outline-dark:var(--color-slate-700);--color-outline-dark-strong:var(--color-slate-300);--color-info:var(--color-sky-500);--color-on-info:var(--color-white);--color-success:var(--color-green-600);--color-on-success:var(--color-white);--color-warning:var(--color-amber-500);--color-on-warning:var(--color-white);--color-danger:var(--color-red-600);--color-on-danger:var(--color-white);--radius-radius:.375rem}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab, currentcolor 50%, transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.pointer-events-auto{pointer-events:auto}.pointer-events-none{pointer-events:none}.collapse{visibility:collapse}.invisible{visibility:hidden}.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.inset-0{inset:0}.inset-x-0{inset-inline:0}.inset-x-8{inset-inline:calc(var(--spacing) * 8)}.inset-y-0{inset-block:0}.-top-1{top:calc(var(--spacing) * -1)}.top-0{top:0}.top-1\/2{top:50%}.top-full{top:100%}.-right-1{right:calc(var(--spacing) * -1)}.right-0{right:0}.right-3{right:calc(var(--spacing) * 3)}.left-0{left:0}.left-1\/2{left:50%}.left-3{left:calc(var(--spacing) * 3)}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-99{z-index:99}.container{width:100%}@media (min-width:40rem){.container{max-width:40rem}}@media (min-width:48rem){.container{max-width:48rem}}@media (min-width:64rem){.container{max-width:64rem}}@media (min-width:80rem){.container{max-width:80rem}}@media (min-width:96rem){.container{max-width:96rem}}.mx-4{margin-inline:calc(var(--spacing) * 4)}.mx-auto{margin-inline:auto}.mt-0\.5{margin-top:calc(var(--spacing) * .5)}.mt-1{margin-top:var(--spacing)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mt-4{margin-top:calc(var(--spacing) * 4)}.mt-5{margin-top:calc(var(--spacing) * 5)}.mt-6{margin-top:calc(var(--spacing) * 6)}.mt-8{margin-top:calc(var(--spacing) * 8)}.mr-2{margin-right:calc(var(--spacing) * 2)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-3{margin-bottom:calc(var(--spacing) * 3)}.ml-0\.5{margin-left:calc(var(--spacing) * .5)}.ml-1{margin-left:var(--spacing)}.ml-2{margin-left:calc(var(--spacing) * 2)}.ml-3{margin-left:calc(var(--spacing) * 3)}.ml-auto{margin-left:auto}.block{display:block}.contents{display:contents}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.table{display:table}.aspect-square{aspect-ratio:1}.size-3{width:calc(var(--spacing) * 3);height:calc(var(--spacing) * 3)}.size-3\.5{width:calc(var(--spacing) * 3.5);height:calc(var(--spacing) * 3.5)}.size-4{width:calc(var(--spacing) * 4);height:calc(var(--spacing) * 4)}.size-5{width:calc(var(--spacing) * 5);height:calc(var(--spacing) * 5)}.size-6{width:calc(var(--spacing) * 6);height:calc(var(--spacing) * 6)}.size-7{width:calc(var(--spacing) * 7);height:calc(var(--spacing) * 7)}.size-9{width:calc(var(--spacing) * 9);height:calc(var(--spacing) * 9)}.size-10{width:calc(var(--spacing) * 10);height:calc(var(--spacing) * 10)}.size-11{width:calc(var(--spacing) * 11);height:calc(var(--spacing) * 11)}.size-12{width:calc(var(--spacing) * 12);height:calc(var(--spacing) * 12)}.size-14{width:calc(var(--spacing) * 14);height:calc(var(--spacing) * 14)}.size-16{width:calc(var(--spacing) * 16);height:calc(var(--spacing) * 16)}.size-24{width:calc(var(--spacing) * 24);height:calc(var(--spacing) * 24)}.size-48{width:calc(var(--spacing) * 48);height:calc(var(--spacing) * 48)}.size-full{width:100%;height:100%}.h-4{height:calc(var(--spacing) * 4)}.h-6{height:calc(var(--spacing) * 6)}.h-16{height:calc(var(--spacing) * 16)}.h-44{height:calc(var(--spacing) * 44)}.h-fit{height:fit-content}.h-px{height:1px}.max-h-56{max-height:calc(var(--spacing) * 56)}.max-h-72{max-height:calc(var(--spacing) * 72)}.max-h-80{max-height:calc(var(--spacing) * 80)}.min-h-screen{min-height:100vh}.w-4{width:calc(var(--spacing) * 4)}.w-7{width:calc(var(--spacing) * 7)}.w-8{width:calc(var(--spacing) * 8)}.w-11{width:calc(var(--spacing) * 11)}.w-20{width:calc(var(--spacing) * 20)}.w-24{width:calc(var(--spacing) * 24)}.w-28{width:calc(var(--spacing) * 28)}.w-56{width:calc(var(--spacing) * 56)}.w-60{width:calc(var(--spacing) * 60)}.w-64{width:calc(var(--spacing) * 64)}.w-80{width:calc(var(--spacing) * 80)}.w-fit{width:fit-content}.w-full{width:100%}.max-w-2xl{max-width:var(--container-2xl)}.max-w-3xl{max-width:var(--container-3xl)}.max-w-5xl{max-width:var(--container-5xl)}.max-w-7xl{max-width:var(--container-7xl)}.max-w-full{max-width:100%}.max-w-md{max-width:var(--container-md)}.max-w-none{max-width:none}.max-w-sm{max-width:var(--container-sm)}.max-w-xl{max-width:var(--container-xl)}.min-w-0{min-width:0}.min-w-4{min-width:calc(var(--spacing) * 4)}.min-w-40{min-width:calc(var(--spacing) * 40)}.min-w-48{min-width:calc(var(--spacing) * 48)}.flex-1{flex:1}.shrink-0{flex-shrink:0}.grow{flex-grow:1}.-translate-x-1\/2{--tw-translate-x:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.-translate-x-24{--tw-translate-x:calc(var(--spacing) * -24);translate:var(--tw-translate-x) var(--tw-translate-y)}.-translate-x-60{--tw-translate-x:calc(var(--spacing) * -60);translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-x-0{--tw-translate-x:0;translate:var(--tw-translate-x) var(--tw-translate-y)}.-translate-y-1\/2{--tw-translate-y:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-y-0{--tw-translate-y:0;translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-y-8{--tw-translate-y:calc(var(--spacing) * 8);translate:var(--tw-translate-x) var(--tw-translate-y)}.rotate-0{rotate:0deg}.rotate-180{rotate:180deg}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.cursor-pointer{cursor:pointer}.appearance-none{appearance:none}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-\[auto_1fr\]{grid-template-columns:auto 1fr}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-baseline{align-items:baseline}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.items-stretch{align-items:stretch}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-0\.5{gap:calc(var(--spacing) * .5)}.gap-1{gap:var(--spacing)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-2\.5{gap:calc(var(--spacing) * 2.5)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-4{gap:calc(var(--spacing) * 4)}.gap-5{gap:calc(var(--spacing) * 5)}.gap-6{gap:calc(var(--spacing) * 6)}.gap-8{gap:calc(var(--spacing) * 8)}.gap-10{gap:calc(var(--spacing) * 10)}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(var(--spacing) * var(--tw-space-y-reverse));margin-block-end:calc(var(--spacing) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 1.5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 1.5) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 2) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 3) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 4) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 5) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-6>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 6) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 6) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-8>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 8) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 8) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-12>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 12) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 12) * calc(1 - var(--tw-space-y-reverse)))}.gap-x-4{column-gap:calc(var(--spacing) * 4)}.gap-y-1{row-gap:var(--spacing)}:where(.divide-y>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(1px * var(--tw-divide-y-reverse));border-bottom-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)))}:where(.divide-outline>:not(:last-child)){border-color:var(--color-outline)}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-clip{overflow:clip}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-full{border-radius:3.40282e38px}.rounded-radius{border-radius:var(--radius-radius)}.rounded-sm{border-radius:var(--radius-sm)}.rounded-l-radius{border-top-left-radius:var(--radius-radius);border-bottom-left-radius:var(--radius-radius)}.rounded-r-radius{border-top-right-radius:var(--radius-radius);border-bottom-right-radius:var(--radius-radius)}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-danger{border-color:var(--color-danger)}.border-danger\/40{border-color:#e4001466}@supports (color:color-mix(in lab, red, red)){.border-danger\/40{border-color:color-mix(in oklab, var(--color-danger) 40%, transparent)}}.border-info{border-color:var(--color-info)}.border-outline{border-color:var(--color-outline)}.border-primary{border-color:var(--color-primary)}.border-primary\/40{border-color:#4f39f666}@supports (color:color-mix(in lab, red, red)){.border-primary\/40{border-color:color-mix(in oklab, var(--color-primary) 40%, transparent)}}.border-secondary{border-color:var(--color-secondary)}.border-secondary\/60{border-color:#45556c99}@supports (color:color-mix(in lab, red, red)){.border-secondary\/60{border-color:color-mix(in oklab, var(--color-secondary) 60%, transparent)}}.border-success{border-color:var(--color-success)}.border-warning{border-color:var(--color-warning)}.border-warning\/60{border-color:#f99c0099}@supports (color:color-mix(in lab, red, red)){.border-warning\/60{border-color:color-mix(in oklab, var(--color-warning) 60%, transparent)}}.bg-black\/50{background-color:#00000080}@supports (color:color-mix(in lab, red, red)){.bg-black\/50{background-color:color-mix(in oklab, var(--color-black) 50%, transparent)}}.bg-danger{background-color:var(--color-danger)}.bg-danger\/5{background-color:#e400140d}@supports (color:color-mix(in lab, red, red)){.bg-danger\/5{background-color:color-mix(in oklab, var(--color-danger) 5%, transparent)}}.bg-danger\/10{background-color:#e400141a}@supports (color:color-mix(in lab, red, red)){.bg-danger\/10{background-color:color-mix(in oklab, var(--color-danger) 10%, transparent)}}.bg-danger\/15{background-color:#e4001426}@supports (color:color-mix(in lab, red, red)){.bg-danger\/15{background-color:color-mix(in oklab, var(--color-danger) 15%, transparent)}}.bg-info{background-color:var(--color-info)}.bg-info\/10{background-color:#00a5ef1a}@supports (color:color-mix(in lab, red, red)){.bg-info\/10{background-color:color-mix(in oklab, var(--color-info) 10%, transparent)}}.bg-info\/15{background-color:#00a5ef26}@supports (color:color-mix(in lab, red, red)){.bg-info\/15{background-color:color-mix(in oklab, var(--color-info) 15%, transparent)}}.bg-outline{background-color:var(--color-outline)}.bg-primary{background-color:var(--color-primary)}.bg-primary\/5{background-color:#4f39f60d}@supports (color:color-mix(in lab, red, red)){.bg-primary\/5{background-color:color-mix(in oklab, var(--color-primary) 5%, transparent)}}.bg-primary\/10{background-color:#4f39f61a}@supports (color:color-mix(in lab, red, red)){.bg-primary\/10{background-color:color-mix(in oklab, var(--color-primary) 10%, transparent)}}.bg-secondary{background-color:var(--color-secondary)}.bg-success{background-color:var(--color-success)}.bg-success\/10{background-color:#00a5441a}@supports (color:color-mix(in lab, red, red)){.bg-success\/10{background-color:color-mix(in oklab, var(--color-success) 10%, transparent)}}.bg-success\/15{background-color:#00a54426}@supports (color:color-mix(in lab, red, red)){.bg-success\/15{background-color:color-mix(in oklab, var(--color-success) 15%, transparent)}}.bg-surface{background-color:var(--color-surface)}.bg-surface-alt{background-color:var(--color-surface-alt)}.bg-surface-alt\/40{background-color:#f1f5f966}@supports (color:color-mix(in lab, red, red)){.bg-surface-alt\/40{background-color:color-mix(in oklab, var(--color-surface-alt) 40%, transparent)}}.bg-surface-alt\/50{background-color:#f1f5f980}@supports (color:color-mix(in lab, red, red)){.bg-surface-alt\/50{background-color:color-mix(in oklab, var(--color-surface-alt) 50%, transparent)}}.bg-surface\/40{background-color:#fff6}@supports (color:color-mix(in lab, red, red)){.bg-surface\/40{background-color:color-mix(in oklab, var(--color-surface) 40%, transparent)}}.bg-surface\/95{background-color:#fffffff2}@supports (color:color-mix(in lab, red, red)){.bg-surface\/95{background-color:color-mix(in oklab, var(--color-surface) 95%, transparent)}}.bg-transparent{background-color:#0000}.bg-warning{background-color:var(--color-warning)}.bg-warning\/10{background-color:#f99c001a}@supports (color:color-mix(in lab, red, red)){.bg-warning\/10{background-color:color-mix(in oklab, var(--color-warning) 10%, transparent)}}.bg-warning\/15{background-color:#f99c0026}@supports (color:color-mix(in lab, red, red)){.bg-warning\/15{background-color:color-mix(in oklab, var(--color-warning) 15%, transparent)}}.bg-white{background-color:var(--color-white)}.object-cover{object-fit:cover}.p-0\.5{padding:calc(var(--spacing) * .5)}.p-1{padding:var(--spacing)}.p-2{padding:calc(var(--spacing) * 2)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.p-5{padding:calc(var(--spacing) * 5)}.p-6{padding:calc(var(--spacing) * 6)}.px-1{padding-inline:var(--spacing)}.px-1\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-2\.5{padding-inline:calc(var(--spacing) * 2.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.px-5{padding-inline:calc(var(--spacing) * 5)}.px-6{padding-inline:calc(var(--spacing) * 6)}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:var(--spacing)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-2\.5{padding-block:calc(var(--spacing) * 2.5)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-6{padding-block:calc(var(--spacing) * 6)}.py-8{padding-block:calc(var(--spacing) * 8)}.py-10{padding-block:calc(var(--spacing) * 10)}.py-12{padding-block:calc(var(--spacing) * 12)}.py-16{padding-block:calc(var(--spacing) * 16)}.pt-0{padding-top:0}.pt-1{padding-top:var(--spacing)}.pt-2{padding-top:calc(var(--spacing) * 2)}.pt-3{padding-top:calc(var(--spacing) * 3)}.pt-20{padding-top:calc(var(--spacing) * 20)}.pr-7{padding-right:calc(var(--spacing) * 7)}.pr-8{padding-right:calc(var(--spacing) * 8)}.pb-2{padding-bottom:calc(var(--spacing) * 2)}.pb-3{padding-bottom:calc(var(--spacing) * 3)}.pl-1{padding-left:var(--spacing)}.pl-3{padding-left:calc(var(--spacing) * 3)}.pl-6{padding-left:calc(var(--spacing) * 6)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.font-mono{font-family:var(--font-mono)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-3xl{font-size:var(--text-3xl);line-height:var(--tw-leading,var(--text-3xl--line-height))}.text-4xl{font-size:var(--text-4xl);line-height:var(--tw-leading,var(--text-4xl--line-height))}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[10px\]{font-size:10px}.leading-4{--tw-leading:calc(var(--spacing) * 4);line-height:calc(var(--spacing) * 4)}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-tight{--tw-tracking:var(--tracking-tight);letter-spacing:var(--tracking-tight)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.text-pretty{text-wrap:pretty}.break-all{word-break:break-all}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-line{white-space:pre-line}.text-danger{color:var(--color-danger)}.text-info{color:var(--color-info)}.text-on-danger{color:var(--color-on-danger)}.text-on-info{color:var(--color-on-info)}.text-on-primary{color:var(--color-on-primary)}.text-on-primary\/90{color:#ffffffe6}@supports (color:color-mix(in lab, red, red)){.text-on-primary\/90{color:color-mix(in oklab, var(--color-on-primary) 90%, transparent)}}.text-on-secondary{color:var(--color-on-secondary)}.text-on-success{color:var(--color-on-success)}.text-on-surface{color:var(--color-on-surface)}.text-on-surface-strong{color:var(--color-on-surface-strong)}.text-on-surface\/40{color:#31415866}@supports (color:color-mix(in lab, red, red)){.text-on-surface\/40{color:color-mix(in oklab, var(--color-on-surface) 40%, transparent)}}.text-on-surface\/50{color:#31415880}@supports (color:color-mix(in lab, red, red)){.text-on-surface\/50{color:color-mix(in oklab, var(--color-on-surface) 50%, transparent)}}.text-on-surface\/60{color:#31415899}@supports (color:color-mix(in lab, red, red)){.text-on-surface\/60{color:color-mix(in oklab, var(--color-on-surface) 60%, transparent)}}.text-on-surface\/70{color:#314158b3}@supports (color:color-mix(in lab, red, red)){.text-on-surface\/70{color:color-mix(in oklab, var(--color-on-surface) 70%, transparent)}}.text-on-surface\/80{color:#314158cc}@supports (color:color-mix(in lab, red, red)){.text-on-surface\/80{color:color-mix(in oklab, var(--color-on-surface) 80%, transparent)}}.text-on-warning{color:var(--color-on-warning)}.text-outline{color:var(--color-outline)}.text-primary{color:var(--color-primary)}.text-secondary{color:var(--color-secondary)}.text-success{color:var(--color-success)}.text-warning{color:var(--color-warning)}.uppercase{text-transform:uppercase}.italic{font-style:italic}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,)}.line-through{text-decoration-line:line-through}.underline{text-decoration-line:underline}.underline-offset-2{text-underline-offset:2px}.antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.opacity-0{opacity:0}.opacity-100{opacity:1}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.outline-danger{outline-color:var(--color-danger)}.outline-primary{outline-color:var(--color-primary)}.outline-secondary{outline-color:var(--color-secondary)}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.backdrop-blur{--tw-backdrop-blur:blur(8px);-webkit-backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-\[margin\]{transition-property:margin;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-300{--tw-duration:.3s;transition-duration:.3s}.duration-700{--tw-duration:.7s;transition-duration:.7s}.ease-in{--tw-ease:var(--ease-in);transition-timing-function:var(--ease-in)}.ease-out{--tw-ease:var(--ease-out);transition-timing-function:var(--ease-out)}@media (hover:hover){.group-hover\:scale-105:is(:where(.group):hover *){--tw-scale-x:105%;--tw-scale-y:105%;--tw-scale-z:105%;scale:var(--tw-scale-x) var(--tw-scale-y)}}.peer-checked\:visible:is(:where(.peer):checked~*){visibility:visible}.peer-checked\:bg-primary:is(:where(.peer):checked~*){background-color:var(--color-primary)}.peer-focus\:outline-2:is(:where(.peer):focus~*){outline-style:var(--tw-outline-style);outline-width:2px}.peer-focus\:outline-offset-2:is(:where(.peer):focus~*){outline-offset:2px}.peer-focus\:outline-outline-strong:is(:where(.peer):focus~*){outline-color:var(--color-outline-strong)}.peer-focus\:peer-checked\:outline-primary:is(:where(.peer):focus~*):is(:where(.peer):checked~*){outline-color:var(--color-primary)}.peer-active\:outline-offset-0:is(:where(.peer):active~*){outline-offset:0px}.file\:mr-4::file-selector-button{margin-right:calc(var(--spacing) * 4)}.file\:border-none::file-selector-button{--tw-border-style:none;border-style:none}.file\:bg-surface-alt::file-selector-button{background-color:var(--color-surface-alt)}.file\:px-4::file-selector-button{padding-inline:calc(var(--spacing) * 4)}.file\:py-2::file-selector-button{padding-block:calc(var(--spacing) * 2)}.file\:font-medium::file-selector-button{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.file\:text-on-surface-strong::file-selector-button{color:var(--color-on-surface-strong)}.before\:invisible:before{content:var(--tw-content);visibility:hidden}.before\:absolute:before{content:var(--tw-content);position:absolute}.before\:inset-0:before{content:var(--tw-content);inset:0}.before\:top-1\/2:before{content:var(--tw-content);top:50%}.before\:left-1\/2:before{content:var(--tw-content);left:50%}.before\:h-1\.5:before{content:var(--tw-content);height:calc(var(--spacing) * 1.5)}.before\:w-1\.5:before{content:var(--tw-content);width:calc(var(--spacing) * 1.5)}.before\:-translate-x-1\/2:before{content:var(--tw-content);--tw-translate-x:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.before\:-translate-y-1\/2:before{content:var(--tw-content);--tw-translate-y:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.before\:rounded-full:before{content:var(--tw-content);border-radius:3.40282e38px}.before\:bg-on-primary:before{content:var(--tw-content);background-color:var(--color-on-primary)}.after\:absolute:after{content:var(--tw-content);position:absolute}.after\:top-0:after{content:var(--tw-content);top:0}.after\:bottom-0:after{content:var(--tw-content);bottom:0}.after\:left-\[0\.0625rem\]:after{content:var(--tw-content);left:.0625rem}.after\:my-auto:after{content:var(--tw-content);margin-block:auto}.after\:h-5:after{content:var(--tw-content);height:calc(var(--spacing) * 5)}.after\:w-5:after{content:var(--tw-content);width:calc(var(--spacing) * 5)}.after\:rounded-full:after{content:var(--tw-content);border-radius:3.40282e38px}.after\:bg-on-surface:after{content:var(--tw-content);background-color:var(--color-on-surface)}.after\:transition-all:after{content:var(--tw-content);transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.after\:content-\[\'\'\]:after{--tw-content:"";content:var(--tw-content)}.peer-checked\:after\:translate-x-5:is(:where(.peer):checked~*):after{content:var(--tw-content);--tw-translate-x:calc(var(--spacing) * 5);translate:var(--tw-translate-x) var(--tw-translate-y)}.peer-checked\:after\:bg-on-primary:is(:where(.peer):checked~*):after{content:var(--tw-content);background-color:var(--color-on-primary)}.checked\:border-primary:checked{border-color:var(--color-primary)}.checked\:bg-primary:checked{background-color:var(--color-primary)}.checked\:before\:visible:checked:before{content:var(--tw-content);visibility:visible}.checked\:before\:bg-primary:checked:before{content:var(--tw-content);background-color:var(--color-primary)}@media (hover:hover){.hover\:border-primary:hover{border-color:var(--color-primary)}.hover\:bg-danger\/5:hover{background-color:#e400140d}@supports (color:color-mix(in lab, red, red)){.hover\:bg-danger\/5:hover{background-color:color-mix(in oklab, var(--color-danger) 5%, transparent)}}.hover\:bg-danger\/10:hover{background-color:#e400141a}@supports (color:color-mix(in lab, red, red)){.hover\:bg-danger\/10:hover{background-color:color-mix(in oklab, var(--color-danger) 10%, transparent)}}.hover\:bg-info\/5:hover{background-color:#00a5ef0d}@supports (color:color-mix(in lab, red, red)){.hover\:bg-info\/5:hover{background-color:color-mix(in oklab, var(--color-info) 5%, transparent)}}.hover\:bg-primary\/5:hover{background-color:#4f39f60d}@supports (color:color-mix(in lab, red, red)){.hover\:bg-primary\/5:hover{background-color:color-mix(in oklab, var(--color-primary) 5%, transparent)}}.hover\:bg-surface-alt:hover{background-color:var(--color-surface-alt)}.hover\:bg-surface-dark-alt\/5:hover{background-color:#1d293d0d}@supports (color:color-mix(in lab, red, red)){.hover\:bg-surface-dark-alt\/5:hover{background-color:color-mix(in oklab, var(--color-surface-dark-alt) 5%, transparent)}}.hover\:bg-surface\/60:hover{background-color:#fff9}@supports (color:color-mix(in lab, red, red)){.hover\:bg-surface\/60:hover{background-color:color-mix(in oklab, var(--color-surface) 60%, transparent)}}.hover\:text-on-surface-strong:hover{color:var(--color-on-surface-strong)}.hover\:text-primary:hover{color:var(--color-primary)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-75:hover{opacity:.75}.hover\:opacity-90:hover{opacity:.9}}.focus\:outline-hidden:focus{--tw-outline-style:none;outline-style:none}@media (forced-colors:active){.focus\:outline-hidden:focus{outline-offset:2px;outline:2px solid #0000}}.focus\:outline-2:focus{outline-style:var(--tw-outline-style);outline-width:2px}.focus\:outline-offset-2:focus{outline-offset:2px}.focus\:outline-outline-strong:focus{outline-color:var(--color-outline-strong)}.focus\:outline-primary:focus,.checked\:focus\:outline-primary:checked:focus{outline-color:var(--color-primary)}.focus-visible\:bg-primary\/10:focus-visible{background-color:#4f39f61a}@supports (color:color-mix(in lab, red, red)){.focus-visible\:bg-primary\/10:focus-visible{background-color:color-mix(in oklab, var(--color-primary) 10%, transparent)}}.focus-visible\:bg-surface-dark-alt\/10:focus-visible{background-color:#1d293d1a}@supports (color:color-mix(in lab, red, red)){.focus-visible\:bg-surface-dark-alt\/10:focus-visible{background-color:color-mix(in oklab, var(--color-surface-dark-alt) 10%, transparent)}}.focus-visible\:text-on-surface-strong:focus-visible{color:var(--color-on-surface-strong)}.focus-visible\:underline:focus-visible{text-decoration-line:underline}.focus-visible\:outline-hidden:focus-visible{--tw-outline-style:none;outline-style:none}@media (forced-colors:active){.focus-visible\:outline-hidden:focus-visible{outline-offset:2px;outline:2px solid #0000}}.focus-visible\:outline-2:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px}.focus-visible\:outline-offset-2:focus-visible{outline-offset:2px}.focus-visible\:outline-danger:focus-visible{outline-color:var(--color-danger)}.focus-visible\:outline-info:focus-visible{outline-color:var(--color-info)}.focus-visible\:outline-outline:focus-visible{outline-color:var(--color-outline)}.focus-visible\:outline-primary:focus-visible{outline-color:var(--color-primary)}.focus-visible\:outline-secondary:focus-visible{outline-color:var(--color-secondary)}.focus-visible\:outline-success:focus-visible{outline-color:var(--color-success)}.focus-visible\:outline-warning:focus-visible{outline-color:var(--color-warning)}.active\:opacity-100:active{opacity:1}.active\:outline-offset-0:active{outline-offset:0px}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-75:disabled{opacity:.75}.has-checked\:text-on-surface-strong:has(:checked){color:var(--color-on-surface-strong)}.has-disabled\:cursor-not-allowed:has(:disabled){cursor:not-allowed}.has-disabled\:opacity-75:has(:disabled){opacity:.75}.has-\[\:checked\]\:border-primary:has(:checked){border-color:var(--color-primary)}.aria-\[current\=page\]\:bg-primary\/10[aria-current=page]{background-color:#4f39f61a}@supports (color:color-mix(in lab, red, red)){.aria-\[current\=page\]\:bg-primary\/10[aria-current=page]{background-color:color-mix(in oklab, var(--color-primary) 10%, transparent)}}.aria-\[current\=page\]\:font-semibold[aria-current=page]{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.aria-\[current\=page\]\:text-on-surface-strong[aria-current=page]{color:var(--color-on-surface-strong)}.aria-\[current\=page\]\:text-primary[aria-current=page]{color:var(--color-primary)}@media (min-width:40rem){.sm\:col-span-2{grid-column:span 2/span 2}.sm\:col-span-3{grid-column:span 3/span 3}.sm\:col-span-4{grid-column:span 4/span 4}.sm\:col-span-5{grid-column:span 5/span 5}.sm\:max-w-\[10rem\]{max-width:10rem}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:grid-cols-12{grid-template-columns:repeat(12,minmax(0,1fr))}}@media (min-width:48rem){.md\:top-\[unset\]{top:unset}.md\:right-0{right:0}.md\:bottom-0{bottom:0}.md\:left-\[unset\]{left:unset}.md\:ml-0{margin-left:0}.md\:ml-60{margin-left:calc(var(--spacing) * 60)}.md\:flex{display:flex}.md\:hidden{display:none}.md\:inline-flex{display:inline-flex}.md\:h-64{height:calc(var(--spacing) * 64)}.md\:w-56{width:calc(var(--spacing) * 56)}.md\:max-w-sm{max-width:var(--container-sm)}.md\:-translate-x-60{--tw-translate-x:calc(var(--spacing) * -60);translate:var(--tw-translate-x) var(--tw-translate-y)}.md\:translate-x-0{--tw-translate-x:0;translate:var(--tw-translate-x) var(--tw-translate-y)}.md\:translate-x-24{--tw-translate-x:calc(var(--spacing) * 24);translate:var(--tw-translate-x) var(--tw-translate-y)}.md\:flex-row{flex-direction:row}.md\:items-start{align-items:flex-start}}@media (min-width:64rem){.lg\:static{position:static}.lg\:z-auto{z-index:auto}.lg\:col-span-2{grid-column:span 2/span 2}.lg\:hidden{display:none}.lg\:w-64{width:calc(var(--spacing) * 64)}.lg\:shrink-0{flex-shrink:0}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:self-start{align-self:flex-start}.lg\:overflow-visible{overflow:visible}.lg\:rounded-radius{border-radius:var(--radius-radius)}.lg\:border{border-style:var(--tw-border-style);border-width:1px}.lg\:p-3{padding:calc(var(--spacing) * 3)}}@media (min-width:80rem){.xl\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}:where(.dark\:divide-outline-dark:where([data-theme=dark],[data-theme=dark] *)>:not(:last-child)){border-color:var(--color-outline-dark)}.dark\:border-danger:where([data-theme=dark],[data-theme=dark] *){border-color:var(--color-danger)}.dark\:border-info:where([data-theme=dark],[data-theme=dark] *){border-color:var(--color-info)}.dark\:border-outline-dark:where([data-theme=dark],[data-theme=dark] *){border-color:var(--color-outline-dark)}.dark\:border-primary-dark:where([data-theme=dark],[data-theme=dark] *){border-color:var(--color-primary-dark)}.dark\:border-primary-dark\/40:where([data-theme=dark],[data-theme=dark] *){border-color:#7d87ff66}@supports (color:color-mix(in lab, red, red)){.dark\:border-primary-dark\/40:where([data-theme=dark],[data-theme=dark] *){border-color:color-mix(in oklab, var(--color-primary-dark) 40%, transparent)}}.dark\:border-secondary-dark:where([data-theme=dark],[data-theme=dark] *){border-color:var(--color-secondary-dark)}.dark\:border-secondary-dark\/60:where([data-theme=dark],[data-theme=dark] *){border-color:#cad5e299}@supports (color:color-mix(in lab, red, red)){.dark\:border-secondary-dark\/60:where([data-theme=dark],[data-theme=dark] *){border-color:color-mix(in oklab, var(--color-secondary-dark) 60%, transparent)}}.dark\:border-success:where([data-theme=dark],[data-theme=dark] *){border-color:var(--color-success)}.dark\:border-warning:where([data-theme=dark],[data-theme=dark] *){border-color:var(--color-warning)}.dark\:bg-danger:where([data-theme=dark],[data-theme=dark] *){background-color:var(--color-danger)}.dark\:bg-info:where([data-theme=dark],[data-theme=dark] *){background-color:var(--color-info)}.dark\:bg-outline-dark:where([data-theme=dark],[data-theme=dark] *){background-color:var(--color-outline-dark)}.dark\:bg-primary-dark:where([data-theme=dark],[data-theme=dark] *){background-color:var(--color-primary-dark)}.dark\:bg-primary-dark\/10:where([data-theme=dark],[data-theme=dark] *){background-color:#7d87ff1a}@supports (color:color-mix(in lab, red, red)){.dark\:bg-primary-dark\/10:where([data-theme=dark],[data-theme=dark] *){background-color:color-mix(in oklab, var(--color-primary-dark) 10%, transparent)}}.dark\:bg-secondary-dark:where([data-theme=dark],[data-theme=dark] *){background-color:var(--color-secondary-dark)}.dark\:bg-success:where([data-theme=dark],[data-theme=dark] *){background-color:var(--color-success)}.dark\:bg-surface-dark:where([data-theme=dark],[data-theme=dark] *){background-color:var(--color-surface-dark)}.dark\:bg-surface-dark-alt:where([data-theme=dark],[data-theme=dark] *){background-color:var(--color-surface-dark-alt)}.dark\:bg-surface-dark-alt\/30:where([data-theme=dark],[data-theme=dark] *){background-color:#1d293d4d}@supports (color:color-mix(in lab, red, red)){.dark\:bg-surface-dark-alt\/30:where([data-theme=dark],[data-theme=dark] *){background-color:color-mix(in oklab, var(--color-surface-dark-alt) 30%, transparent)}}.dark\:bg-surface-dark-alt\/40:where([data-theme=dark],[data-theme=dark] *){background-color:#1d293d66}@supports (color:color-mix(in lab, red, red)){.dark\:bg-surface-dark-alt\/40:where([data-theme=dark],[data-theme=dark] *){background-color:color-mix(in oklab, var(--color-surface-dark-alt) 40%, transparent)}}.dark\:bg-surface-dark-alt\/50:where([data-theme=dark],[data-theme=dark] *){background-color:#1d293d80}@supports (color:color-mix(in lab, red, red)){.dark\:bg-surface-dark-alt\/50:where([data-theme=dark],[data-theme=dark] *){background-color:color-mix(in oklab, var(--color-surface-dark-alt) 50%, transparent)}}.dark\:bg-surface-dark\/40:where([data-theme=dark],[data-theme=dark] *){background-color:#0f172b66}@supports (color:color-mix(in lab, red, red)){.dark\:bg-surface-dark\/40:where([data-theme=dark],[data-theme=dark] *){background-color:color-mix(in oklab, var(--color-surface-dark) 40%, transparent)}}.dark\:bg-surface-dark\/95:where([data-theme=dark],[data-theme=dark] *){background-color:#0f172bf2}@supports (color:color-mix(in lab, red, red)){.dark\:bg-surface-dark\/95:where([data-theme=dark],[data-theme=dark] *){background-color:color-mix(in oklab, var(--color-surface-dark) 95%, transparent)}}.dark\:bg-warning:where([data-theme=dark],[data-theme=dark] *){background-color:var(--color-warning)}.dark\:text-danger:where([data-theme=dark],[data-theme=dark] *){color:var(--color-danger)}.dark\:text-on-danger:where([data-theme=dark],[data-theme=dark] *){color:var(--color-on-danger)}.dark\:text-on-info:where([data-theme=dark],[data-theme=dark] *){color:var(--color-on-info)}.dark\:text-on-primary-dark:where([data-theme=dark],[data-theme=dark] *){color:var(--color-on-primary-dark)}.dark\:text-on-primary-dark\/90:where([data-theme=dark],[data-theme=dark] *){color:#020618e6}@supports (color:color-mix(in lab, red, red)){.dark\:text-on-primary-dark\/90:where([data-theme=dark],[data-theme=dark] *){color:color-mix(in oklab, var(--color-on-primary-dark) 90%, transparent)}}.dark\:text-on-secondary-dark:where([data-theme=dark],[data-theme=dark] *){color:var(--color-on-secondary-dark)}.dark\:text-on-success:where([data-theme=dark],[data-theme=dark] *){color:var(--color-on-success)}.dark\:text-on-surface-dark:where([data-theme=dark],[data-theme=dark] *){color:var(--color-on-surface-dark)}.dark\:text-on-surface-dark-strong:where([data-theme=dark],[data-theme=dark] *){color:var(--color-on-surface-dark-strong)}.dark\:text-on-surface-dark\/40:where([data-theme=dark],[data-theme=dark] *){color:#cad5e266}@supports (color:color-mix(in lab, red, red)){.dark\:text-on-surface-dark\/40:where([data-theme=dark],[data-theme=dark] *){color:color-mix(in oklab, var(--color-on-surface-dark) 40%, transparent)}}.dark\:text-on-surface-dark\/50:where([data-theme=dark],[data-theme=dark] *){color:#cad5e280}@supports (color:color-mix(in lab, red, red)){.dark\:text-on-surface-dark\/50:where([data-theme=dark],[data-theme=dark] *){color:color-mix(in oklab, var(--color-on-surface-dark) 50%, transparent)}}.dark\:text-on-surface-dark\/60:where([data-theme=dark],[data-theme=dark] *){color:#cad5e299}@supports (color:color-mix(in lab, red, red)){.dark\:text-on-surface-dark\/60:where([data-theme=dark],[data-theme=dark] *){color:color-mix(in oklab, var(--color-on-surface-dark) 60%, transparent)}}.dark\:text-on-surface-dark\/70:where([data-theme=dark],[data-theme=dark] *){color:#cad5e2b3}@supports (color:color-mix(in lab, red, red)){.dark\:text-on-surface-dark\/70:where([data-theme=dark],[data-theme=dark] *){color:color-mix(in oklab, var(--color-on-surface-dark) 70%, transparent)}}.dark\:text-on-surface-dark\/80:where([data-theme=dark],[data-theme=dark] *){color:#cad5e2cc}@supports (color:color-mix(in lab, red, red)){.dark\:text-on-surface-dark\/80:where([data-theme=dark],[data-theme=dark] *){color:color-mix(in oklab, var(--color-on-surface-dark) 80%, transparent)}}.dark\:text-on-warning:where([data-theme=dark],[data-theme=dark] *){color:var(--color-on-warning)}.dark\:text-outline-dark:where([data-theme=dark],[data-theme=dark] *){color:var(--color-outline-dark)}.dark\:text-primary-dark:where([data-theme=dark],[data-theme=dark] *){color:var(--color-primary-dark)}.dark\:text-secondary-dark:where([data-theme=dark],[data-theme=dark] *){color:var(--color-secondary-dark)}.dark\:text-warning:where([data-theme=dark],[data-theme=dark] *){color:var(--color-warning)}.dark\:peer-checked\:bg-primary-dark:where([data-theme=dark],[data-theme=dark] *):is(:where(.peer):checked~*){background-color:var(--color-primary-dark)}.dark\:peer-focus\:outline-outline-dark-strong:where([data-theme=dark],[data-theme=dark] *):is(:where(.peer):focus~*){outline-color:var(--color-outline-dark-strong)}.dark\:peer-focus\:peer-checked\:outline-primary-dark:where([data-theme=dark],[data-theme=dark] *):is(:where(.peer):focus~*):is(:where(.peer):checked~*){outline-color:var(--color-primary-dark)}.dark\:file\:bg-surface-dark-alt:where([data-theme=dark],[data-theme=dark] *)::file-selector-button{background-color:var(--color-surface-dark-alt)}.dark\:file\:text-on-surface-dark-strong:where([data-theme=dark],[data-theme=dark] *)::file-selector-button{color:var(--color-on-surface-dark-strong)}.dark\:before\:bg-on-primary-dark:where([data-theme=dark],[data-theme=dark] *):before{content:var(--tw-content);background-color:var(--color-on-primary-dark)}.dark\:after\:bg-on-surface-dark:where([data-theme=dark],[data-theme=dark] *):after{content:var(--tw-content);background-color:var(--color-on-surface-dark)}.dark\:peer-checked\:after\:bg-on-primary-dark:where([data-theme=dark],[data-theme=dark] *):is(:where(.peer):checked~*):after{content:var(--tw-content);background-color:var(--color-on-primary-dark)}.dark\:checked\:border-primary-dark:where([data-theme=dark],[data-theme=dark] *):checked{border-color:var(--color-primary-dark)}.dark\:checked\:bg-primary-dark:where([data-theme=dark],[data-theme=dark] *):checked{background-color:var(--color-primary-dark)}.dark\:checked\:before\:bg-primary-dark:where([data-theme=dark],[data-theme=dark] *):checked:before{content:var(--tw-content);background-color:var(--color-primary-dark)}@media (hover:hover){.dark\:hover\:border-primary-dark:where([data-theme=dark],[data-theme=dark] *):hover{border-color:var(--color-primary-dark)}.dark\:hover\:bg-primary-dark\/5:where([data-theme=dark],[data-theme=dark] *):hover{background-color:#7d87ff0d}@supports (color:color-mix(in lab, red, red)){.dark\:hover\:bg-primary-dark\/5:where([data-theme=dark],[data-theme=dark] *):hover{background-color:color-mix(in oklab, var(--color-primary-dark) 5%, transparent)}}.dark\:hover\:bg-surface-alt\/5:where([data-theme=dark],[data-theme=dark] *):hover{background-color:#f1f5f90d}@supports (color:color-mix(in lab, red, red)){.dark\:hover\:bg-surface-alt\/5:where([data-theme=dark],[data-theme=dark] *):hover{background-color:color-mix(in oklab, var(--color-surface-alt) 5%, transparent)}}.dark\:hover\:bg-surface-dark:where([data-theme=dark],[data-theme=dark] *):hover{background-color:var(--color-surface-dark)}.dark\:hover\:bg-surface-dark-alt:where([data-theme=dark],[data-theme=dark] *):hover{background-color:var(--color-surface-dark-alt)}.dark\:hover\:bg-surface-dark-alt\/50:where([data-theme=dark],[data-theme=dark] *):hover{background-color:#1d293d80}@supports (color:color-mix(in lab, red, red)){.dark\:hover\:bg-surface-dark-alt\/50:where([data-theme=dark],[data-theme=dark] *):hover{background-color:color-mix(in oklab, var(--color-surface-dark-alt) 50%, transparent)}}.dark\:hover\:bg-surface-dark\/60:where([data-theme=dark],[data-theme=dark] *):hover{background-color:#0f172b99}@supports (color:color-mix(in lab, red, red)){.dark\:hover\:bg-surface-dark\/60:where([data-theme=dark],[data-theme=dark] *):hover{background-color:color-mix(in oklab, var(--color-surface-dark) 60%, transparent)}}.dark\:hover\:text-on-surface-dark-strong:where([data-theme=dark],[data-theme=dark] *):hover{color:var(--color-on-surface-dark-strong)}.dark\:hover\:text-primary-dark:where([data-theme=dark],[data-theme=dark] *):hover{color:var(--color-primary-dark)}}.dark\:focus\:outline-outline-dark-strong:where([data-theme=dark],[data-theme=dark] *):focus{outline-color:var(--color-outline-dark-strong)}.dark\:checked\:focus\:outline-primary-dark:where([data-theme=dark],[data-theme=dark] *):checked:focus{outline-color:var(--color-primary-dark)}.dark\:focus-visible\:bg-surface-alt\/10:where([data-theme=dark],[data-theme=dark] *):focus-visible{background-color:#f1f5f91a}@supports (color:color-mix(in lab, red, red)){.dark\:focus-visible\:bg-surface-alt\/10:where([data-theme=dark],[data-theme=dark] *):focus-visible{background-color:color-mix(in oklab, var(--color-surface-alt) 10%, transparent)}}.dark\:focus-visible\:text-on-surface-dark-strong:where([data-theme=dark],[data-theme=dark] *):focus-visible{color:var(--color-on-surface-dark-strong)}.dark\:focus-visible\:outline-danger:where([data-theme=dark],[data-theme=dark] *):focus-visible{outline-color:var(--color-danger)}.dark\:focus-visible\:outline-info:where([data-theme=dark],[data-theme=dark] *):focus-visible{outline-color:var(--color-info)}.dark\:focus-visible\:outline-outline-dark:where([data-theme=dark],[data-theme=dark] *):focus-visible{outline-color:var(--color-outline-dark)}.dark\:focus-visible\:outline-primary-dark:where([data-theme=dark],[data-theme=dark] *):focus-visible{outline-color:var(--color-primary-dark)}.dark\:focus-visible\:outline-secondary-dark:where([data-theme=dark],[data-theme=dark] *):focus-visible{outline-color:var(--color-secondary-dark)}.dark\:focus-visible\:outline-success:where([data-theme=dark],[data-theme=dark] *):focus-visible{outline-color:var(--color-success)}.dark\:focus-visible\:outline-warning:where([data-theme=dark],[data-theme=dark] *):focus-visible{outline-color:var(--color-warning)}.dark\:has-checked\:text-on-surface-dark-strong:where([data-theme=dark],[data-theme=dark] *):has(:checked){color:var(--color-on-surface-dark-strong)}.dark\:has-\[\:checked\]\:border-primary-dark:where([data-theme=dark],[data-theme=dark] *):has(:checked){border-color:var(--color-primary-dark)}.dark\:aria-\[current\=page\]\:bg-primary-dark\/10:where([data-theme=dark],[data-theme=dark] *)[aria-current=page]{background-color:#7d87ff1a}@supports (color:color-mix(in lab, red, red)){.dark\:aria-\[current\=page\]\:bg-primary-dark\/10:where([data-theme=dark],[data-theme=dark] *)[aria-current=page]{background-color:color-mix(in oklab, var(--color-primary-dark) 10%, transparent)}}.dark\:aria-\[current\=page\]\:text-on-surface-dark-strong:where([data-theme=dark],[data-theme=dark] *)[aria-current=page]{color:var(--color-on-surface-dark-strong)}.dark\:aria-\[current\=page\]\:text-primary-dark:where([data-theme=dark],[data-theme=dark] *)[aria-current=page]{color:var(--color-primary-dark)}}[x-cloak]{display:none!important}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-divide-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-content{syntax:"*";inherits:false;initial-value:""} \ No newline at end of file diff --git a/assets/views/account/order_detail.html b/assets/views/account/order_detail.html index f9ad41d..7926ca5 100644 --- a/assets/views/account/order_detail.html +++ b/assets/views/account/order_detail.html @@ -29,7 +29,7 @@
    {% for item in items %}
  • - {{ item.product_name }} × {{ item.quantity }} + {{ item.product_name }}{% if item.variant_label %} · {{ item.variant_label }}{% endif %} × {{ item.quantity }} {{ item.line_total }} {{ order.currency }}
  • {% endfor %} diff --git a/assets/views/admin/catalog/product_form.html b/assets/views/admin/catalog/product_form.html index d48dacd..7c28fbb 100644 --- a/assets/views/admin/catalog/product_form.html +++ b/assets/views/admin/catalog/product_form.html @@ -18,38 +18,95 @@ {{ ui::csrf_field() }} {% if product %} - {% set v_name = product.name %}{% set v_price = product.price %}{% set v_currency = product.currency %}{% set v_stock = product.stock %}{% set v_sku = product.sku | default(value="") %}{% set v_desc = product.description | default(value="") %}{% set v_pub = product.published %} + {% set v_name = product.name %}{% set v_currency = product.currency %}{% set v_desc = product.description | default(value="") %}{% set v_pub = product.published %} {% else %} - {% set v_name = "" %}{% set v_price = "" %}{% set v_currency = "EUR" %}{% set v_stock = 0 %}{% set v_sku = "" %}{% set v_desc = "" %}{% set v_pub = false %} + {% set v_name = "" %}{% set v_currency = "EUR" %}{% set v_desc = "" %}{% set v_pub = false %} {% endif %} + {% set inp = "w-full rounded-radius border border-outline bg-surface-alt px-3 py-2 text-sm text-on-surface focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary dark:border-outline-dark dark:bg-surface-dark-alt/50 dark:text-on-surface-dark dark:focus-visible:outline-primary-dark" %} + {% set sublabel = "text-xs font-medium text-on-surface/70 dark:text-on-surface-dark/70" %}
    {{ ui::input(name="name", id="name", required=true, value=v_name) }}
    -
    -
    - - {{ ui::input(name="price", id="price", required=true, value=v_price, placeholder="0.00", attrs='inputmode="decimal"') }} -
    -
    - - {{ ui::input(name="currency", id="currency", value=v_currency, attrs='maxlength="3"', extra="uppercase") }} -
    +
    + + {{ ui::input(name="currency", id="currency", value=v_currency, attrs='maxlength="3"', extra="uppercase") }}
    -
    -
    - - {{ ui::input(name="stock", id="stock", type="number", value=v_stock, attrs='min="0"') }} -
    -
    - - {{ ui::input(name="sku", id="sku", value=v_sku) }} + {# --- Variants / options editor ------------------------------------------- #} + {# Each product is sold as one or more variants (a free-text label such as #} + {# "10cm x 13cm" or "5ml" plus its own price/stock/sku, and optional public & #} + {# business sale prices). Rows are managed client-side; names are indexed #} + {# (variants[i][...]) and read back by the controller. #} + +
    +
    + {{ t(key="variants-options", lang=lang | default(value='sk')) }} +
    + +
    + +
    diff --git a/assets/views/admin/catalog/products.html b/assets/views/admin/catalog/products.html index 51cf00e..9a677fc 100644 --- a/assets/views/admin/catalog/products.html +++ b/assets/views/admin/catalog/products.html @@ -83,7 +83,7 @@ {{ ui::th(label=t(key="product", lang=lang | default(value='sk'))) }} {{ ui::th(label=t(key="price", lang=lang | default(value='sk'))) }} - {{ ui::th(label=t(key="sale-price", lang=lang | default(value='sk'))) }} + {{ ui::th(label=t(key="variants-options", lang=lang | default(value='sk'))) }} {{ ui::th(label=t(key="effective-price", lang=lang | default(value='sk'))) }} {{ ui::th(label=t(key="stock", lang=lang | default(value='sk'))) }} {{ ui::th(label=t(key="status", lang=lang | default(value='sk'))) }} @@ -106,15 +106,8 @@
    - {{ product.regular_price }} {{ product.currency }} - - {% if product.on_sale %} - {{ product.sale_price }} {{ product.currency }} - (−{{ product.percent_off }}%) - {% else %} - - {% endif %} - + {% if product.has_options %}{{ t(key="from-price", price=product.regular_price, lang=lang | default(value='sk')) }}{% else %}{{ product.regular_price }}{% endif %} {{ product.currency }} + {{ product.variant_count }} {{ ui::eff_price(p=product) }} @@ -129,14 +122,6 @@
    {{ ui::button(variant="outline-secondary", label=t(key="edit", lang=lang | default(value='sk')), href="/admin/catalog/products/" ~ product.id ~ "/edit", size="px-3 py-1.5 text-xs") }} - {{ ui::button(variant="outline-secondary", label=t(key="set-discount", lang=lang | default(value='sk')), href="/admin/catalog/products/" ~ product.id ~ "/discount/edit?audience=" ~ audience, size="px-3 py-1.5 text-xs") }} - {% if product.on_sale %} -
    - {{ ui::csrf_field() }} - {{ ui::button(variant="outline-danger", label=t(key="remove-discount", lang=lang | default(value='sk')), type="submit", size="px-3 py-1.5 text-xs") }} -
    - {% endif %} {{ ui::button(variant="outline-secondary", label=t(key="view", lang=lang | default(value='sk')), href="/shop/" ~ product.slug, size="px-3 py-1.5 text-xs") }}
    diff --git a/assets/views/admin/customers/price_form.html b/assets/views/admin/customers/price_form.html index 366ca60..1bb6c73 100644 --- a/assets/views/admin/customers/price_form.html +++ b/assets/views/admin/customers/price_form.html @@ -8,7 +8,7 @@
    -

    {{ product.name }}

    +

    {{ product.name }}{% if product.variant_label %} · {{ product.variant_label }}{% endif %}

    {{ ui::badge(label=t(key="negotiated-price", lang=lang | default(value='sk')), variant="info") }}

    {{ customer.name }}

    @@ -20,7 +20,7 @@
    {{ ui::alert_danger(message=t(key=error, lang=lang | default(value='sk'))) }}
    {% endif %} - {{ ui::button(variant="secondary", label=t(key="save", lang=lang | default(value='sk')), type="submit") }} {% if has_negotiated %} - {{ ui::button(variant="outline-danger", label=t(key="remove", lang=lang | default(value='sk')), type="submit", attrs=`formaction="/admin/customers/` ~ customer.id ~ `/prices/` ~ product.id ~ `/remove" onclick="return confirm('` ~ t(key="negotiated-remove-confirm", lang=lang | default(value='sk')) ~ `')"`) }} + {{ ui::button(variant="outline-danger", label=t(key="remove", lang=lang | default(value='sk')), type="submit", attrs=`formaction="/admin/customers/` ~ customer.id ~ `/prices/` ~ product.variant_id ~ `/remove" onclick="return confirm('` ~ t(key="negotiated-remove-confirm", lang=lang | default(value='sk')) ~ `')"`) }} {% endif %}
    @@ -83,7 +83,7 @@

    {{ t(key="automated-price", lang=lang | default(value='sk')) }}

    {{ ui::badge(label=t(key="collision", lang=lang | default(value='sk')), variant="warning") }}
    -
    + {{ ui::csrf_field() }} - + {{ ui::button(label=t(key="add-to-cart", lang=lang | default(value='sk')), type="submit", extra="w-full", icon='') }}
    diff --git a/assets/views/shop/_cart_body.html b/assets/views/shop/_cart_body.html index c56e45c..448e642 100644 --- a/assets/views/shop/_cart_body.html +++ b/assets/views/shop/_cart_body.html @@ -19,6 +19,7 @@ {{ item.name }} + {% if item.variant_label %}{{ item.variant_label }}{% endif %} {% if item.on_sale %} @@ -35,7 +36,7 @@
    {{ ui::csrf_field() }} - + {{ ui::csrf_field() }} - + {{ ui::button(variant="ghost-danger", label=t(key="cart-remove", lang=lang | default(value='sk')), type="submit", size="px-2 py-1 text-xs") }}
    diff --git a/assets/views/shop/_cart_preview.html b/assets/views/shop/_cart_preview.html index 1934142..be0e366 100644 --- a/assets/views/shop/_cart_preview.html +++ b/assets/views/shop/_cart_preview.html @@ -8,6 +8,7 @@
    {{ item.name }} + {% if item.variant_label %}{{ item.variant_label }}{% endif %}

    {{ item.quantity }} × {{ item.price }} {{ item.currency }}

    {{ item.line_total }} {{ item.currency }} diff --git a/assets/views/shop/order_confirmed.html b/assets/views/shop/order_confirmed.html index 47339a3..a6beae5 100644 --- a/assets/views/shop/order_confirmed.html +++ b/assets/views/shop/order_confirmed.html @@ -29,7 +29,7 @@
      {% for item in items %}
    • - {{ item.product_name }} × {{ item.quantity }} + {{ item.product_name }}{% if item.variant_label %} · {{ item.variant_label }}{% endif %} × {{ item.quantity }} {{ item.line_total }} {{ order.currency }}
    • {% endfor %} diff --git a/assets/views/shop/show.html b/assets/views/shop/show.html index 10b8aa5..359c66d 100644 --- a/assets/views/shop/show.html +++ b/assets/views/shop/show.html @@ -49,39 +49,77 @@
    -
    + {% set fld = "w-full rounded-radius border border-outline bg-surface-alt px-3 py-2 text-sm text-on-surface focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary dark:border-outline-dark dark:bg-surface-dark-alt/50 dark:text-on-surface-dark dark:focus-visible:outline-primary-dark" %} + {% set btn = "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-radius px-5 py-2 text-sm text-center font-medium tracking-wide transition hover:opacity-75 focus-visible:outline-2 focus-visible:outline-offset-2 active:opacity-100 active:outline-offset-0 disabled:cursor-not-allowed disabled:opacity-75 border border-primary bg-primary text-on-primary focus-visible:outline-primary dark:border-primary-dark dark:bg-primary-dark dark:text-on-primary-dark dark:focus-visible:outline-primary-dark" %} + +
    {% if category %} {{ category.name }} {% endif %}

    {{ product.name }}

    - {% if product.on_sale %} -
    -

    {{ product.price }} {{ product.currency }}

    -

    {{ product.regular_price }} {{ product.currency }}

    -
    - {% else %} -

    {{ product.price }} {{ product.currency }}

    - {% endif %} - {% if product.description %} -
    {{ product.description }}
    - {% endif %} + + +
    + +
    {% endblock content %} diff --git a/migration/src/lib.rs b/migration/src/lib.rs index 7afeb5f..276f8a4 100644 --- a/migration/src/lib.rs +++ b/migration/src/lib.rs @@ -40,6 +40,7 @@ mod m20260621_000002_account_product_prices; mod m20260621_000003_discount_profiles; mod m20260621_000004_add_business_sale_price_to_products; mod m20260622_000001_audience_discount_profiles; +mod m20260622_000002_product_variants; pub struct Migrator; #[async_trait::async_trait] @@ -84,6 +85,7 @@ impl MigratorTrait for Migrator { Box::new(m20260621_000003_discount_profiles::Migration), Box::new(m20260621_000004_add_business_sale_price_to_products::Migration), Box::new(m20260622_000001_audience_discount_profiles::Migration), + Box::new(m20260622_000002_product_variants::Migration), // inject-above (do not remove this comment) ] } diff --git a/migration/src/m20260622_000002_product_variants.rs b/migration/src/m20260622_000002_product_variants.rs new file mode 100644 index 0000000..d663cd2 --- /dev/null +++ b/migration/src/m20260622_000002_product_variants.rs @@ -0,0 +1,204 @@ +//! Introduce product variants as the purchasable unit. +//! +//! A product becomes a presentation grouping (name, description, images, +//! category, tags, percentage discount profiles). Each product owns one or more +//! `product_variants`, and the variant is what carries the things that actually +//! differ between options: a free-text `label` (e.g. "rolovaná 90cm x 10m", +//! "5ml"), its own `sku`, `stock`, regular `price_cents`, and its own optional +//! public/business quick-sale prices. +//! +//! This migration: +//! 1. creates `product_variants`, +//! 2. backfills one variant per existing product from the product's current +//! price/stock/sku/sale columns, +//! 3. moves the per-account negotiated price and collision-resolution tables +//! from keying on `product_id` to `variant_id`, +//! 4. snapshots the variant onto `order_items`, +//! 5. drops the now-moved purchasable columns from `products`. + +use sea_orm_migration::prelude::*; + +#[derive(DeriveMigrationName)] +pub struct Migration; + +#[async_trait::async_trait] +impl MigrationTrait for Migration { + async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> { + let db = m.get_connection(); + + // 1. The variants table. + db.execute_unprepared( + r#" + CREATE TABLE product_variants ( + id SERIAL PRIMARY KEY, + created_at TIMESTAMPTZ NOT NULL DEFAULT now(), + updated_at TIMESTAMPTZ NOT NULL DEFAULT now(), + product_id INTEGER NOT NULL REFERENCES products(id) ON DELETE CASCADE, + label VARCHAR NOT NULL DEFAULT '', + position INTEGER NOT NULL DEFAULT 0, + sku VARCHAR, + stock INTEGER NOT NULL DEFAULT 0, + price_cents BIGINT NOT NULL, + sale_price_cents BIGINT, + business_sale_price_cents BIGINT + ); + CREATE INDEX idx_product_variants_product ON product_variants (product_id); + "#, + ) + .await?; + + // 2. One variant per existing product, carrying its current pricing. + db.execute_unprepared( + r#" + INSERT INTO product_variants + (product_id, label, position, sku, stock, + price_cents, sale_price_cents, business_sale_price_cents) + SELECT id, '', 0, sku, stock, + price_cents, sale_price_cents, business_sale_price_cents + FROM products; + "#, + ) + .await?; + + // 3a. Negotiated prices: product_id -> variant_id. + db.execute_unprepared( + r#" + ALTER TABLE account_product_prices ADD COLUMN variant_id INTEGER; + UPDATE account_product_prices a + SET variant_id = pv.id + FROM product_variants pv + WHERE pv.product_id = a.product_id; + DROP INDEX IF EXISTS idx_account_product_prices_user_product_unique; + ALTER TABLE account_product_prices DROP COLUMN product_id; + ALTER TABLE account_product_prices ALTER COLUMN variant_id SET NOT NULL; + ALTER TABLE account_product_prices + ADD CONSTRAINT fk_account_product_prices_variant + FOREIGN KEY (variant_id) REFERENCES product_variants(id) ON DELETE CASCADE; + CREATE UNIQUE INDEX idx_account_product_prices_user_variant_unique + ON account_product_prices (user_id, variant_id); + "#, + ) + .await?; + + // 3b. Collision resolutions: product_id -> variant_id. + db.execute_unprepared( + r#" + ALTER TABLE account_product_resolutions ADD COLUMN variant_id INTEGER; + UPDATE account_product_resolutions a + SET variant_id = pv.id + FROM product_variants pv + WHERE pv.product_id = a.product_id; + DROP INDEX IF EXISTS idx_account_product_resolutions_unique; + ALTER TABLE account_product_resolutions DROP COLUMN product_id; + ALTER TABLE account_product_resolutions ALTER COLUMN variant_id SET NOT NULL; + ALTER TABLE account_product_resolutions + ADD CONSTRAINT fk_account_product_resolutions_variant + FOREIGN KEY (variant_id) REFERENCES product_variants(id) ON DELETE CASCADE; + CREATE UNIQUE INDEX idx_account_product_resolutions_unique + ON account_product_resolutions (user_id, variant_id); + "#, + ) + .await?; + + // 4. Snapshot the variant on order lines (label is frozen at order time; + // the FK is nullable + SET NULL so deleting a variant keeps history). + db.execute_unprepared( + r#" + ALTER TABLE order_items ADD COLUMN variant_label VARCHAR NOT NULL DEFAULT ''; + ALTER TABLE order_items ADD COLUMN variant_id INTEGER + REFERENCES product_variants(id) ON DELETE SET NULL; + "#, + ) + .await?; + + // 5. Drop the purchasable columns now owned by the variant. + db.execute_unprepared( + r#" + ALTER TABLE products DROP COLUMN price_cents; + ALTER TABLE products DROP COLUMN sale_price_cents; + ALTER TABLE products DROP COLUMN business_sale_price_cents; + ALTER TABLE products DROP COLUMN sku; + ALTER TABLE products DROP COLUMN stock; + "#, + ) + .await?; + + Ok(()) + } + + async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> { + let db = m.get_connection(); + + // Restore product columns from each product's first variant. + db.execute_unprepared( + r#" + ALTER TABLE products ADD COLUMN price_cents BIGINT NOT NULL DEFAULT 0; + ALTER TABLE products ADD COLUMN sale_price_cents BIGINT; + ALTER TABLE products ADD COLUMN business_sale_price_cents BIGINT; + ALTER TABLE products ADD COLUMN sku VARCHAR; + ALTER TABLE products ADD COLUMN stock INTEGER NOT NULL DEFAULT 0; + UPDATE products p SET + price_cents = pv.price_cents, + sale_price_cents = pv.sale_price_cents, + business_sale_price_cents = pv.business_sale_price_cents, + sku = pv.sku, + stock = pv.stock + FROM ( + SELECT DISTINCT ON (product_id) product_id, price_cents, + sale_price_cents, business_sale_price_cents, sku, stock + FROM product_variants ORDER BY product_id, position, id + ) pv + WHERE pv.product_id = p.id; + "#, + ) + .await?; + + db.execute_unprepared( + r#" + ALTER TABLE order_items DROP COLUMN variant_id; + ALTER TABLE order_items DROP COLUMN variant_label; + "#, + ) + .await?; + + db.execute_unprepared( + r#" + ALTER TABLE account_product_resolutions ADD COLUMN product_id INTEGER; + UPDATE account_product_resolutions a + SET product_id = pv.product_id + FROM product_variants pv WHERE pv.id = a.variant_id; + DROP INDEX IF EXISTS idx_account_product_resolutions_unique; + ALTER TABLE account_product_resolutions DROP COLUMN variant_id; + ALTER TABLE account_product_resolutions ALTER COLUMN product_id SET NOT NULL; + ALTER TABLE account_product_resolutions + ADD CONSTRAINT fk_account_product_resolutions_product + FOREIGN KEY (product_id) REFERENCES products(id) ON DELETE CASCADE; + CREATE UNIQUE INDEX idx_account_product_resolutions_unique + ON account_product_resolutions (user_id, product_id); + "#, + ) + .await?; + + db.execute_unprepared( + r#" + ALTER TABLE account_product_prices ADD COLUMN product_id INTEGER; + UPDATE account_product_prices a + SET product_id = pv.product_id + FROM product_variants pv WHERE pv.id = a.variant_id; + DROP INDEX IF EXISTS idx_account_product_prices_user_variant_unique; + ALTER TABLE account_product_prices DROP COLUMN variant_id; + ALTER TABLE account_product_prices ALTER COLUMN product_id SET NOT NULL; + ALTER TABLE account_product_prices + ADD CONSTRAINT fk_account_product_prices_product + FOREIGN KEY (product_id) REFERENCES products(id) ON DELETE CASCADE; + CREATE UNIQUE INDEX idx_account_product_prices_user_product_unique + ON account_product_prices (user_id, product_id); + "#, + ) + .await?; + + db.execute_unprepared("DROP TABLE product_variants;").await?; + + Ok(()) + } +} diff --git a/src/controllers/admin_customers.rs b/src/controllers/admin_customers.rs index 5376eaa..295ce03 100644 --- a/src/controllers/admin_customers.rs +++ b/src/controllers/admin_customers.rs @@ -21,7 +21,7 @@ use crate::{ controllers::i18n::current_lang, models::{ account_discount_profiles, account_product_prices, account_product_resolutions, - categories, discount_profiles, products, _entities::users, + categories, discount_profiles, product_variants, products, _entities::users, }, shared::{ guard, @@ -142,16 +142,9 @@ async fn show( .order_by_asc(products::Column::Name) .all(&ctx.db) .await?; - // Two prices per product: - // - the generic business price a freshly-registered company sees (business - // baseline + business-audience profiles, no per-company deals), and - // - this company's effective price (its negotiated price + assigned profiles). - // The effective price is highlighted only when it differs from the generic one. - let business = pricing::audience_price_many(&ctx, &list, BUSINESS_AUDIENCE).await?; - let details = pricing::detail_many(&ctx, &list, Some(&company)).await?; - // Category sidebar tree (counts over the full, unfiltered list) plus the - // active `?category=` filter applied to the rows. + // Category sidebar tree (counts over the full, unfiltered product list) plus + // the active `?category=` filter applied to the rows. let category_ids: Vec> = list.iter().map(|p| p.category_id).collect(); let category_groups = view::admin_category_groups(&all_categories, &category_ids); let selected_category = params @@ -161,15 +154,43 @@ async fn show( .to_string(); let filter = view::category_filter_ids(&all_categories, &selected_category); - let rows: Vec = list + // Pricing is per variant. Flatten the (filtered) products into their variants + // in product-name then variant-position order, carrying each variant's + // product for the row's display name. + let product_ids: Vec = list.iter().map(|p| p.id).collect(); + let grouped = product_variants::Entity::grouped_for_products(&ctx.db, &product_ids).await?; + let mut variant_rows: Vec<(&products::Model, product_variants::Model)> = Vec::new(); + for product in &list { + if !view::category_filter_keep(&filter, product.category_id) { + continue; + } + if let Some(variants) = grouped.get(&product.id) { + for variant in variants { + variant_rows.push((product, variant.clone())); + } + } + } + + // Two prices per variant: + // - the generic business price a freshly-registered company sees (business + // baseline + business-audience profiles, no per-company deals), and + // - this company's effective price (its negotiated price + assigned profiles). + // The effective price is highlighted only when it differs from the generic one. + let variants_only: Vec = + variant_rows.iter().map(|(_, v)| v.clone()).collect(); + let business = pricing::audience_price_variants(&ctx, &variants_only, BUSINESS_AUDIENCE).await?; + let details = pricing::detail_variants(&ctx, &variants_only, Some(&company)).await?; + + let rows: Vec = variant_rows .iter() .zip(business.iter()) .zip(details.iter()) - .filter(|((product, _), _)| view::category_filter_keep(&filter, product.category_id)) - .map(|((product, b), d)| { + .map(|(((product, variant), b), d)| { json!({ "product_id": product.id, + "variant_id": variant.id, "name": product.name, + "variant_label": variant.label, "currency": product.currency, "regular_price": format_price(d.regular_cents), "business_price": format_price(b.price_cents), @@ -207,22 +228,27 @@ async fn price_edit( auth: auth::JWT, jar: CookieJar, ViewEngine(v): ViewEngine, - Path((id, product_id)): Path<(i32, i32)>, + Path((id, variant_id)): Path<(i32, i32)>, Query(params): Query>, State(ctx): State, ) -> Result { guard::current_admin(auth, &ctx).await?; let company = company_by_id(&ctx, id).await?; - let product = products::Entity::find_by_id(product_id) + let variant = product_variants::Entity::find_by_id(variant_id) + .one(&ctx.db) + .await? + .ok_or_else(|| Error::NotFound)?; + let product = products::Entity::find_by_id(variant.product_id) .one(&ctx.db) .await? .ok_or_else(|| Error::NotFound)?; let business = - pricing::audience_price_many(&ctx, std::slice::from_ref(&product), BUSINESS_AUDIENCE) + pricing::audience_price_variants(&ctx, std::slice::from_ref(&variant), BUSINESS_AUDIENCE) .await?; let business_cents = business[0].price_cents; - let detail = pricing::detail_many(&ctx, std::slice::from_ref(&product), Some(&company)).await?; + let detail = + pricing::detail_variants(&ctx, std::slice::from_ref(&variant), Some(&company)).await?; let d = &detail[0]; // Names for the covering profiles, used by the collision resolution selector. @@ -248,7 +274,9 @@ async fn price_edit( "customer": { "id": company.id, "name": company.name }, "product": { "id": product.id, + "variant_id": variant.id, "name": product.name, + "variant_label": variant.label, "currency": product.currency, "regular_price": format_price(d.regular_cents), "regular_cents": d.regular_cents, @@ -271,7 +299,7 @@ async fn price_edit( #[debug_handler] async fn set_price( auth: auth::JWT, - Path((id, product_id)): Path<(i32, i32)>, + Path((id, variant_id)): Path<(i32, i32)>, State(ctx): State, Form(form): Form, ) -> Result { @@ -280,7 +308,7 @@ async fn set_price( let entered = form.price.trim().to_string(); if entered.is_empty() { - account_product_prices::Model::clear(&ctx.db, company.id, product_id).await?; + account_product_prices::Model::clear(&ctx.db, company.id, variant_id).await?; return format::redirect(&format!("/admin/customers/{id}")); } @@ -288,23 +316,23 @@ async fn set_price( Ok(cents) if cents > 0 => cents, _ => { return format::redirect(&format!( - "/admin/customers/{id}/prices/{product_id}/edit?error=discount-must-be-positive" + "/admin/customers/{id}/prices/{variant_id}/edit?error=discount-must-be-positive" )) } }; - account_product_prices::Model::upsert(&ctx.db, company.id, product_id, cents).await?; + account_product_prices::Model::upsert(&ctx.db, company.id, variant_id, cents).await?; format::redirect(&format!("/admin/customers/{id}")) } #[debug_handler] async fn remove_price( auth: auth::JWT, - Path((id, product_id)): Path<(i32, i32)>, + Path((id, variant_id)): Path<(i32, i32)>, State(ctx): State, ) -> Result { guard::current_admin(auth, &ctx).await?; let company = company_by_id(&ctx, id).await?; - account_product_prices::Model::clear(&ctx.db, company.id, product_id).await?; + account_product_prices::Model::clear(&ctx.db, company.id, variant_id).await?; format::redirect(&format!("/admin/customers/{id}")) } @@ -347,7 +375,7 @@ async fn sync_profiles( #[debug_handler] async fn set_resolution( auth: auth::JWT, - Path((id, product_id)): Path<(i32, i32)>, + Path((id, variant_id)): Path<(i32, i32)>, State(ctx): State, Form(form): Form, ) -> Result { @@ -356,14 +384,14 @@ async fn set_resolution( let existing = account_product_resolutions::Entity::find() .filter(account_product_resolutions::Column::UserId.eq(company.id)) - .filter(account_product_resolutions::Column::ProductId.eq(product_id)) + .filter(account_product_resolutions::Column::VariantId.eq(variant_id)) .one(&ctx.db) .await?; let mut active = match existing { Some(row) => row.into_active_model(), None => account_product_resolutions::ActiveModel { user_id: Set(company.id), - product_id: Set(product_id), + variant_id: Set(variant_id), ..Default::default() }, }; @@ -378,16 +406,16 @@ pub fn routes() -> Routes { .add("/admin/customers/{id}", get(show)) .add("/admin/customers/{id}/profiles", post(sync_profiles)) .add( - "/admin/customers/{id}/prices/{product_id}/edit", + "/admin/customers/{id}/prices/{variant_id}/edit", get(price_edit), ) - .add("/admin/customers/{id}/prices/{product_id}", post(set_price)) + .add("/admin/customers/{id}/prices/{variant_id}", post(set_price)) .add( - "/admin/customers/{id}/prices/{product_id}/remove", + "/admin/customers/{id}/prices/{variant_id}/remove", post(remove_price), ) .add( - "/admin/customers/{id}/resolutions/{product_id}", + "/admin/customers/{id}/resolutions/{variant_id}", post(set_resolution), ) } diff --git a/src/controllers/admin_form.rs b/src/controllers/admin_form.rs index 20acdd0..cfd5d69 100644 --- a/src/controllers/admin_form.rs +++ b/src/controllers/admin_form.rs @@ -38,6 +38,23 @@ impl MultipartForm { Some("on" | "true" | "1") ) } + + /// The distinct row indices `N` present among `variants[N][...]` fields, + /// sorted ascending. Used to read the repeated variant rows of the product + /// form (each row's fields are uniquely keyed, so the HashMap keeps them all). + pub(crate) fn variant_indices(&self) -> Vec { + let mut idx: Vec = self + .fields + .keys() + .filter_map(|k| { + let rest = k.strip_prefix("variants[")?; + rest.split(']').next()?.parse::().ok() + }) + .collect(); + idx.sort_unstable(); + idx.dedup(); + idx + } } pub(crate) async fn read_multipart_form(mut multipart: Multipart) -> Result { diff --git a/src/controllers/admin_products.rs b/src/controllers/admin_products.rs index c71da28..1a062b9 100644 --- a/src/controllers/admin_products.rs +++ b/src/controllers/admin_products.rs @@ -1,4 +1,11 @@ //! Admin product CRUD. +//! +//! A product is a presentation grouping; its purchasable options live in +//! `product_variants` (each with its own label, sku, stock, regular price and +//! optional public/business quick-sale prices), edited inline on the product +//! form. The products list and the per-audience percentage discount profiles +//! operate at the product level, previewing prices on each product's +//! representative (first) variant. use std::collections::{HashMap, HashSet}; @@ -9,7 +16,6 @@ use sea_orm::{ ActiveModelTrait, ColumnTrait, EntityTrait, ModelTrait, PaginatorTrait, QueryFilter, QueryOrder, Set, TransactionTrait, }; -use serde::Deserialize; use serde_json::json; use crate::{ @@ -20,12 +26,13 @@ use crate::{ }, shared::{ guard, - money::{format_bp, format_price, parse_percent, parse_price_to_cents}, + money::{format_bp, format_price, parse_price_to_cents}, pricing, slug::{slugify, unique_slug}, }, models::{ - audience_discount_profiles, categories, discount_profiles, product_images, products, + audience_discount_profiles, categories, discount_profiles, product_images, + product_variants, products, }, views::shop as view, }; @@ -45,10 +52,7 @@ struct ProductFields { name: String, slug: String, description: Option, - price_cents: i64, currency: String, - sku: Option, - stock: i32, category_id: Option, published: bool, } @@ -61,19 +65,8 @@ async fn parse_product_fields( let name = form .text("name") .ok_or_else(|| Error::BadRequest("product name is required".to_string()))?; - let price_cents = parse_price_to_cents( - form.text("price") - .ok_or_else(|| Error::BadRequest("price is required".to_string()))? - .as_str(), - )?; let currency = form.text("currency").unwrap_or_else(|| "EUR".to_string()); let description = form.text("description"); - let sku = form.text("sku"); - let stock = form - .text("stock") - .and_then(|s| s.parse::().ok()) - .filter(|n| *n >= 0) - .unwrap_or(0); let category_id = form.text("category_id").and_then(|s| s.parse::().ok()); let published = form.checked("published"); @@ -98,15 +91,150 @@ async fn parse_product_fields( name, slug, description, - price_cents, currency, - sku, - stock, category_id, published, }) } +/// One variant row parsed from the product form. +struct VariantInput { + id: Option, + label: String, + sku: Option, + stock: i32, + price_cents: i64, + sale_cents: Option, + business_sale_cents: Option, + position: i32, +} + +/// An optional price field on a variant row (sale / business sale): blank means +/// "no quick-sale", a value must parse and be below the regular price. +fn parse_optional_sale( + form: &MultipartForm, + i: usize, + key: &str, + price_cents: i64, +) -> Result> { + let Some(raw) = form.text(&format!("variants[{i}][{key}]")) else { + return Ok(None); + }; + let cents = parse_price_to_cents(&raw)?; + if cents <= 0 || cents >= price_cents { + return Err(Error::BadRequest( + "a sale price must be positive and below the regular price".to_string(), + )); + } + Ok(Some(cents)) +} + +/// Parse the repeated variant rows from the form, in submission order. Blank +/// rows (no price and no label) are skipped; at least one valid row is required. +fn parse_variants(form: &MultipartForm) -> Result> { + let mut out = Vec::new(); + for i in form.variant_indices() { + let label = form + .text(&format!("variants[{i}][label]")) + .unwrap_or_default(); + let price_raw = form.text(&format!("variants[{i}][price]")); + + let Some(price_raw) = price_raw else { + // A completely empty leftover row is ignored; a labelled row without + // a price is a mistake worth reporting. + if label.is_empty() { + continue; + } + return Err(Error::BadRequest( + "each option needs a price".to_string(), + )); + }; + let price_cents = parse_price_to_cents(&price_raw)?; + if price_cents <= 0 { + return Err(Error::BadRequest( + "an option price must be positive".to_string(), + )); + } + + let sku = form.text(&format!("variants[{i}][sku]")); + let stock = form + .text(&format!("variants[{i}][stock]")) + .and_then(|s| s.parse::().ok()) + .filter(|n| *n >= 0) + .unwrap_or(0); + let sale_cents = parse_optional_sale(form, i, "sale", price_cents)?; + let business_sale_cents = parse_optional_sale(form, i, "business_sale", price_cents)?; + let id = form + .text(&format!("variants[{i}][id]")) + .and_then(|s| s.parse::().ok()); + + out.push(VariantInput { + id, + label, + sku, + stock, + price_cents, + sale_cents, + business_sale_cents, + position: out.len() as i32, + }); + } + if out.is_empty() { + return Err(Error::BadRequest( + "add at least one option with a price".to_string(), + )); + } + Ok(out) +} + +/// Apply a parsed variant row onto a (new or existing) active model. +fn apply_variant(active: &mut product_variants::ActiveModel, input: &VariantInput) { + active.label = Set(input.label.clone()); + active.sku = Set(input.sku.clone()); + active.stock = Set(input.stock); + active.price_cents = Set(input.price_cents); + active.sale_price_cents = Set(input.sale_cents); + active.business_sale_price_cents = Set(input.business_sale_cents); + active.position = Set(input.position); +} + +/// Reconcile the product's variants with the submitted rows inside `txn`: update +/// rows carrying an id, insert rows without one, and delete existing variants no +/// longer present. +async fn sync_variants( + txn: &C, + product_id: i32, + inputs: &[VariantInput], +) -> Result<()> { + let existing = product_variants::Entity::for_product(txn, product_id).await?; + let keep: HashSet = inputs.iter().filter_map(|v| v.id).collect(); + for variant in &existing { + if !keep.contains(&variant.id) { + variant.clone().delete(txn).await?; + } + } + let by_id: HashMap = + existing.into_iter().map(|v| (v.id, v)).collect(); + for input in inputs { + match input.id.and_then(|id| by_id.get(&id)) { + Some(model) => { + let mut active = model.clone().into_active_model(); + apply_variant(&mut active, input); + active.update(txn).await?; + } + None => { + let mut active = product_variants::ActiveModel { + product_id: Set(product_id), + ..Default::default() + }; + apply_variant(&mut active, input); + active.insert(txn).await?; + } + } + } + Ok(()) +} + async fn form_context(ctx: &AppContext, jar: &CookieJar) -> Result { let categories = categories::Entity::find() .order_by_asc(categories::Column::Position) @@ -116,6 +244,19 @@ async fn form_context(ctx: &AppContext, jar: &CookieJar) -> Result serde_json::Value { + json!({ + "id": variant.id, + "label": variant.label, + "sku": variant.sku, + "stock": variant.stock, + "price": format_price(variant.price_cents), + "sale": variant.sale_price_cents.map(format_price), + "business_sale": variant.business_sale_price_cents.map(format_price), + }) +} + #[debug_handler] async fn index( auth: auth::JWT, @@ -140,9 +281,8 @@ async fn index( .order_by_desc(products::Column::CreatedAt) .all(&ctx.db) .await?; - // Effective price each product carries for the active audience, after the - // global per-product discount and any profiles assigned to that audience. - let effective = pricing::audience_price_many(&ctx, &list, audience).await?; + let ids: Vec = list.iter().map(|p| p.id).collect(); + let grouped = product_variants::Entity::grouped_for_products(&ctx.db, &ids).await?; // Category sidebar tree (counts over the full, unfiltered list) plus the // active `?category=` filter applied to the rows. @@ -155,16 +295,38 @@ async fn index( .to_string(); let filter = view::category_filter_ids(&all_categories, &selected_category); - let mut rows = Vec::new(); - for (product, priced) in list.iter().zip(effective.iter()) { + // The kept products with their representative (first) variant, priced in one + // batch for the active audience. + let mut kept: Vec<(&products::Model, &Vec)> = Vec::new(); + for product in &list { if !view::category_filter_keep(&filter, product.category_id) { continue; } + if let Some(variants) = grouped.get(&product.id) { + if !variants.is_empty() { + kept.push((product, variants)); + } + } + } + let reps: Vec = + kept.iter().map(|(_, vs)| vs[0].clone()).collect(); + let effective = pricing::audience_price_variants(&ctx, &reps, audience).await?; + + let mut rows = Vec::new(); + for ((product, variants), priced) in kept.iter().zip(effective.iter()) { let image = product_images::first_for(&ctx, product.id).await?; let category_name = product .category_id .and_then(|id| category_name.get(&id).cloned()); - rows.push(product_row(product, priced, image, category_name, audience)); + let total_stock: i32 = variants.iter().map(|v| v.stock).sum(); + rows.push(product_row( + product, + priced, + variants.len(), + total_stock, + image, + category_name, + )); } format::view( @@ -183,32 +345,32 @@ async fn index( ) } -/// List-row shape: the product card fields plus the active audience's per-product -/// discount and its resolved effective price (after profiles). +/// List-row shape: the product card fields plus its representative variant's +/// resolved effective price (after the active audience's profiles) and the count +/// of options. fn product_row( product: &products::Model, effective: &pricing::PricedProduct, + variant_count: usize, + total_stock: i32, image: Option, category_name: Option, - audience: &str, ) -> serde_json::Value { - let sale = current_value(product, audience); json!({ "id": product.id, "name": product.name, "slug": product.slug, "currency": product.currency, - "stock": product.stock, + "stock": total_stock, + "variant_count": variant_count, + "has_options": variant_count > 1, "published": product.published, "image": image, "category_name": category_name, - "regular_price": format_price(product.price_cents), - "on_sale": sale.is_some(), - "sale_price": sale.map(format_price), - "percent_off": sale.map(|s| percent_off(product.price_cents, s)), + "regular_price": format_price(effective.regular_cents), "effective_price": format_price(effective.price_cents), "effective_reduced": effective.is_reduced(), - "effective_percent_off": percent_off(product.price_cents, effective.price_cents), + "effective_percent_off": percent_off(effective.regular_cents, effective.price_cents), }) } @@ -252,6 +414,7 @@ async fn new( guard::current_admin(auth, &ctx).await?; let mut context = form_context(&ctx, &jar).await?; context["product"] = serde_json::Value::Null; + context["variants"] = json!([]); format::view(&v, "admin/catalog/product_form.html", context) } @@ -264,23 +427,23 @@ async fn create( guard::current_admin(auth, &ctx).await?; let form = read_multipart_form(multipart).await?; let fields = parse_product_fields(&ctx, &form, None).await?; + let variants = parse_variants(&form)?; + let txn = ctx.db.begin().await?; let product = products::ActiveModel { name: Set(fields.name), slug: Set(fields.slug), description: Set(fields.description), - price_cents: Set(fields.price_cents), currency: Set(fields.currency), - sku: Set(fields.sku), - stock: Set(fields.stock), view_count: Set(0), published: Set(fields.published), published_at: Set(fields.published.then(|| chrono::Utc::now().into())), category_id: Set(fields.category_id), ..Default::default() } - .insert(&ctx.db) + .insert(&txn) .await?; + sync_variants(&txn, product.id, &variants).await?; if let Some(data) = form.image { let filename = store_image(&ctx, data).await?; @@ -291,9 +454,10 @@ async fn create( alt: Set(None), ..Default::default() } - .insert(&ctx.db) + .insert(&txn) .await?; } + txn.commit().await?; format::redirect("/admin/catalog/products") } @@ -309,8 +473,10 @@ async fn edit( guard::current_admin(auth, &ctx).await?; let product = product_by_id(&ctx, id).await?; let image = product_images::first_for(&ctx, id).await?; + let variants = product_variants::Entity::for_product(&ctx.db, id).await?; let mut context = form_context(&ctx, &jar).await?; context["product"] = view::product_form(&product, image); + context["variants"] = json!(variants.iter().map(variant_form_json).collect::>()); format::view(&v, "admin/catalog/product_form.html", context) } @@ -326,15 +492,14 @@ async fn update( let was_published = existing.published; let form = read_multipart_form(multipart).await?; let fields = parse_product_fields(&ctx, &form, Some(id)).await?; + let variants = parse_variants(&form)?; + let txn = ctx.db.begin().await?; let mut product = existing.into_active_model(); product.name = Set(fields.name); product.slug = Set(fields.slug); product.description = Set(fields.description); - product.price_cents = Set(fields.price_cents); product.currency = Set(fields.currency); - product.sku = Set(fields.sku); - product.stock = Set(fields.stock); product.category_id = Set(fields.category_id); product.published = Set(fields.published); if fields.published && !was_published { @@ -342,7 +507,8 @@ async fn update( } else if !fields.published { product.published_at = Set(None); } - product.update(&ctx.db).await?; + product.update(&txn).await?; + sync_variants(&txn, id, &variants).await?; if let Some(data) = form.image { let filename = store_image(&ctx, data).await?; @@ -354,9 +520,10 @@ async fn update( alt: Set(None), ..Default::default() } - .insert(&ctx.db) + .insert(&txn) .await?; } + txn.commit().await?; format::redirect("/admin/catalog/products") } @@ -372,23 +539,16 @@ async fn delete( format::redirect("/admin/catalog/products") } -// --- Discounts ------------------------------------------------------------- +// --- Discount profiles ----------------------------------------------------- // // Two audiences, switched by an `?audience=` tab on the products page: -// - **personal** (default): the public sale price (`products.sale_price_cents`) -// everyone sees. -// - **business**: a baseline discount for all company accounts -// (`products.business_sale_price_cents`). Per-company profiles/negotiated -// prices still layer on top (lowest price wins). Both are off the regular price. - -#[derive(Debug, Deserialize)] -struct DiscountForm { - /// "fixed" (enter the new price) or "percent" (enter % off). Defaults to - /// fixed for older/JSON callers. - mode: Option, - sale_price: Option, - percent: Option, -} +// - **personal** (default): what everyone sees. +// - **business**: what company accounts see (per-company profiles/negotiated +// prices still layer on top; lowest price wins). +// +// Per-product absolute quick-sale prices live on each variant and are edited in +// the product form. This section is only the reusable *percentage* discount +// profiles assigned to an audience. fn read_audience(params: &HashMap) -> &'static str { match params.get("audience").map(String::as_str) { @@ -397,32 +557,10 @@ fn read_audience(params: &HashMap) -> &'static str { } } -fn current_value(product: &products::Model, audience: &str) -> Option { - if audience == BUSINESS { - product.business_sale_price_cents - } else { - product.sale_price_cents - } -} - -fn set_value(active: &mut products::ActiveModel, audience: &str, value: Option) { - if audience == BUSINESS { - active.business_sale_price_cents = Set(value); - } else { - active.sale_price_cents = Set(value); - } -} - fn list_redirect(audience: &str) -> Result { format::redirect(&format!("/admin/catalog/products?audience={audience}")) } -/// Resolve a percentage off the regular price into a fixed sale price in cents. -fn percent_to_sale_cents(regular_cents: i64, percent: f64) -> i64 { - let off = (regular_cents as f64 * percent / 100.0).round() as i64; - regular_cents - off -} - /// Percent off the regular price, rounded to a whole number. fn percent_off(regular_cents: i64, sale_cents: i64) -> i64 { if regular_cents <= 0 { @@ -432,6 +570,28 @@ fn percent_off(regular_cents: i64, sale_cents: i64) -> i64 { off.round() as i64 } +/// Representative (first) variant for each product in `list`, in the same order, +/// dropping products with no variants. Returns the products kept alongside their +/// representative variant. +async fn representatives<'a>( + ctx: &AppContext, + list: &'a [products::Model], +) -> Result<(Vec<&'a products::Model>, Vec)> { + let ids: Vec = list.iter().map(|p| p.id).collect(); + let grouped = product_variants::Entity::grouped_for_products(&ctx.db, &ids).await?; + let mut products_kept = Vec::new(); + let mut reps = Vec::new(); + for product in list { + if let Some(variants) = grouped.get(&product.id) { + if let Some(first) = variants.first() { + products_kept.push(product); + reps.push(first.clone()); + } + } + } + Ok((products_kept, reps)) +} + /// Preview the effective prices that the submitted (unsaved) checkbox set would /// produce, without persisting anything. Returns OOB ``s that htmx swaps /// into the effective-price column so the admin sees the effect before Save. @@ -461,14 +621,15 @@ async fn profiles_preview( .order_by_desc(products::Column::CreatedAt) .all(&ctx.db) .await?; + let (products_kept, reps) = representatives(&ctx, &list).await?; let effective = - pricing::audience_price_many_preview(&ctx, &list, audience, profile_ids).await?; + pricing::audience_price_variants_preview(&ctx, &reps, audience, profile_ids).await?; let selected_category = params.get("category").map(String::as_str).unwrap_or("all"); let filter = view::category_filter_ids(&all_categories, selected_category); let mut rows = Vec::new(); - for (product, priced) in list.iter().zip(effective.iter()) { + for (product, priced) in products_kept.iter().zip(effective.iter()) { if !view::category_filter_keep(&filter, product.category_id) { continue; } @@ -477,7 +638,7 @@ async fn profiles_preview( "currency": product.currency, "effective_price": format_price(priced.price_cents), "effective_reduced": priced.is_reduced(), - "effective_percent_off": percent_off(product.price_cents, priced.price_cents), + "effective_percent_off": percent_off(priced.regular_cents, priced.price_cents), })); } @@ -523,160 +684,6 @@ async fn sync_profiles( list_redirect(audience) } -/// What to pre-fill the discount form with: the chosen input mode and the raw -/// values for each field, so a rejected submit (or a re-edit) shows what the -/// admin had. -#[derive(Default)] -struct FormPrefill { - mode: String, - fixed: String, - percent: String, -} - -fn render_discount_form( - v: &TeraView, - jar: &CookieJar, - product: &products::Model, - audience: &str, - prefill: &FormPrefill, - error: Option<&str>, -) -> Result { - let mode = if prefill.mode == "percent" { "percent" } else { "fixed" }; - format::view( - v, - "admin/catalog/discount_form.html", - json!({ - "product": { - "id": product.id, - "name": product.name, - "currency": product.currency, - "regular_price": format_price(product.price_cents), - "regular_cents": product.price_cents, - }, - "audience": audience, - "has_discount": current_value(product, audience).is_some(), - "mode": mode, - "fixed": prefill.fixed, - "percent": prefill.percent, - "error": error, - "lang": current_lang(jar), - }), - ) -} - -#[debug_handler] -async fn discount_edit( - auth: auth::JWT, - jar: CookieJar, - ViewEngine(v): ViewEngine, - Path(id): Path, - Query(params): Query>, - State(ctx): State, -) -> Result { - guard::current_admin(auth, &ctx).await?; - let audience = read_audience(¶ms); - let product = product_by_id(&ctx, id).await?; - // Re-editing always opens in fixed mode showing the current price. - let prefill = FormPrefill { - mode: "fixed".to_string(), - fixed: current_value(&product, audience) - .map(format_price) - .unwrap_or_default(), - percent: String::new(), - }; - render_discount_form(&v, &jar, &product, audience, &prefill, None) -} - -#[debug_handler] -async fn discount_update( - auth: auth::JWT, - jar: CookieJar, - ViewEngine(v): ViewEngine, - Path(id): Path, - Query(params): Query>, - State(ctx): State, - Form(form): Form, -) -> Result { - guard::current_admin(auth, &ctx).await?; - let audience = read_audience(¶ms); - let product = product_by_id(&ctx, id).await?; - - let mode = match form.mode.as_deref() { - Some("percent") => "percent", - _ => "fixed", - }; - let fixed = form.sale_price.unwrap_or_default().trim().to_string(); - let percent = form.percent.unwrap_or_default().trim().to_string(); - - let prefill = FormPrefill { - mode: mode.to_string(), - fixed: fixed.clone(), - percent: percent.clone(), - }; - let render_err = - |key: &str| render_discount_form(&v, &jar, &product, audience, &prefill, Some(key)); - - // Resolve the entered discount into a fixed sale price in cents. An empty - // input in the active mode clears the discount (same as the Remove action). - let sale_cents = if mode == "percent" { - if percent.is_empty() { - return clear_discount(&ctx, product, audience).await; - } - let pct = match parse_percent(&percent) { - Some(pct) => pct, - None => return render_err("discount-invalid"), - }; - if pct <= 0.0 || pct >= 100.0 { - return render_err("discount-percent-range"); - } - percent_to_sale_cents(product.price_cents, pct) - } else { - if fixed.is_empty() { - return clear_discount(&ctx, product, audience).await; - } - match parse_price_to_cents(&fixed) { - Ok(cents) => cents, - Err(_) => return render_err("discount-invalid"), - } - }; - - if sale_cents <= 0 { - return render_err("discount-must-be-positive"); - } - if sale_cents >= product.price_cents { - return render_err("discount-below-regular"); - } - - let mut active = product.into_active_model(); - set_value(&mut active, audience, Some(sale_cents)); - active.update(&ctx.db).await?; - list_redirect(audience) -} - -async fn clear_discount( - ctx: &AppContext, - product: products::Model, - audience: &str, -) -> Result { - let mut active = product.into_active_model(); - set_value(&mut active, audience, None); - active.update(&ctx.db).await?; - list_redirect(audience) -} - -#[debug_handler] -async fn discount_remove( - auth: auth::JWT, - Path(id): Path, - Query(params): Query>, - State(ctx): State, -) -> Result { - guard::current_admin(auth, &ctx).await?; - let audience = read_audience(¶ms); - let product = product_by_id(&ctx, id).await?; - clear_discount(&ctx, product, audience).await -} - pub fn routes() -> Routes { let image_limit = DefaultBodyLimit::max(IMAGE_MAX_BYTES + 1024 * 1024); Routes::new() @@ -697,16 +704,4 @@ pub fn routes() -> Routes { post(update).layer(image_limit), ) .add("/admin/catalog/products/{id}/delete", post(delete)) - .add( - "/admin/catalog/products/{id}/discount/edit", - get(discount_edit), - ) - .add( - "/admin/catalog/products/{id}/discount", - post(discount_update), - ) - .add( - "/admin/catalog/products/{id}/discount/remove", - post(discount_remove), - ) } diff --git a/src/controllers/cart.rs b/src/controllers/cart.rs index 909aa2f..a693b98 100644 --- a/src/controllers/cart.rs +++ b/src/controllers/cart.rs @@ -1,4 +1,4 @@ -use crate::{controllers::i18n::current_lang, shared::{guard, money::format_price, pricing}, models::products}; +use crate::{controllers::i18n::current_lang, shared::{guard, money::format_price, pricing}, models::{product_variants, products}}; use axum::{ http::{HeaderMap, StatusCode}, response::Redirect, @@ -15,22 +15,22 @@ const CART_MAX_AGE_DAYS: i64 = 30; #[derive(Debug, Deserialize)] struct AddForm { - product_id: i32, + variant_id: i32, quantity: Option, } #[derive(Debug, Deserialize)] struct UpdateForm { - product_id: i32, + variant_id: i32, quantity: i32, } #[derive(Debug, Deserialize)] struct RemoveForm { - product_id: i32, + variant_id: i32, } -/// Parse the `cart` cookie ("id:qty,id:qty") into `(product_id, quantity)` +/// Parse the `cart` cookie ("id:qty,id:qty") into `(variant_id, quantity)` /// pairs, silently dropping malformed or non-positive entries. pub(crate) fn parse_cart(jar: &CookieJar) -> Vec<(i32, i32)> { let Some(cookie) = jar.get(CART_COOKIE) else { @@ -64,12 +64,23 @@ fn cart_cookie(value: String) -> Cookie<'static> { .build() } -/// Look up a published product, returning its current stock cap. -async fn published_product(ctx: &AppContext, id: i32) -> Result> { - Ok(products::Entity::find_by_id(id) +/// Look up a variant whose product is published, returning the variant together +/// with its parent product (for name/slug/currency). +async fn published_variant( + ctx: &AppContext, + variant_id: i32, +) -> Result> { + let Some(variant) = product_variants::Entity::find_by_id(variant_id) + .one(&ctx.db) + .await? + else { + return Ok(None); + }; + let product = products::Entity::find_by_id(variant.product_id) .filter(products::Column::Published.eq(true)) .one(&ctx.db) - .await?) + .await?; + Ok(product.map(|p| (variant, p))) } #[debug_handler] @@ -79,16 +90,16 @@ async fn add( headers: HeaderMap, Form(form): Form, ) -> Result { - let Some(product) = published_product(&ctx, form.product_id).await? else { + let Some((variant, _product)) = published_variant(&ctx, form.variant_id).await? else { return Err(Error::NotFound); }; let mut items = parse_cart(&jar); let add_qty = form.quantity.unwrap_or(1).max(1); - if let Some(entry) = items.iter_mut().find(|(id, _)| *id == product.id) { - entry.1 = (entry.1 + add_qty).min(product.stock); + if let Some(entry) = items.iter_mut().find(|(id, _)| *id == variant.id) { + entry.1 = (entry.1 + add_qty).min(variant.stock); } else { - items.push((product.id, add_qty.min(product.stock))); + items.push((variant.id, add_qty.min(variant.stock))); } items.retain(|(_, qty)| *qty > 0); @@ -117,14 +128,14 @@ async fn update( headers: HeaderMap, Form(form): Form, ) -> Result { - let stock = published_product(&ctx, form.product_id) + let stock = published_variant(&ctx, form.variant_id) .await? - .map(|p| p.stock) + .map(|(v, _)| v.stock) .unwrap_or(0); let mut items = parse_cart(&jar); let clamped = form.quantity.clamp(0, stock); - if let Some(entry) = items.iter_mut().find(|(id, _)| *id == form.product_id) { + if let Some(entry) = items.iter_mut().find(|(id, _)| *id == form.variant_id) { entry.1 = clamped; } items.retain(|(_, qty)| *qty > 0); @@ -142,7 +153,7 @@ async fn remove( Form(form): Form, ) -> Result { let mut items = parse_cart(&jar); - items.retain(|(id, _)| *id != form.product_id); + items.retain(|(id, _)| *id != form.variant_id); let jar = jar.add(cart_cookie(serialize_cart(&items))); cart_response(&ctx, &v, jar, &headers).await @@ -192,38 +203,40 @@ pub(crate) async fn resolve_cart( // Resolve the cart entries to in-stock products first, then price them all // for the current viewer in one batch (the price depends on who's logged in). let user = guard::current_user(ctx, jar).await; - let mut items: Vec<(products::Model, i32)> = Vec::new(); + let mut items: Vec<(product_variants::Model, products::Model, i32)> = Vec::new(); for (id, qty) in parse_cart(jar) { - let Some(product) = published_product(ctx, id).await? else { + let Some((variant, product)) = published_variant(ctx, id).await? else { continue; }; - let qty = qty.clamp(0, product.stock); + let qty = qty.clamp(0, variant.stock); if qty == 0 { continue; } - items.push((product, qty)); + items.push((variant, product, qty)); } - let products_only: Vec = items.iter().map(|(p, _)| p.clone()).collect(); - let priced = pricing::price_many(ctx, &products_only, user.as_ref()).await?; + let variants_only: Vec = + items.iter().map(|(v, _, _)| v.clone()).collect(); + let priced = pricing::price_variants(ctx, &variants_only, user.as_ref()).await?; let mut lines = Vec::new(); let mut valid = Vec::new(); let mut total: i64 = 0; - for ((product, qty), priced) in items.iter().zip(priced.iter()) { + for ((variant, product, qty), priced) in items.iter().zip(priced.iter()) { let unit_price = priced.price_cents; let line_total = unit_price * i64::from(*qty); total += line_total; - valid.push((product.id, *qty)); + valid.push((variant.id, *qty)); lines.push(json!({ - "id": product.id, + "id": variant.id, "name": product.name, + "variant_label": variant.label, "slug": product.slug, "price": format_price(unit_price), "regular_price": format_price(priced.regular_cents), "on_sale": priced.is_reduced(), "currency": product.currency, "quantity": qty, - "stock": product.stock, + "stock": variant.stock, "line_total": format_price(line_total), })); } diff --git a/src/controllers/shop.rs b/src/controllers/shop.rs index 2899c92..a5682da 100644 --- a/src/controllers/shop.rs +++ b/src/controllers/shop.rs @@ -9,22 +9,40 @@ use serde_json::json; use crate::{ controllers::i18n::current_lang, shared::{guard, pricing}, - models::{categories, product_images, products, users}, + models::{categories, product_images, product_variants, products, users}, views::shop as view, }; -/// Shape a list of products into card rows for `user` (None = public), pricing -/// each via [`pricing::price_many`] and loading its primary image. +/// Shape a list of products into card rows for `user` (None = public). Each card +/// shows the resolved price of the product's representative (first) variant; the +/// `variant_count` lets the template render "from {price}" for multi-variant +/// products. Products with no variants are skipped (not purchasable). async fn product_rows( ctx: &AppContext, user: Option<&users::Model>, list: Vec, ) -> Result> { - let priced = pricing::price_many(ctx, &list, user).await?; - let mut rows = Vec::with_capacity(list.len()); - for (product, priced) in list.iter().zip(priced.iter()) { + let ids: Vec = list.iter().map(|p| p.id).collect(); + let grouped = product_variants::Entity::grouped_for_products(&ctx.db, &ids).await?; + + // Representative (first) variant per product, in list order, dropping any + // product that has no variants. + let mut entries: Vec<(&products::Model, product_variants::Model, usize)> = Vec::new(); + for product in &list { + if let Some(variants) = grouped.get(&product.id) { + if let Some(first) = variants.first() { + entries.push((product, first.clone(), variants.len())); + } + } + } + + let reps: Vec = entries.iter().map(|(_, v, _)| v.clone()).collect(); + let priced = pricing::price_variants(ctx, &reps, user).await?; + + let mut rows = Vec::with_capacity(entries.len()); + for ((product, rep, count), priced) in entries.iter().zip(priced.iter()) { let image = product_images::first_for(ctx, product.id).await?; - rows.push(view::product_card(product, priced, image, None)); + rows.push(view::product_card(product, rep, priced, *count, image, None)); } Ok(rows) } @@ -121,13 +139,44 @@ async fn show( }; let user = guard::current_user(&ctx, &jar).await; - let priced = pricing::price_for(&ctx, &product, user.as_ref()).await?; + let variants = product_variants::Entity::for_product(&ctx.db, product.id).await?; + let variant_prices = pricing::price_variants(&ctx, &variants, user.as_ref()).await?; + let options: Vec = variants + .iter() + .zip(variant_prices.iter()) + .map(|(variant, priced)| view::variant_option(variant, priced)) + .collect(); + // The card header uses the representative (first) variant for its headline + // price; the picker below lets the customer switch. + let representative = variants.first(); + let priced = variant_prices.first().copied(); + let card = match (representative, priced) { + (Some(rep), Some(priced)) => view::product_card( + &product, + rep, + &priced, + variants.len(), + None, + category.as_ref().map(|c| c.name.clone()), + ), + // A product with no variants isn't purchasable; show it without a price. + _ => serde_json::json!({ + "id": product.id, + "name": product.name, + "slug": product.slug, + "description": product.description, + "currency": product.currency, + "variant_count": 0, + "has_options": false, + }), + }; let c = guard::chrome_from(&ctx, user.as_ref()); format::view( &v, "shop/show.html", json!({ - "product": view::product_card(&product, &priced, None, category.as_ref().map(|c| c.name.clone())), + "product": card, + "variants": options, "images": images.iter().map(|i| i.image_id.clone()).collect::>(), "category": category, "logged_in_admin": c.logged_in_admin, diff --git a/src/models/_entities/account_discount_profiles.rs b/src/models/_entities/account_discount_profiles.rs index a7ed624..8d9bcfd 100644 --- a/src/models/_entities/account_discount_profiles.rs +++ b/src/models/_entities/account_discount_profiles.rs @@ -1,5 +1,4 @@ -//! `SeaORM` Entity assigning a discount profile to a business account. -//! Hand-written to match the `account_discount_profiles` migration. +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.19 use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; @@ -17,14 +16,6 @@ pub struct Model { #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] pub enum Relation { - #[sea_orm( - belongs_to = "super::users::Entity", - from = "Column::UserId", - to = "super::users::Column::Id", - on_update = "Cascade", - on_delete = "Cascade" - )] - Users, #[sea_orm( belongs_to = "super::discount_profiles::Entity", from = "Column::DiscountProfileId", @@ -33,12 +24,14 @@ pub enum Relation { on_delete = "Cascade" )] DiscountProfiles, -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::Users.def() - } + #[sea_orm( + belongs_to = "super::users::Entity", + from = "Column::UserId", + to = "super::users::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + Users, } impl Related for Entity { @@ -46,3 +39,9 @@ impl Related for Entity { Relation::DiscountProfiles.def() } } + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Users.def() + } +} diff --git a/src/models/_entities/account_product_prices.rs b/src/models/_entities/account_product_prices.rs index 50ca349..591691d 100644 --- a/src/models/_entities/account_product_prices.rs +++ b/src/models/_entities/account_product_prices.rs @@ -1,5 +1,4 @@ -//! `SeaORM` Entity for per-account negotiated product prices. Hand-written to -//! match the `account_product_prices` migration (one row per (user, product)). +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.19 use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; @@ -11,13 +10,21 @@ pub struct Model { pub updated_at: DateTimeWithTimeZone, #[sea_orm(primary_key)] pub id: i32, - pub user_id: i32, - pub product_id: i32, pub price_cents: i64, + pub user_id: i32, + pub variant_id: i32, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] pub enum Relation { + #[sea_orm( + belongs_to = "super::product_variants::Entity", + from = "Column::VariantId", + to = "super::product_variants::Column::Id", + on_update = "NoAction", + on_delete = "Cascade" + )] + ProductVariants, #[sea_orm( belongs_to = "super::users::Entity", from = "Column::UserId", @@ -26,14 +33,12 @@ pub enum Relation { on_delete = "Cascade" )] Users, - #[sea_orm( - belongs_to = "super::products::Entity", - from = "Column::ProductId", - to = "super::products::Column::Id", - on_update = "Cascade", - on_delete = "Cascade" - )] - Products, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ProductVariants.def() + } } impl Related for Entity { @@ -41,9 +46,3 @@ impl Related for Entity { Relation::Users.def() } } - -impl Related for Entity { - fn to() -> RelationDef { - Relation::Products.def() - } -} diff --git a/src/models/_entities/account_product_resolutions.rs b/src/models/_entities/account_product_resolutions.rs index 96fd69d..0a65348 100644 --- a/src/models/_entities/account_product_resolutions.rs +++ b/src/models/_entities/account_product_resolutions.rs @@ -1,6 +1,4 @@ -//! `SeaORM` Entity for an account's chosen profile when two assigned profiles -//! cover one product. Hand-written to match the `account_product_resolutions` -//! migration. +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.19 use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; @@ -13,28 +11,12 @@ pub struct Model { #[sea_orm(primary_key)] pub id: i32, pub user_id: i32, - pub product_id: i32, pub discount_profile_id: i32, + pub variant_id: i32, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] pub enum Relation { - #[sea_orm( - belongs_to = "super::users::Entity", - from = "Column::UserId", - to = "super::users::Column::Id", - on_update = "Cascade", - on_delete = "Cascade" - )] - Users, - #[sea_orm( - belongs_to = "super::products::Entity", - from = "Column::ProductId", - to = "super::products::Column::Id", - on_update = "Cascade", - on_delete = "Cascade" - )] - Products, #[sea_orm( belongs_to = "super::discount_profiles::Entity", from = "Column::DiscountProfileId", @@ -43,18 +25,22 @@ pub enum Relation { on_delete = "Cascade" )] DiscountProfiles, -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::Users.def() - } -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::Products.def() - } + #[sea_orm( + belongs_to = "super::product_variants::Entity", + from = "Column::VariantId", + to = "super::product_variants::Column::Id", + on_update = "NoAction", + on_delete = "Cascade" + )] + ProductVariants, + #[sea_orm( + belongs_to = "super::users::Entity", + from = "Column::UserId", + to = "super::users::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + Users, } impl Related for Entity { @@ -62,3 +48,15 @@ impl Related for Entity { Relation::DiscountProfiles.def() } } + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ProductVariants.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Users.def() + } +} diff --git a/src/models/_entities/audience_discount_profiles.rs b/src/models/_entities/audience_discount_profiles.rs index a822891..3edc686 100644 --- a/src/models/_entities/audience_discount_profiles.rs +++ b/src/models/_entities/audience_discount_profiles.rs @@ -1,6 +1,4 @@ -//! `SeaORM` Entity assigning a discount profile to a whole audience (all -//! personal viewers or all company accounts). Hand-written to match the -//! `audience_discount_profiles` migration. +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.19 use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; @@ -12,7 +10,6 @@ pub struct Model { pub updated_at: DateTimeWithTimeZone, #[sea_orm(primary_key)] pub id: i32, - /// "personal" or "business". pub audience: String, pub discount_profile_id: i32, } diff --git a/src/models/_entities/audit_logs.rs b/src/models/_entities/audit_logs.rs index c2d7791..93e618a 100644 --- a/src/models/_entities/audit_logs.rs +++ b/src/models/_entities/audit_logs.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.20 +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.19 use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; diff --git a/src/models/_entities/categories.rs b/src/models/_entities/categories.rs index 286eaa6..469bbcf 100644 --- a/src/models/_entities/categories.rs +++ b/src/models/_entities/categories.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.20 +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.19 use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; @@ -23,8 +23,6 @@ pub struct Model { #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] pub enum Relation { - #[sea_orm(has_many = "super::products::Entity")] - Products, #[sea_orm( belongs_to = "Entity", from = "Column::ParentId", @@ -32,7 +30,9 @@ pub enum Relation { on_update = "Cascade", on_delete = "SetNull" )] - Parent, + SelfRef, + #[sea_orm(has_many = "super::products::Entity")] + Products, } impl Related for Entity { diff --git a/src/models/_entities/customer_profiles.rs b/src/models/_entities/customer_profiles.rs index f9fbd4a..3722382 100644 --- a/src/models/_entities/customer_profiles.rs +++ b/src/models/_entities/customer_profiles.rs @@ -1,5 +1,4 @@ -//! `SeaORM` Entity for customer shipping/contact profiles. Hand-written to match -//! the `customer_profiles` migration (1:1 with `users` via a unique `user_id`). +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.19 use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; @@ -11,18 +10,18 @@ pub struct Model { pub updated_at: DateTimeWithTimeZone, #[sea_orm(primary_key)] pub id: i32, - #[sea_orm(unique)] - pub user_id: i32, - pub company_name: Option, - pub company_id: Option, - pub tax_id: Option, - pub vat_id: Option, pub phone_prefix: Option, pub phone: Option, pub address: Option, pub city: Option, pub zip: Option, pub country: Option, + #[sea_orm(unique)] + pub user_id: i32, + pub company_name: Option, + pub company_id: Option, + pub tax_id: Option, + pub vat_id: Option, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] diff --git a/src/models/_entities/discount_profile_products.rs b/src/models/_entities/discount_profile_products.rs index 6338f63..e600bb1 100644 --- a/src/models/_entities/discount_profile_products.rs +++ b/src/models/_entities/discount_profile_products.rs @@ -1,5 +1,4 @@ -//! `SeaORM` Entity for a discount profile's product membership. Hand-written to -//! match the `discount_profile_products` migration. +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.19 use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; diff --git a/src/models/_entities/discount_profiles.rs b/src/models/_entities/discount_profiles.rs index 776d04d..03928c9 100644 --- a/src/models/_entities/discount_profiles.rs +++ b/src/models/_entities/discount_profiles.rs @@ -1,5 +1,4 @@ -//! `SeaORM` Entity for reusable discount profiles. Hand-written to match the -//! `discount_profiles` migration. +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.19 use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; @@ -12,24 +11,20 @@ pub struct Model { #[sea_orm(primary_key)] pub id: i32, pub name: String, - /// Discount in basis points (5% = 500). pub percent_bp: i32, - /// "include" (covers listed products) or "all_except" (covers all but them). pub scope_type: String, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] pub enum Relation { - #[sea_orm(has_many = "super::discount_profile_products::Entity")] - DiscountProfileProducts, #[sea_orm(has_many = "super::account_discount_profiles::Entity")] AccountDiscountProfiles, -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::DiscountProfileProducts.def() - } + #[sea_orm(has_many = "super::account_product_resolutions::Entity")] + AccountProductResolutions, + #[sea_orm(has_many = "super::audience_discount_profiles::Entity")] + AudienceDiscountProfiles, + #[sea_orm(has_many = "super::discount_profile_products::Entity")] + DiscountProfileProducts, } impl Related for Entity { @@ -37,3 +32,21 @@ impl Related for Entity { Relation::AccountDiscountProfiles.def() } } + +impl Related for Entity { + fn to() -> RelationDef { + Relation::AccountProductResolutions.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::AudienceDiscountProfiles.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::DiscountProfileProducts.def() + } +} diff --git a/src/models/_entities/mod.rs b/src/models/_entities/mod.rs index bba88fa..8e70f89 100644 --- a/src/models/_entities/mod.rs +++ b/src/models/_entities/mod.rs @@ -1,22 +1,23 @@ -//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.20 +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.19 pub mod prelude; pub mod account_discount_profiles; pub mod account_product_prices; -pub mod audience_discount_profiles; pub mod account_product_resolutions; +pub mod audience_discount_profiles; pub mod audit_logs; pub mod categories; +pub mod customer_profiles; pub mod discount_profile_products; pub mod discount_profiles; -pub mod customer_profiles; pub mod o_auth2_sessions; pub mod order_items; pub mod orders; pub mod product_images; pub mod product_product_tags; pub mod product_tags; +pub mod product_variants; pub mod products; pub mod shipping_methods; pub mod users; diff --git a/src/models/_entities/o_auth2_sessions.rs b/src/models/_entities/o_auth2_sessions.rs index 3536d4e..178111f 100644 --- a/src/models/_entities/o_auth2_sessions.rs +++ b/src/models/_entities/o_auth2_sessions.rs @@ -1,6 +1,4 @@ -//! `SeaORM` Entity for loco-oauth2 sessions. Hand-written to match the -//! `o_auth2_sessions` migration (the rest of `_entities/` is codegen; this table -//! is owned by the loco-oauth2 integration). +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.19 use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; @@ -8,12 +6,13 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] #[sea_orm(table_name = "o_auth2_sessions")] pub struct Model { - pub created_at: DateTimeUtc, - pub updated_at: DateTimeUtc, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, #[sea_orm(primary_key)] pub id: i32, + #[sea_orm(unique)] pub session_id: String, - pub expires_at: DateTimeUtc, + pub expires_at: DateTimeWithTimeZone, pub user_id: i32, } diff --git a/src/models/_entities/order_items.rs b/src/models/_entities/order_items.rs index 20b8bb9..578935f 100644 --- a/src/models/_entities/order_items.rs +++ b/src/models/_entities/order_items.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.20 +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.19 use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; @@ -15,6 +15,8 @@ pub struct Model { pub quantity: i32, pub order_id: i32, pub product_id: Option, + pub variant_label: String, + pub variant_id: Option, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] @@ -27,6 +29,14 @@ pub enum Relation { on_delete = "Cascade" )] Orders, + #[sea_orm( + belongs_to = "super::product_variants::Entity", + from = "Column::VariantId", + to = "super::product_variants::Column::Id", + on_update = "NoAction", + on_delete = "SetNull" + )] + ProductVariants, #[sea_orm( belongs_to = "super::products::Entity", from = "Column::ProductId", @@ -43,6 +53,12 @@ impl Related for Entity { } } +impl Related for Entity { + fn to() -> RelationDef { + Relation::ProductVariants.def() + } +} + impl Related for Entity { fn to() -> RelationDef { Relation::Products.def() diff --git a/src/models/_entities/orders.rs b/src/models/_entities/orders.rs index 1cb0e13..3e8712f 100644 --- a/src/models/_entities/orders.rs +++ b/src/models/_entities/orders.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.20 +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.19 use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; @@ -13,17 +13,10 @@ pub struct Model { #[sea_orm(unique)] pub order_number: String, pub email: String, - pub phone: Option, pub customer_name: Option, pub status: String, pub total_cents: i64, pub currency: String, - pub user_id: Option, - pub account_type: String, - pub company_name: Option, - pub company_id: Option, - pub tax_id: Option, - pub vat_id: Option, pub address: Option, pub city: Option, pub zip: Option, @@ -39,6 +32,13 @@ pub struct Model { pub tracking_number: Option, pub shipment_id: Option, pub label_url: Option, + pub phone: Option, + pub account_type: String, + pub company_name: Option, + pub company_id: Option, + pub tax_id: Option, + pub vat_id: Option, + pub user_id: Option, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] diff --git a/src/models/_entities/prelude.rs b/src/models/_entities/prelude.rs index 6b9ebe5..e50216e 100644 --- a/src/models/_entities/prelude.rs +++ b/src/models/_entities/prelude.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.20 +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.19 pub use super::account_discount_profiles::Entity as AccountDiscountProfiles; pub use super::account_product_prices::Entity as AccountProductPrices; @@ -15,6 +15,7 @@ pub use super::orders::Entity as Orders; pub use super::product_images::Entity as ProductImages; pub use super::product_product_tags::Entity as ProductProductTags; pub use super::product_tags::Entity as ProductTags; +pub use super::product_variants::Entity as ProductVariants; pub use super::products::Entity as Products; pub use super::shipping_methods::Entity as ShippingMethods; pub use super::users::Entity as Users; diff --git a/src/models/_entities/product_images.rs b/src/models/_entities/product_images.rs index fc3e673..a5139a1 100644 --- a/src/models/_entities/product_images.rs +++ b/src/models/_entities/product_images.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.20 +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.19 use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; diff --git a/src/models/_entities/product_product_tags.rs b/src/models/_entities/product_product_tags.rs index e096714..5432124 100644 --- a/src/models/_entities/product_product_tags.rs +++ b/src/models/_entities/product_product_tags.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.20 +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.19 use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; diff --git a/src/models/_entities/product_tags.rs b/src/models/_entities/product_tags.rs index f8a0101..e61bbfd 100644 --- a/src/models/_entities/product_tags.rs +++ b/src/models/_entities/product_tags.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.20 +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.19 use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; diff --git a/src/models/_entities/product_variants.rs b/src/models/_entities/product_variants.rs new file mode 100644 index 0000000..1596b92 --- /dev/null +++ b/src/models/_entities/product_variants.rs @@ -0,0 +1,63 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.19 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] +#[sea_orm(table_name = "product_variants")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub product_id: i32, + pub label: String, + pub position: i32, + pub sku: Option, + pub stock: i32, + pub price_cents: i64, + pub sale_price_cents: Option, + pub business_sale_price_cents: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm(has_many = "super::account_product_prices::Entity")] + AccountProductPrices, + #[sea_orm(has_many = "super::account_product_resolutions::Entity")] + AccountProductResolutions, + #[sea_orm(has_many = "super::order_items::Entity")] + OrderItems, + #[sea_orm( + belongs_to = "super::products::Entity", + from = "Column::ProductId", + to = "super::products::Column::Id", + on_update = "NoAction", + on_delete = "Cascade" + )] + Products, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::AccountProductPrices.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::AccountProductResolutions.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::OrderItems.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Products.def() + } +} diff --git a/src/models/_entities/products.rs b/src/models/_entities/products.rs index 43a09a6..0b2475e 100644 --- a/src/models/_entities/products.rs +++ b/src/models/_entities/products.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.20 +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.19 use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; @@ -15,12 +15,7 @@ pub struct Model { pub slug: String, #[sea_orm(column_type = "Text", nullable)] pub description: Option, - pub price_cents: i64, - pub sale_price_cents: Option, - pub business_sale_price_cents: Option, pub currency: String, - pub sku: Option, - pub stock: i32, pub view_count: i32, pub published: bool, pub published_at: Option, @@ -37,12 +32,16 @@ pub enum Relation { on_delete = "SetNull" )] Categories, + #[sea_orm(has_many = "super::discount_profile_products::Entity")] + DiscountProfileProducts, #[sea_orm(has_many = "super::order_items::Entity")] OrderItems, #[sea_orm(has_many = "super::product_images::Entity")] ProductImages, #[sea_orm(has_many = "super::product_product_tags::Entity")] ProductProductTags, + #[sea_orm(has_many = "super::product_variants::Entity")] + ProductVariants, } impl Related for Entity { @@ -51,6 +50,12 @@ impl Related for Entity { } } +impl Related for Entity { + fn to() -> RelationDef { + Relation::DiscountProfileProducts.def() + } +} + impl Related for Entity { fn to() -> RelationDef { Relation::OrderItems.def() @@ -69,6 +74,12 @@ impl Related for Entity { } } +impl Related for Entity { + fn to() -> RelationDef { + Relation::ProductVariants.def() + } +} + impl Related for Entity { fn to() -> RelationDef { super::product_product_tags::Relation::ProductTags.def() diff --git a/src/models/_entities/shipping_methods.rs b/src/models/_entities/shipping_methods.rs index 18aca2a..c7a7424 100644 --- a/src/models/_entities/shipping_methods.rs +++ b/src/models/_entities/shipping_methods.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.20 +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.19 use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; diff --git a/src/models/_entities/users.rs b/src/models/_entities/users.rs index 50857c4..951b0a6 100644 --- a/src/models/_entities/users.rs +++ b/src/models/_entities/users.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.20 +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.19 use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; @@ -26,15 +26,45 @@ pub struct Model { pub magic_link_expiration: Option, pub theme: String, pub account_type: String, + #[sea_orm(column_type = "Text", nullable)] pub totp_secret: Option, pub totp_enabled_at: Option, + #[sea_orm(column_type = "Text", nullable)] pub totp_backup_codes: Option, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] pub enum Relation { + #[sea_orm(has_many = "super::account_discount_profiles::Entity")] + AccountDiscountProfiles, + #[sea_orm(has_many = "super::account_product_prices::Entity")] + AccountProductPrices, + #[sea_orm(has_many = "super::account_product_resolutions::Entity")] + AccountProductResolutions, #[sea_orm(has_many = "super::audit_logs::Entity")] AuditLogs, + #[sea_orm(has_one = "super::customer_profiles::Entity")] + CustomerProfiles, + #[sea_orm(has_many = "super::o_auth2_sessions::Entity")] + OAuth2Sessions, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::AccountDiscountProfiles.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::AccountProductPrices.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::AccountProductResolutions.def() + } } impl Related for Entity { @@ -42,3 +72,15 @@ impl Related for Entity { Relation::AuditLogs.def() } } + +impl Related for Entity { + fn to() -> RelationDef { + Relation::CustomerProfiles.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::OAuth2Sessions.def() + } +} diff --git a/src/models/account_product_prices.rs b/src/models/account_product_prices.rs index 2baeb67..4605cc6 100644 --- a/src/models/account_product_prices.rs +++ b/src/models/account_product_prices.rs @@ -25,7 +25,7 @@ impl ActiveModelBehavior for ActiveModel { } impl Model { - /// All negotiated prices for one account, as a `(product_id -> cents)` map. + /// All negotiated prices for one account, as a `(variant_id -> cents)` map. pub async fn map_for_user( db: &DatabaseConnection, user_id: i32, @@ -34,26 +34,26 @@ impl Model { .filter(Column::UserId.eq(user_id)) .all(db) .await?; - Ok(rows.into_iter().map(|r| (r.product_id, r.price_cents)).collect()) + Ok(rows.into_iter().map(|r| (r.variant_id, r.price_cents)).collect()) } - /// Insert or update the negotiated price for `(user_id, product_id)`. + /// Insert or update the negotiated price for `(user_id, variant_id)`. pub async fn upsert( db: &DatabaseConnection, user_id: i32, - product_id: i32, + variant_id: i32, price_cents: i64, ) -> Result { let existing = Entity::find() .filter(Column::UserId.eq(user_id)) - .filter(Column::ProductId.eq(product_id)) + .filter(Column::VariantId.eq(variant_id)) .one(db) .await?; let mut active = match existing { Some(row) => row.into_active_model(), None => ActiveModel { user_id: ActiveValue::set(user_id), - product_id: ActiveValue::set(product_id), + variant_id: ActiveValue::set(variant_id), ..Default::default() }, }; @@ -61,15 +61,15 @@ impl Model { active.save(db).await?.try_into_model() } - /// Remove the negotiated price for `(user_id, product_id)`, if any. + /// Remove the negotiated price for `(user_id, variant_id)`, if any. pub async fn clear( db: &DatabaseConnection, user_id: i32, - product_id: i32, + variant_id: i32, ) -> Result<(), DbErr> { Entity::delete_many() .filter(Column::UserId.eq(user_id)) - .filter(Column::ProductId.eq(product_id)) + .filter(Column::VariantId.eq(variant_id)) .exec(db) .await?; Ok(()) diff --git a/src/models/mod.rs b/src/models/mod.rs index 2114454..1b165df 100644 --- a/src/models/mod.rs +++ b/src/models/mod.rs @@ -24,3 +24,4 @@ pub mod product_tags; pub mod products; pub mod shipping_methods; pub mod users; +pub mod product_variants; diff --git a/src/models/o_auth2_sessions.rs b/src/models/o_auth2_sessions.rs index 46e57db..dbfac61 100644 --- a/src/models/o_auth2_sessions.rs +++ b/src/models/o_auth2_sessions.rs @@ -17,7 +17,7 @@ impl ActiveModelBehavior for ActiveModel { { if !insert && self.updated_at.is_unchanged() { let mut this = self; - this.updated_at = sea_orm::ActiveValue::Set(Utc::now()); + this.updated_at = sea_orm::ActiveValue::Set(Utc::now().into()); Ok(this) } else { Ok(self) @@ -34,7 +34,7 @@ impl OAuth2SessionsTrait for Model { .one(db) .await? .ok_or_else(|| ModelError::EntityNotFound)?; - Ok(session.expires_at < Utc::now()) + Ok(session.expires_at < Utc::now().fixed_offset()) } /// Create or refresh the session row for `user` from the provider token. @@ -58,14 +58,14 @@ impl OAuth2SessionsTrait for Model { Some(session) => { let mut session: o_auth2_sessions::ActiveModel = session.into(); session.session_id = ActiveValue::set(session_id); - session.expires_at = ActiveValue::set(expires_at); - session.updated_at = ActiveValue::set(Utc::now()); + session.expires_at = ActiveValue::set(expires_at.into()); + session.updated_at = ActiveValue::set(Utc::now().into()); session.update(&txn).await? } None => { o_auth2_sessions::ActiveModel { session_id: ActiveValue::set(session_id), - expires_at: ActiveValue::set(expires_at), + expires_at: ActiveValue::set(expires_at.into()), user_id: ActiveValue::set(user.id), ..Default::default() } diff --git a/src/models/orders.rs b/src/models/orders.rs index f255c2d..875b33b 100644 --- a/src/models/orders.rs +++ b/src/models/orders.rs @@ -3,7 +3,7 @@ use sea_orm::entity::prelude::*; use sea_orm::{Set, TransactionTrait}; use uuid::Uuid; -use crate::models::_entities::{order_items, products, shipping_methods}; +use crate::models::_entities::{order_items, product_variants, products, shipping_methods}; use crate::models::users; use crate::shared::pricing; pub use crate::models::_entities::orders::{ActiveModel, Column, Entity, Model}; @@ -40,10 +40,10 @@ fn generate_order_number() -> String { format!("ORD-{suffix}") } -/// Atomically place an order for the given `(product_id, quantity)` lines: -/// snapshot each product's price/name, decrement stock (re-checking inside the -/// transaction so an item can't oversell between cart and pay), then write the -/// order and its line items. Returns the persisted order. +/// Atomically place an order for the given `(variant_id, quantity)` lines: +/// snapshot each variant's price/name/label, decrement its stock (re-checking +/// inside the transaction so an item can't oversell between cart and pay), then +/// write the order and its line items. Returns the persisted order. pub async fn place( ctx: &AppContext, items: &[(i32, i32)], @@ -55,13 +55,17 @@ pub async fn place( let mut subtotal: i64 = 0; let mut currency = "EUR".to_string(); let mut snapshots = Vec::new(); - for (product_id, qty) in items { - let product = products::Entity::find_by_id(*product_id) + for (variant_id, qty) in items { + let variant = product_variants::Entity::find_by_id(*variant_id) + .one(&txn) + .await? + .ok_or_else(|| Error::BadRequest("an item is no longer available".to_string()))?; + let product = products::Entity::find_by_id(variant.product_id) .filter(products::Column::Published.eq(true)) .one(&txn) .await? .ok_or_else(|| Error::BadRequest("a product is no longer available".to_string()))?; - if product.stock < *qty { + if variant.stock < *qty { return Err(Error::BadRequest(format!( "not enough stock for {}", product.name @@ -71,14 +75,14 @@ pub async fn place( // Snapshot the price the buyer actually pays — public sale or, for a // business account, their negotiated/lowest price (same resolver the // cart and storefront use). - let unit_price_cents = pricing::price_for(ctx, &product, user).await?.price_cents; + let unit_price_cents = pricing::price_variant(ctx, &variant, user).await?.price_cents; subtotal += unit_price_cents * i64::from(*qty); - let mut active = product.clone().into_active_model(); - active.stock = Set(product.stock - *qty); + let mut active = variant.clone().into_active_model(); + active.stock = Set(variant.stock - *qty); active.update(&txn).await?; - snapshots.push((product.id, product.name, unit_price_cents, *qty)); + snapshots.push((product.id, variant.id, product.name, variant.label, unit_price_cents, *qty)); } let order = ActiveModel { @@ -111,11 +115,13 @@ pub async fn place( .insert(&txn) .await?; - for (product_id, name, unit_price_cents, qty) in snapshots { + for (product_id, variant_id, name, variant_label, unit_price_cents, qty) in snapshots { order_items::ActiveModel { order_id: Set(order.id), product_id: Set(Some(product_id)), + variant_id: Set(Some(variant_id)), product_name: Set(name), + variant_label: Set(variant_label), unit_price_cents: Set(unit_price_cents), quantity: Set(qty), ..Default::default() diff --git a/src/models/product_variants.rs b/src/models/product_variants.rs new file mode 100644 index 0000000..22c8001 --- /dev/null +++ b/src/models/product_variants.rs @@ -0,0 +1,89 @@ +use sea_orm::entity::prelude::*; +use sea_orm::QueryOrder; +pub use super::_entities::product_variants::{ActiveModel, Column, Entity, Model}; +pub type ProductVariants = Entity; + +#[async_trait::async_trait] +impl ActiveModelBehavior for ActiveModel { + async fn before_save(self, _db: &C, insert: bool) -> std::result::Result + where + C: ConnectionTrait, + { + if !insert && self.updated_at.is_unchanged() { + let mut this = self; + this.updated_at = sea_orm::ActiveValue::Set(chrono::Utc::now().into()); + Ok(this) + } else { + Ok(self) + } + } +} + +// implement your read-oriented logic here +impl Model { + /// Whether a discount is currently active: a sale price is set and is + /// strictly below the regular price. + #[must_use] + pub fn on_sale(&self) -> bool { + matches!(self.sale_price_cents, Some(sale) if sale < self.price_cents) + } + + /// The price actually charged: the sale price when [`Model::on_sale`], + /// otherwise the regular price. + #[must_use] + pub fn effective_price_cents(&self) -> i64 { + if self.on_sale() { + self.sale_price_cents.unwrap_or(self.price_cents) + } else { + self.price_cents + } + } + + /// Whether a baseline business discount (for all company accounts) is set and + /// actually below the regular price. + #[must_use] + pub fn business_on_sale(&self) -> bool { + matches!(self.business_sale_price_cents, Some(sale) if sale < self.price_cents) + } +} + +// implement your write-oriented logic here +impl ActiveModel {} + +// implement your custom finders, selectors oriented logic here +impl Entity { + /// All variants for one product, in display order. + pub async fn for_product( + db: &C, + product_id: i32, + ) -> Result, DbErr> { + Entity::find() + .filter(Column::ProductId.eq(product_id)) + .order_by_asc(Column::Position) + .order_by_asc(Column::Id) + .all(db) + .await + } + + /// All variants for many products in one query, grouped by `product_id` and + /// ordered within each group. Products with no variants are absent. + pub async fn grouped_for_products( + db: &C, + product_ids: &[i32], + ) -> Result>, DbErr> { + let mut map: std::collections::HashMap> = std::collections::HashMap::new(); + if product_ids.is_empty() { + return Ok(map); + } + let rows = Entity::find() + .filter(Column::ProductId.is_in(product_ids.to_vec())) + .order_by_asc(Column::Position) + .order_by_asc(Column::Id) + .all(db) + .await?; + for row in rows { + map.entry(row.product_id).or_default().push(row); + } + Ok(map) + } +} diff --git a/src/models/products.rs b/src/models/products.rs index 4a49e90..c311057 100644 --- a/src/models/products.rs +++ b/src/models/products.rs @@ -19,32 +19,7 @@ impl ActiveModelBehavior for ActiveModel { } // implement your read-oriented logic here -impl Model { - /// Whether a discount is currently active: a sale price is set and is - /// strictly below the regular price. - #[must_use] - pub fn on_sale(&self) -> bool { - matches!(self.sale_price_cents, Some(sale) if sale < self.price_cents) - } - - /// The price actually charged: the sale price when [`Model::on_sale`], - /// otherwise the regular price. - #[must_use] - pub fn effective_price_cents(&self) -> i64 { - if self.on_sale() { - self.sale_price_cents.unwrap_or(self.price_cents) - } else { - self.price_cents - } - } - - /// Whether a baseline business discount (for all company accounts) is set and - /// actually below the regular price. - #[must_use] - pub fn business_on_sale(&self) -> bool { - matches!(self.business_sale_price_cents, Some(sale) if sale < self.price_cents) - } -} +impl Model {} // implement your write-oriented logic here impl ActiveModel {} diff --git a/src/seed.rs b/src/seed.rs index 3c0458a..f622871 100644 --- a/src/seed.rs +++ b/src/seed.rs @@ -4,7 +4,7 @@ use loco_rs::prelude::*; use sea_orm::{ActiveModelTrait, ColumnTrait, EntityTrait, QueryFilter, Set}; use crate::{ - models::_entities::{categories, products}, + models::_entities::{categories, product_variants, products}, shared::slug::slugify, }; @@ -157,14 +157,11 @@ pub async fn seed_catalog(ctx: &AppContext) -> Result<()> { let now = chrono::Utc::now(); - products::ActiveModel { + let product = products::ActiveModel { name: Set(item.name.to_string()), slug: Set(product_slug), description: Set(Some(item.description.to_string())), - price_cents: Set(item.price_cents), currency: Set("EUR".to_string()), - sku: Set(item.sku.map(|s| s.to_string())), - stock: Set(item.stock), published: Set(true), published_at: Set(Some(now.into())), category_id: Set(category.map(|c| c.id)), @@ -172,6 +169,20 @@ pub async fn seed_catalog(ctx: &AppContext) -> Result<()> { } .insert(&ctx.db) .await?; + + // Each seed product ships as a single default (unlabelled) variant + // carrying its price/stock/sku. + product_variants::ActiveModel { + product_id: Set(product.id), + label: Set(String::new()), + position: Set(0), + sku: Set(item.sku.map(|s| s.to_string())), + stock: Set(item.stock), + price_cents: Set(item.price_cents), + ..Default::default() + } + .insert(&ctx.db) + .await?; } Ok(()) diff --git a/src/shared/pricing.rs b/src/shared/pricing.rs index 27b1a64..2e913d2 100644 --- a/src/shared/pricing.rs +++ b/src/shared/pricing.rs @@ -19,7 +19,8 @@ use sea_orm::{ColumnTrait, EntityTrait, QueryFilter}; use crate::models::{ account_discount_profiles, account_product_prices, account_product_resolutions, - audience_discount_profiles, discount_profile_products, discount_profiles, products, users, + audience_discount_profiles, discount_profile_products, discount_profiles, product_variants, + users, }; use crate::shared::money::apply_discount_bp; @@ -219,7 +220,7 @@ async fn load_b2b(ctx: &AppContext, user_id: i32) -> Result { .all(&ctx.db) .await? .into_iter() - .map(|r| (r.product_id, r.discount_profile_id)) + .map(|r| (r.variant_id, r.discount_profile_id)) .collect(); Ok(B2bContext { @@ -236,13 +237,16 @@ struct PricingCtx { b2b: Option, } -/// Resolve the per-company automated price for a product: the single covering -/// profile, the admin-resolved winner on a collision, or (unresolved) the -/// biggest discount, flagged. +/// Resolve the per-company automated price for a variant. Discount profiles +/// cover the *product* (`product_id`); the admin's collision resolution is set +/// per *variant* (`variant_id`). Result: the single covering profile, the +/// admin-resolved winner on a collision, or (unresolved) the biggest discount, +/// flagged. fn company_auto( b2b: &B2bContext, regular_cents: i64, product_id: i32, + variant_id: i32, ) -> (Option, Option, bool, Vec) { let covering = b2b.profiles.covering(product_id); let ids: Vec = covering.iter().map(|p| p.id).collect(); @@ -254,7 +258,7 @@ fn company_auto( } else { match b2b .resolutions - .get(&product_id) + .get(&variant_id) .and_then(|rid| covering.iter().find(|p| p.id == *rid).copied()) { Some(resolved) => (resolved, false), @@ -276,12 +280,14 @@ fn company_auto( ) } -fn detail_for(product: &products::Model, pc: &PricingCtx) -> PriceDetail { - let regular = product.price_cents; +fn detail_for_variant(variant: &product_variants::Model, pc: &PricingCtx) -> PriceDetail { + let regular = variant.price_cents; + let product_id = variant.product_id; - // Personal price: public sale + personal-audience profiles, lowest wins. - let personal_sale = product.effective_price_cents(); - let personal_profile = pc.personal.best_price(regular, product.id); + // Personal price: the variant's own public sale + personal-audience profiles + // (which cover the product), lowest wins. + let personal_sale = variant.effective_price_cents(); + let personal_profile = pc.personal.best_price(regular, product_id); let personal_effective = personal_profile .map_or(personal_sale, |p| personal_sale.min(p)); @@ -289,12 +295,13 @@ fn detail_for(product: &products::Model, pc: &PricingCtx) -> PriceDetail { return PriceDetail::public_only(regular, personal_effective); }; - // Business candidates (company accounts only). - let manual = b2b.manual.get(&product.id).copied(); + // Business candidates (company accounts only). The negotiated price is keyed + // to the variant; the baseline business sale lives on the variant. + let manual = b2b.manual.get(&variant.id).copied(); let (auto_cents, auto_profile_id, collision, covering_ids) = - company_auto(b2b, regular, product.id); - let business_global = product.business_sale_price_cents; - let business_profile = pc.business.best_price(regular, product.id); + company_auto(b2b, regular, product_id, variant.id); + let business_global = variant.business_sale_price_cents; + let business_profile = pc.business.best_price(regular, product_id); let business_best = lowest([manual, auto_cents, business_global, business_profile]); let priced = decide(regular, personal_effective, business_best); @@ -328,14 +335,14 @@ async fn load_pricing_ctx(ctx: &AppContext, user: Option<&users::Model>) -> Resu }) } -/// Full breakdowns for many products for `user`, batching per-request lookups. -pub async fn detail_many( +/// Full breakdowns for many variants for `user`, batching per-request lookups. +pub async fn detail_variants( ctx: &AppContext, - list: &[products::Model], + list: &[product_variants::Model], user: Option<&users::Model>, ) -> Result> { let pc = load_pricing_ctx(ctx, user).await?; - Ok(list.iter().map(|p| detail_for(p, &pc)).collect()) + Ok(list.iter().map(|v| detail_for_variant(v, &pc)).collect()) } /// Effective prices for a whole audience using only the global layers (the @@ -343,9 +350,9 @@ pub async fn detail_many( /// no specific company's per-company deals. Used by the discounts admin page to /// preview what each tab's discounts produce. `audience` is "personal" or /// "business". -pub async fn audience_price_many( +pub async fn audience_price_variants( ctx: &AppContext, - list: &[products::Model], + list: &[product_variants::Model], audience: &str, ) -> Result> { let personal = load_audience(ctx, AUDIENCE_PERSONAL).await?; @@ -367,7 +374,7 @@ pub async fn audience_price_many( business, b2b, }; - Ok(list.iter().map(|p| detail_for(p, &pc).priced()).collect()) + Ok(list.iter().map(|v| detail_for_variant(v, &pc).priced()).collect()) } /// Like [`audience_price_many`], but prices against an *unsaved* set of profile @@ -376,9 +383,9 @@ pub async fn audience_price_many( /// checkboxes, before they hit Save. For the business tab the personal layer /// stays the persisted one (businesses get the lower of personal/business), and /// only the business layer is replaced by the previewed selection. -pub async fn audience_price_many_preview( +pub async fn audience_price_variants_preview( ctx: &AppContext, - list: &[products::Model], + list: &[product_variants::Model], audience: &str, selected_profile_ids: Vec, ) -> Result> { @@ -401,26 +408,26 @@ pub async fn audience_price_many_preview( business, b2b, }; - Ok(list.iter().map(|p| detail_for(p, &pc).priced()).collect()) + Ok(list.iter().map(|v| detail_for_variant(v, &pc).priced()).collect()) } -/// Price one product for `user` (`None` = anonymous/public). -pub async fn price_for( +/// Price one variant for `user` (`None` = anonymous/public). +pub async fn price_variant( ctx: &AppContext, - product: &products::Model, + variant: &product_variants::Model, user: Option<&users::Model>, ) -> Result { - let detail = detail_many(ctx, std::slice::from_ref(product), user).await?; + let detail = detail_variants(ctx, std::slice::from_ref(variant), user).await?; Ok(detail[0].priced()) } -/// Price many products for `user`, batching the per-request lookups. -pub async fn price_many( +/// Price many variants for `user`, batching the per-request lookups. +pub async fn price_variants( ctx: &AppContext, - list: &[products::Model], + list: &[product_variants::Model], user: Option<&users::Model>, ) -> Result> { - Ok(detail_many(ctx, list, user) + Ok(detail_variants(ctx, list, user) .await? .iter() .map(PriceDetail::priced) diff --git a/src/views/checkout.rs b/src/views/checkout.rs index 22dc1bc..c28c3ae 100644 --- a/src/views/checkout.rs +++ b/src/views/checkout.rs @@ -12,6 +12,7 @@ pub fn items(items: &[order_items::Model]) -> Vec { .map(|item| { json!({ "product_name": item.product_name, + "variant_label": item.variant_label, "quantity": item.quantity, "unit_price": format_price(item.unit_price_cents), "line_total": format_price(item.unit_price_cents * i64::from(item.quantity)), diff --git a/src/views/shop.rs b/src/views/shop.rs index f326dba..bbf09d9 100644 --- a/src/views/shop.rs +++ b/src/views/shop.rs @@ -2,23 +2,28 @@ use serde_json::{json, Value}; -use crate::models::_entities::{categories, products}; +use crate::models::_entities::{categories, product_variants, products}; use crate::shared::money::format_price; use crate::shared::pricing::PricedProduct; /// Card/list shape for a product: model fields plus the viewer's resolved price -/// (from [`crate::shared::pricing`]), its optional primary image and category. -/// `on_sale` means "render the price as reduced" — driven by the resolved price, -/// so it covers both public sales and business deals; `is_business` flags the -/// latter. +/// for its representative (first) variant, the variant count (so the template can +/// render "from {price}" for multi-variant products), its optional primary image +/// and category. `on_sale` means "render the price as reduced" — driven by the +/// resolved price, so it covers both public sales and business deals; +/// `is_business` flags the latter. `representative` is the variant whose price is +/// shown and whose stock/sku the card exposes. pub fn product_card( product: &products::Model, + representative: &product_variants::Model, priced: &PricedProduct, + variant_count: usize, image: Option, category_name: Option, ) -> Value { json!({ "id": product.id, + "variant_id": representative.id, "name": product.name, "slug": product.slug, "description": product.description, @@ -27,26 +32,41 @@ pub fn product_card( "is_business": priced.is_business, "regular_price": format_price(priced.regular_cents), "currency": product.currency, - "sku": product.sku, - "stock": product.stock, + "sku": representative.sku, + "stock": representative.stock, + "variant_count": variant_count, + "has_options": variant_count > 1, "published": product.published, "image": image, "category_name": category_name, }) } +/// One priced variant row for the product detail page's option picker. +pub fn variant_option(variant: &product_variants::Model, priced: &PricedProduct) -> Value { + json!({ + "id": variant.id, + "label": variant.label, + "sku": variant.sku, + "stock": variant.stock, + "in_stock": variant.stock > 0, + "price": format_price(priced.price_cents), + "on_sale": priced.is_reduced(), + "regular_price": format_price(priced.regular_cents), + "is_business": priced.is_business, + }) +} + /// Shape used to pre-fill the admin product form (exposes `category_id` rather -/// than a resolved name, and the current primary image). +/// than a resolved name, and the current primary image). Variants are supplied +/// separately by the controller. pub fn product_form(product: &products::Model, image: Option) -> Value { json!({ "id": product.id, "name": product.name, "slug": product.slug, "description": product.description, - "price": format_price(product.price_cents), "currency": product.currency, - "sku": product.sku, - "stock": product.stock, "published": product.published, "category_id": product.category_id, "image": image,