main^2
Midnight 3 years ago
parent c8f4a6bdab
commit 57874136b5

@ -138,9 +138,11 @@
function update_price(commission: Commission) { function update_price(commission: Commission) {
commission.price = 0; commission.price = 0;
for (let index = 0; index < commission.questions.length; index++) { for (let index = 0; index < commission.answers.length; index++) {
const question = commission.questions[index];
const answer = commission.answers[index]; const answer = commission.answers[index];
const question = commission.questions.filter(value => {
return value['name'] == answer['name'];
})[0];
question['options'].forEach(value => { question['options'].forEach(value => {
if(value['name'] == answer['option']) { if(value['name'] == answer['option']) {
@ -259,7 +261,7 @@
<form class="flex flex-col gap-10" on:change={() => {update_example(commission)}}> <form class="flex flex-col gap-10" on:change={() => {update_example(commission)}}>
<div class="flex flex-col gap-1"> <div class="flex flex-col gap-1">
<label for={commission.type}>Type of commission</label> <label for={commission.type}>Type of commission</label>
<select class="bg-slate-600 p-2 rounded-lg" bind:value={commission.type} on:change={() => {update_commission_type(commission)}}> <select class="bg-slate-600 p-2 rounded-lg hover:bg-slate-500 duration-300" bind:value={commission.type} on:change={() => {update_commission_type(commission)}}>
{#each types as question} {#each types as question}
<option value={question.name}>{question.name}</option> <option value={question.name}>{question.name}</option>
{/each} {/each}
@ -267,14 +269,35 @@
</div> </div>
{#each commission.questions as question, key} {#each commission.questions as question, key}
<div class="flex flex-col gap-1"> {#if question.multiple}
<label for={commission.answers[key]['option']}>{question.name}</label> <div class="flex flex-col gap-1">
<select class="bg-slate-600 p-2 rounded-lg" bind:value={commission.answers[key]['option']} on:change={() => {update_price(commission)}}> <label for={commission.answers[key]['option']}>{question.name}</label>
{#each question.options as option} {#each commission.answers.filter(value => { return value['name'] == question.name; }) as answer, key}
<option value={option.name}>{option.name} | ${option.price}</option> <div class="flex gap-1">
<select class="flex-grow bg-slate-600 p-2 rounded-lg hover:bg-slate-500 duration-300" bind:value={answer['option']} on:change={() => {update_price(commission)}}>
{#each question.options as option}
<option value={option.name}>{option.name} | ${option.price}</option>
{/each}
</select>
</div>
{/each} {/each}
</select> <div class="flex gap-1 w-full items-stretch">
</div> <button type="none" class="w-full bg-slate-600 p-2 rounded-lg hover:bg-slate-500 duration-300" on:click|preventDefault={() => {commission.answers.push({'name': question['name'], 'option': question.options[0]['name']}); commission.answers = commission.answers;}}>Add</button>
{#if commission.answers.filter(value => { return value['name'] == question.name; }).length > 1}
<button type="none" class="w-full bg-slate-600 p-2 rounded-lg hover:bg-slate-500 duration-300" on:click|preventDefault={() => {commission.answers.pop(); commission.answers = commission.answers; }}>Remove</button>
{/if}
</div>
</div>
{:else}
<div class="flex flex-col gap-1">
<label for={commission.answers[key]['option']}>{question.name}</label>
<select class="bg-slate-600 p-2 rounded-lg hover:bg-slate-500 duration-300" bind:value={commission.answers[key]['option']} on:change={() => {update_price(commission)}}>
{#each question.options as option}
<option value={option.name}>{option.name} | ${option.price}</option>
{/each}
</select>
</div>
{/if}
{/each} {/each}
</form> </form>
</div> </div>

@ -233,10 +233,6 @@
"name": "basic", "name": "basic",
"url": "/commissions/fullbodybasic.jpg" "url": "/commissions/fullbodybasic.jpg"
}, },
{
"name": "ultralineart",
"url": "/commissions/fullbodyultralineart.jpg"
},
{ {
"name": "basiclineless", "name": "basiclineless",
"url": "/commissions/fullbodybasiclineless.jpg" "url": "/commissions/fullbodybasiclineless.jpg"
@ -266,7 +262,6 @@
}, },
{ {
"name": "Ultra Lineart", "name": "Ultra Lineart",
"example": "ultralineart",
"price": 45 "price": 45
} }
] ]
@ -344,6 +339,7 @@
}, },
{ {
"name": "Additions", "name": "Additions",
"multiple": true,
"options": [ "options": [
{ {
"name": "None", "name": "None",

Loading…
Cancel
Save