mirror of
https://github.com/revanced/revanced-website.git
synced 2025-04-30 06:34:35 +02:00
feat: handle submitted state
This commit is contained in:
parent
065e09ee00
commit
0602ec3824
@ -30,6 +30,7 @@
|
|||||||
let max = logoAmount;
|
let max = logoAmount;
|
||||||
let token = '';
|
let token = '';
|
||||||
let submit = false;
|
let submit = false;
|
||||||
|
let submitted = false;
|
||||||
$: finalPage = currentPage >= logoPages;
|
$: finalPage = currentPage >= logoPages;
|
||||||
$: min = currentPage * logoAmount;
|
$: min = currentPage * logoAmount;
|
||||||
$: max = min + logoAmount;
|
$: max = min + logoAmount;
|
||||||
@ -151,9 +152,12 @@
|
|||||||
},
|
},
|
||||||
body: JSON.stringify(data)
|
body: JSON.stringify(data)
|
||||||
});
|
});
|
||||||
if (!response.ok) {
|
|
||||||
|
if (response.ok) submitted = true;
|
||||||
|
else {
|
||||||
throw Error(`Status Code ${response.status}: ${await response.text()}`);
|
throw Error(`Status Code ${response.status}: ${await response.text()}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const json = await response.json();
|
const json = await response.json();
|
||||||
|
|
||||||
if (!json.cast) {
|
if (!json.cast) {
|
||||||
@ -222,6 +226,8 @@
|
|||||||
<svelte:fragment slot="title">
|
<svelte:fragment slot="title">
|
||||||
{#if submit}
|
{#if submit}
|
||||||
Submitting
|
Submitting
|
||||||
|
{:else if submitted}
|
||||||
|
Vote casted
|
||||||
{:else}
|
{:else}
|
||||||
Confirm submission
|
Confirm submission
|
||||||
{/if}
|
{/if}
|
||||||
@ -258,18 +264,19 @@
|
|||||||
<Button
|
<Button
|
||||||
kind="text"
|
kind="text"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
submit = true;
|
if (!submitted) submit = true;
|
||||||
}}>Submit</Button
|
else window.close();
|
||||||
|
}}>{submitted ? 'Close' : 'Submit'}</Button
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</Modal>
|
</Modal>
|
||||||
</div>
|
</div>
|
||||||
<div class="buttons-container">
|
<div class="buttons-container">
|
||||||
<Button on:click={previousPage} unclickable={currentPage <= 0}>Previous</Button>
|
<Button on:click={previousPage} unclickable={currentPage <= 0 || submitted}>Previous</Button>
|
||||||
<Button
|
<Button
|
||||||
kind="primary"
|
kind="primary"
|
||||||
on:click={finalPage ? submitSelection : nextPage}
|
on:click={finalPage ? submitSelection : nextPage}
|
||||||
unclickable={finalPage && ui_selected_count < 1}
|
unclickable={finalPage && ui_selected_count < 1 || submitted}
|
||||||
>
|
>
|
||||||
{finalPage ? 'Submit' : 'Next'}
|
{finalPage ? 'Submit' : 'Next'}
|
||||||
</Button>
|
</Button>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user