From 5a7201031d3fafcb90d18cc1034870c408ad0043 Mon Sep 17 00:00:00 2001
From: Fuwn <contact@fuwn.me>
Date: Thu, 1 Feb 2024 00:29:32 -0800
Subject: refactor(discussions): use input template

---
 src/lib/Tools/EpisodeDiscussionCollector.svelte | 42 +++++++------------------
 1 file changed, 11 insertions(+), 31 deletions(-)

(limited to 'src/lib/Tools/EpisodeDiscussionCollector.svelte')

diff --git a/src/lib/Tools/EpisodeDiscussionCollector.svelte b/src/lib/Tools/EpisodeDiscussionCollector.svelte
index 2be34dd4..e4855856 100644
--- a/src/lib/Tools/EpisodeDiscussionCollector.svelte
+++ b/src/lib/Tools/EpisodeDiscussionCollector.svelte
@@ -10,42 +10,22 @@
 		type HoverCoverResponse
 	} from '$lib/Media/Cover/hoverCover';
 	import Skeleton from '$lib/Loading/Skeleton.svelte';
+	import InputTemplate from './InputTemplate.svelte';
 
-	let searchInput = '';
-	let searchInputFinal = '';
 	let hoverCoverState: HoverCoverResponse = {};
+	let submission = '';
 
 	onMount(clearAllParameters);
 </script>
 
-<div class="card">
-	<p>
-		<!-- svelte-ignore missing-declaration -->
-		<input
-			type="text"
-			placeholder="Username"
-			bind:value={searchInput}
-			on:keypress={(e) => {
-				if (e.key === 'Enter') {
-					searchInputFinal = searchInput;
-
-					// eslint-disable-next-line no-undef
-					umami.track('Collect Episode Discussions');
-				}
-			}}
-		/>
-		<button
-			class="button-lined"
-			on:click={() => (searchInputFinal = searchInput)}
-			title="Or click your Enter key"
-			data-umami-event="Collect Episode Discussions"
-		>
-			Search
-		</button>
-	</p>
-
-	{#if searchInputFinal !== ''}
-		{#await threads(searchInputFinal)}
+<InputTemplate
+	field="Username"
+	bind:submission
+	event="Collect Episode Discussions"
+	submitText="Search"
+>
+	{#if submission !== ''}
+		{#await threads(submission)}
 			<Skeleton card={false} count={5} height="0.9rem" list />
 		{:then threads}
 			<ul>
@@ -109,6 +89,6 @@
 
 		Enter a username to search for to continue.
 	{/if}
-</div>
+</InputTemplate>
 
 <HoverCover options={hoverCoverState} width={300} />
-- 
cgit v1.2.3

