-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added feedback submission * updated version * added buttons to settings
- Loading branch information
Showing
9 changed files
with
168 additions
and
11 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
<script lang="ts"> | ||
import { onMount } from 'svelte'; | ||
import { closeModal, modals } from 'svelte-modals'; | ||
import { toast } from '@zerodevx/svelte-toast'; | ||
import { canSubmit, logSubmissionTime } from '$lib/stores/feedback'; | ||
export let isOpen: boolean; | ||
let stackIndex: number = $modals.length; | ||
let feedbackText: string = ''; | ||
let urgency: number = 0; | ||
let canSub: boolean = true; | ||
function updateUrgency(urgen: number) { | ||
if (urgency === urgen) { | ||
urgency = 0; | ||
} else { | ||
urgency = urgen; | ||
} | ||
} | ||
async function submitFeedback() { | ||
if (!$canSubmit) { | ||
toast.push('Please wait for 5 minutes before submitting new feedback.', { | ||
theme: { | ||
'--toastBackground': '#f44336', | ||
'--toastProgressBackground': '#d32f2f' | ||
} | ||
}); | ||
return; | ||
} | ||
logSubmissionTime(); | ||
const response = await fetch('https://feedback-api.shuttleapp.rs/feedback', { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify({ | ||
text: feedbackText, | ||
urgency: urgency | ||
}) | ||
}); | ||
if (response.ok) { | ||
toast.push('Feedback submitted!'); | ||
closeModal(); | ||
} else { | ||
toast.push(await response.text(), { | ||
theme: { | ||
'--toastBackground': '#f44336', | ||
'--toastProgressBackground': '#d32f2f' | ||
} | ||
}); | ||
} | ||
} | ||
</script> | ||
|
||
{#if isOpen} | ||
<div role="dialog" class="fixed inset-0 flex items-center justify-center z-50"> | ||
<div | ||
class="card bg-slate-100 h-fit w-full min-w-[25rem] max-w-[66.666667%] max-h-[85%] overflow-auto" | ||
> | ||
<div class="card-body gap-4"> | ||
<h2 class="card-title">Submit Feedback</h2> | ||
<p>Feel free to submit suggestions or report bugs.</p> | ||
|
||
<form> | ||
<textarea class="textarea w-full" placeholder="Feedback" bind:value={feedbackText} /> | ||
|
||
<div class="flex justify-between"> | ||
<button | ||
class={urgency === 10 ? 'btn btn-primary' : 'btn btn-outline'} | ||
on:click={() => updateUrgency(10)}>😬 Commend</button | ||
> | ||
<button | ||
class={urgency === 20 ? 'btn btn-primary' : 'btn btn-outline'} | ||
on:click={() => updateUrgency(20)}>🕷 Bug</button | ||
> | ||
<button | ||
class={urgency === 30 ? 'btn btn-primary' : 'btn btn-outline'} | ||
on:click={() => updateUrgency(30)}>🚀 Feature</button | ||
> | ||
<button | ||
class={urgency === 50 ? 'btn btn-error' : 'btn btn-outline'} | ||
on:click={() => updateUrgency(50)}>💣 URGENT</button | ||
> | ||
</div> | ||
</form> | ||
|
||
<div class="justify-between items-center card-actions"> | ||
<a | ||
class="link text-sm" | ||
target="_blank" | ||
href="https://github.com/Valink-Solutions/teller/issues" | ||
>Submit more info in a github issue.</a | ||
> | ||
|
||
<div class="flex flex-row gap-2"> | ||
{#if stackIndex > 1} | ||
<button on:click={closeModal} class="btn">Close</button> | ||
{:else} | ||
<button on:click={closeModal} class="btn">Close</button> | ||
{/if} | ||
|
||
<button on:click={submitFeedback} class="btn btn-primary" disabled={!$canSubmit} | ||
>Submit</button | ||
> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{/if} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { writable, derived } from 'svelte/store'; | ||
|
||
const lastFeedbackTime = writable(0); | ||
const timeLimit = 300000; // 5 minutes in milliseconds | ||
|
||
export const canSubmit = derived(lastFeedbackTime, ($lastFeedbackTime) => { | ||
const now = Date.now(); | ||
return now - $lastFeedbackTime >= timeLimit; | ||
}); | ||
|
||
export function logSubmissionTime() { | ||
lastFeedbackTime.set(Date.now()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters