|
6 | 6 | import RiArrowDropRightLine from '~icons/ri/arrow-drop-right-line'; |
7 | 7 | import RiLinksLine from '~icons/ri/links-line'; |
8 | 8 | import RiLoader2Line from '~icons/ri/loader-2-line'; |
9 | | - import type { SubmissionsResult } from './+page.js'; |
| 9 | + import type { SubmissionsResult } from './+page.server.js'; |
| 10 | + import SignInButton from '@/components/custom/SignInButton.svelte'; |
| 11 | + import * as Card from '@/components/ui/card'; |
10 | 12 |
|
11 | 13 | let { data } = $props(); |
12 | 14 |
|
|
35 | 37 | clearTimeout(debounceTimer); |
36 | 38 | debounceTimer = setTimeout(callback, ms); |
37 | 39 | } |
38 | | -
|
39 | | - // TODO implement domain submission (server actions) |
40 | | - function submitDomain() {} |
41 | 40 | </script> |
42 | 41 |
|
43 | 42 | {#snippet submissions(submissions: SubmissionsResult)} |
|
74 | 73 | <main class="flex w-full max-w-4xl flex-col gap-2 self-center px-6"> |
75 | 74 | <h2 class="-mx-2 text-3xl">Domain submissions</h2> |
76 | 75 | <hr class="my-2" /> |
| 76 | + {#if data.status === 'domainSubmissionError'} |
| 77 | + <Card.Root class="p-4 outline outline-red-100 dark:outline-red-900"> |
| 78 | + Error submitting domain. Please try again and file an issue if it does not work. |
| 79 | + </Card.Root> |
| 80 | + {:else if data.status === 'domainSubmitted'} |
| 81 | + <Card.Root class="p-4 outline outline-green-100 dark:outline-green-900"> |
| 82 | + Domain submitted successfully! |
| 83 | + </Card.Root> |
| 84 | + {/if} |
77 | 85 | <div class="w-full rounded-2xl bg-white p-4"> |
78 | 86 | <h3 class="text-2xl">Submit domain</h3> |
79 | 87 | <hr class="my-2" /> |
|
91 | 99 | {#await submissionsForInput} |
92 | 100 | <RiLoader2Line class="h-8 w-8 animate-spin" /> |
93 | 101 | {:then submissionsForInput} |
94 | | - {#if submissionsForInput.count > 0} |
95 | | - <div class="mb-4">Found {submissionsForInput.count} pre-existing submission(s)</div> |
96 | | - {@render submissions(submissionsForInput)} |
97 | | - {#if domainInput.length > 0} |
98 | | - <Button |
99 | | - title="unimplemented" |
100 | | - variant="secondary" |
101 | | - class="mt-6 flex w-full flex-row items-center gap-2 dark:bg-muted" |
102 | | - > |
103 | | - <RiLinksLine class="min-h-5 min-w-5 text-black dark:text-white" /> |
104 | | - Resubmit Domain |
105 | | - </Button> |
106 | | - {/if} |
107 | | - {:else} |
108 | | - Found no pre-existing submission(s) |
109 | | - {#if domainInput.length > 0} |
110 | | - <Button |
111 | | - title="unimplemented" |
112 | | - variant="secondary" |
113 | | - class="mt-6 flex w-full flex-row items-center gap-2 dark:bg-muted" |
114 | | - > |
115 | | - <RiLinksLine class="min-h-5 min-w-5 text-black dark:text-white" /> |
116 | | - Submit Domain |
117 | | - </Button> |
| 102 | + {#if domainInput.length > 0} |
| 103 | + {#if submissionsForInput.count > 0} |
| 104 | + <div class="mb-4">Found {submissionsForInput.count} pre-existing submission(s)</div> |
| 105 | + {@render submissions(submissionsForInput)} |
| 106 | + {:else} |
| 107 | + Found no pre-existing submission(s) |
118 | 108 | {/if} |
| 109 | + <form method="POST" action="?/submitDomain"> |
| 110 | + {#if data.loginStatus == 'assumeLoggedIn'} |
| 111 | + <Button |
| 112 | + variant="secondary" |
| 113 | + class="mt-6 flex w-full flex-row items-center gap-2 dark:bg-muted" |
| 114 | + type="submit" |
| 115 | + > |
| 116 | + <RiLinksLine class="min-h-5 min-w-5 text-black dark:text-white" /> |
| 117 | + {#if submissionsForInput.count > 0} |
| 118 | + Resubmit Domain |
| 119 | + {:else} |
| 120 | + Submit Domain |
| 121 | + {/if} |
| 122 | + </Button> |
| 123 | + {:else} |
| 124 | + <div class="mt-6 flex w-full flex-row items-center gap-2 dark:bg-muted"> |
| 125 | + Authenticate to submit |
| 126 | + <SignInButton loginStatus={data.loginStatus} /> |
| 127 | + </div> |
| 128 | + {/if} |
| 129 | + </form> |
119 | 130 | {/if} |
120 | 131 | {/await} |
121 | 132 | </div> |
|
0 commit comments