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

@ -138,9 +138,11 @@
function update_price(commission: Commission) {
commission.price = 0;
for (let index = 0; index < commission.questions.length; index++) {
const question = commission.questions[index];
for (let index = 0; index < commission.answers.length; index++) {
const answer = commission.answers[index];
const question = commission.questions.filter(value => {
return value['name'] == answer['name'];
})[0];
question['options'].forEach(value => {
if(value['name'] == answer['option']) {
@ -259,7 +261,7 @@
<form class="flex flex-col gap-10" on:change={() => {update_example(commission)}}>
<div class="flex flex-col gap-1">
<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}
<option value={question.name}>{question.name}</option>
{/each}
@ -267,14 +269,35 @@
</div>
{#each commission.questions as question, key}
<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" 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>
{#if question.multiple}
<div class="flex flex-col gap-1">
<label for={commission.answers[key]['option']}>{question.name}</label>
{#each commission.answers.filter(value => { return value['name'] == question.name; }) as answer, key}
<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}
</select>
</div>
<div class="flex gap-1 w-full items-stretch">
<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}
</form>
</div>

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

Loading…
Cancel
Save