|
|
@ -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,15 +269,36 @@
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
{#each commission.questions as question, key}
|
|
|
|
{#each commission.questions as question, key}
|
|
|
|
|
|
|
|
{#if question.multiple}
|
|
|
|
<div class="flex flex-col gap-1">
|
|
|
|
<div class="flex flex-col gap-1">
|
|
|
|
<label for={commission.answers[key]['option']}>{question.name}</label>
|
|
|
|
<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 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}
|
|
|
|
{#each question.options as option}
|
|
|
|
<option value={option.name}>{option.name} | ${option.price}</option>
|
|
|
|
<option value={option.name}>{option.name} | ${option.price}</option>
|
|
|
|
{/each}
|
|
|
|
{/each}
|
|
|
|
</select>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{/each}
|
|
|
|
{/each}
|
|
|
|
|
|
|
|
<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>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|