refactor(products): remove usage notes and contraindications fields
This commit is contained in:
parent
9df241a6a9
commit
013492ec2b
16 changed files with 54 additions and 179 deletions
|
|
@ -380,8 +380,6 @@
|
|||
"productForm_skinProfile": "Skin profile",
|
||||
"productForm_recommendedFor": "Recommended for skin types",
|
||||
"productForm_targetConcerns": "Target concerns",
|
||||
"productForm_contraindications": "Contraindications (one per line)",
|
||||
"productForm_contraindicationsPlaceholder": "e.g. active rosacea flares",
|
||||
"productForm_ingredients": "Ingredients",
|
||||
"productForm_inciList": "INCI list (one ingredient per line)",
|
||||
"productForm_inciPlaceholder": "Aqua\nGlycerin\nNiacinamide",
|
||||
|
|
|
|||
|
|
@ -394,8 +394,6 @@
|
|||
"productForm_skinProfile": "Profil skóry",
|
||||
"productForm_recommendedFor": "Polecane dla typów skóry",
|
||||
"productForm_targetConcerns": "Problemy docelowe",
|
||||
"productForm_contraindications": "Przeciwwskazania (jedno na linię)",
|
||||
"productForm_contraindicationsPlaceholder": "np. aktywna rosacea",
|
||||
"productForm_ingredients": "Składniki",
|
||||
"productForm_inciList": "Lista INCI (jeden składnik na linię)",
|
||||
"productForm_inciPlaceholder": "Aqua\nGlycerin\nNiacinamide",
|
||||
|
|
|
|||
|
|
@ -133,8 +133,6 @@ export interface ProductParseResponse {
|
|||
actives?: ActiveIngredient[];
|
||||
recommended_for?: string[];
|
||||
targets?: string[];
|
||||
contraindications?: string[];
|
||||
usage_notes?: string;
|
||||
fragrance_free?: boolean;
|
||||
essential_oils_free?: boolean;
|
||||
alcohol_denat_free?: boolean;
|
||||
|
|
|
|||
|
|
@ -173,9 +173,7 @@
|
|||
let minIntervalHours = $state(untrack(() => (product?.min_interval_hours != null ? String(product.min_interval_hours) : '')));
|
||||
let maxFrequencyPerWeek = $state(untrack(() => (product?.max_frequency_per_week != null ? String(product.max_frequency_per_week) : '')));
|
||||
let needleLengthMm = $state(untrack(() => (product?.needle_length_mm != null ? String(product.needle_length_mm) : '')));
|
||||
let usageNotes = $state(untrack(() => product?.usage_notes ?? ''));
|
||||
let inciText = $state(untrack(() => product?.inci?.join('\n') ?? ''));
|
||||
let contraindicationsText = $state(untrack(() => product?.contraindications?.join('\n') ?? ''));
|
||||
let personalToleranceNotes = $state(untrack(() => product?.personal_tolerance_notes ?? ''));
|
||||
|
||||
let recommendedFor = $state<string[]>(untrack(() => [...(product?.recommended_for ?? [])]));
|
||||
|
|
@ -215,7 +213,6 @@
|
|||
if (r.url) url = r.url;
|
||||
if (r.sku) sku = r.sku;
|
||||
if (r.barcode) barcode = r.barcode;
|
||||
if (r.usage_notes) usageNotes = r.usage_notes;
|
||||
if (r.category) category = r.category;
|
||||
if (r.recommended_time) recommendedTime = r.recommended_time;
|
||||
if (r.texture) texture = r.texture;
|
||||
|
|
@ -241,7 +238,6 @@
|
|||
if (r.is_medication != null) isMedication = r.is_medication;
|
||||
if (r.is_tool != null) isTool = r.is_tool;
|
||||
if (r.inci?.length) inciText = r.inci.join('\n');
|
||||
if (r.contraindications?.length) contraindicationsText = r.contraindications.join('\n');
|
||||
if (r.actives?.length) {
|
||||
actives = r.actives.map((a) => ({
|
||||
name: a.name,
|
||||
|
|
@ -415,9 +411,7 @@
|
|||
minIntervalHours,
|
||||
maxFrequencyPerWeek,
|
||||
needleLengthMm,
|
||||
usageNotes,
|
||||
inciText,
|
||||
contraindicationsText,
|
||||
personalToleranceNotes,
|
||||
recommendedFor,
|
||||
targetConcerns,
|
||||
|
|
@ -589,17 +583,6 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-2">
|
||||
<Label for="contraindications">{m["productForm_contraindications"]()}</Label>
|
||||
<textarea
|
||||
id="contraindications"
|
||||
name="contraindications"
|
||||
rows="2"
|
||||
placeholder={m["productForm_contraindicationsPlaceholder"]()}
|
||||
class={textareaClass}
|
||||
bind:value={contraindicationsText}
|
||||
></textarea>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
|
|
@ -737,7 +720,6 @@
|
|||
{@const DetailsSection = mod.default}
|
||||
<DetailsSection
|
||||
visible={editSection === 'details'}
|
||||
{textareaClass}
|
||||
bind:priceAmount
|
||||
bind:priceCurrency
|
||||
bind:sizeMl
|
||||
|
|
@ -746,7 +728,6 @@
|
|||
bind:paoMonths
|
||||
bind:phMin
|
||||
bind:phMax
|
||||
bind:usageNotes
|
||||
bind:minIntervalHours
|
||||
bind:maxFrequencyPerWeek
|
||||
bind:needleLengthMm
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
let {
|
||||
visible = false,
|
||||
textareaClass,
|
||||
priceAmount = $bindable(''),
|
||||
priceCurrency = $bindable('PLN'),
|
||||
sizeMl = $bindable(''),
|
||||
|
|
@ -15,7 +14,6 @@
|
|||
paoMonths = $bindable(''),
|
||||
phMin = $bindable(''),
|
||||
phMax = $bindable(''),
|
||||
usageNotes = $bindable(''),
|
||||
minIntervalHours = $bindable(''),
|
||||
maxFrequencyPerWeek = $bindable(''),
|
||||
needleLengthMm = $bindable(''),
|
||||
|
|
@ -26,7 +24,6 @@
|
|||
computedPriceTierLabel
|
||||
}: {
|
||||
visible?: boolean;
|
||||
textareaClass: string;
|
||||
priceAmount?: string;
|
||||
priceCurrency?: string;
|
||||
sizeMl?: string;
|
||||
|
|
@ -35,7 +32,6 @@
|
|||
paoMonths?: string;
|
||||
phMin?: string;
|
||||
phMax?: string;
|
||||
usageNotes?: string;
|
||||
minIntervalHours?: string;
|
||||
maxFrequencyPerWeek?: string;
|
||||
needleLengthMm?: string;
|
||||
|
|
@ -114,17 +110,6 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-2">
|
||||
<Label for="usage_notes">{m["productForm_usageNotes"]()}</Label>
|
||||
<textarea
|
||||
id="usage_notes"
|
||||
name="usage_notes"
|
||||
rows="2"
|
||||
placeholder={m["productForm_usageNotesPlaceholder"]()}
|
||||
class={textareaClass}
|
||||
bind:value={usageNotes}
|
||||
></textarea>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
|
|
|
|||
|
|
@ -161,8 +161,6 @@ export interface Product {
|
|||
actives?: ActiveIngredient[];
|
||||
recommended_for: SkinType[];
|
||||
targets: SkinConcern[];
|
||||
contraindications: string[];
|
||||
usage_notes?: string;
|
||||
fragrance_free?: boolean;
|
||||
essential_oils_free?: boolean;
|
||||
alcohol_denat_free?: boolean;
|
||||
|
|
|
|||
|
|
@ -41,11 +41,6 @@ function parseOptionalString(v: string | null): string | undefined {
|
|||
return s || undefined;
|
||||
}
|
||||
|
||||
function parseTextList(v: string | null): string[] {
|
||||
if (!v?.trim()) return [];
|
||||
return v.split(/\n/).map((s) => s.trim()).filter(Boolean);
|
||||
}
|
||||
|
||||
function parseEffectProfile(form: FormData): Record<string, number> {
|
||||
const keys = [
|
||||
'hydration_immediate', 'hydration_long_term',
|
||||
|
|
@ -98,7 +93,6 @@ export const actions: Actions = {
|
|||
const leave_on = form.get('leave_on') === 'true';
|
||||
const recommended_for = form.getAll('recommended_for') as string[];
|
||||
const targets = form.getAll('targets') as string[];
|
||||
const contraindications = parseTextList(form.get('contraindications') as string | null);
|
||||
|
||||
const inci_raw = form.get('inci') as string;
|
||||
const inci = inci_raw
|
||||
|
|
@ -113,13 +107,12 @@ export const actions: Actions = {
|
|||
leave_on,
|
||||
recommended_for,
|
||||
targets,
|
||||
contraindications,
|
||||
inci,
|
||||
product_effect_profile: parseEffectProfile(form)
|
||||
};
|
||||
|
||||
// Optional strings
|
||||
for (const field of ['line_name', 'url', 'sku', 'barcode', 'usage_notes', 'personal_tolerance_notes', 'price_currency']) {
|
||||
for (const field of ['line_name', 'url', 'sku', 'barcode', 'personal_tolerance_notes', 'price_currency']) {
|
||||
const v = parseOptionalString(form.get(field) as string | null);
|
||||
body[field] = v ?? null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,11 +29,6 @@ function parseOptionalString(v: string | null): string | undefined {
|
|||
return s || undefined;
|
||||
}
|
||||
|
||||
function parseTextList(v: string | null): string[] {
|
||||
if (!v?.trim()) return [];
|
||||
return v.split(/\n/).map((s) => s.trim()).filter(Boolean);
|
||||
}
|
||||
|
||||
function parseEffectProfile(form: FormData): Record<string, number> {
|
||||
const keys = [
|
||||
'hydration_immediate', 'hydration_long_term',
|
||||
|
|
@ -86,7 +81,6 @@ export const actions: Actions = {
|
|||
const leave_on = form.get('leave_on') === 'true';
|
||||
const recommended_for = form.getAll('recommended_for') as string[];
|
||||
const targets = form.getAll('targets') as string[];
|
||||
const contraindications = parseTextList(form.get('contraindications') as string | null);
|
||||
|
||||
const inci_raw = form.get('inci') as string;
|
||||
const inci = inci_raw
|
||||
|
|
@ -101,13 +95,12 @@ export const actions: Actions = {
|
|||
leave_on,
|
||||
recommended_for,
|
||||
targets,
|
||||
contraindications,
|
||||
inci,
|
||||
product_effect_profile: parseEffectProfile(form)
|
||||
};
|
||||
|
||||
// Optional strings
|
||||
for (const field of ['line_name', 'url', 'sku', 'barcode', 'usage_notes', 'personal_tolerance_notes', 'price_currency']) {
|
||||
for (const field of ['line_name', 'url', 'sku', 'barcode', 'personal_tolerance_notes', 'price_currency']) {
|
||||
const v = parseOptionalString(form.get(field) as string | null);
|
||||
if (v !== undefined) payload[field] = v;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue