-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathApp.svelte
More file actions
55 lines (44 loc) · 1.21 KB
/
App.svelte
File metadata and controls
55 lines (44 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<script lang="ts">
import CopyEncryptedBallotForm from "./CopyEncryptedBallotForm.svelte";
import FillBallotForm from "./FillBallotForm.svelte";
import GitHubCredentials from "./GitHubCredentials.svelte";
import FindPrForm from "./FindPRForm.svelte";
let encryptDataPromise = new Promise<never>(() => {});
let url = globalThis.location?.hash.slice(1);
let username = "",
token = "";
function updateAuth(u: string, t: string) {
username = u;
token = t;
}
let step = url ? 1 : 0;
addEventListener("hashchange", () => {
url = globalThis.location?.hash.slice(1);
step = url ? Math.max(step, 1) : 0;
});
function registerEncryptedBallot(promise) {
encryptDataPromise = promise;
promise.then(
() => {
step = 2;
},
() => {
step = Math.min(step, 1);
}
);
}
</script>
<h1>Caritat</h1>
<details>
<GitHubCredentials {updateAuth} {username} {token} />
</details>
<hr />
<details open={step === 0}>
<FindPrForm {url} />
</details>
<details open={step === 1}>
<FillBallotForm {url} {username} {token} {registerEncryptedBallot} />
</details>
<details open={step === 2}>
<CopyEncryptedBallotForm {encryptDataPromise} {url} />
</details>