File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed
Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change 11<script lang =" ts" >
22 import { page } from ' $app/stores' ;
3+ import { fade } from ' svelte/transition' ;
4+ import { loggedIn , user } from ' $lib/utils/console' ;
35 import { PUBLIC_GROWTH_ENDPOINT } from ' $env/static/public' ;
46
57 export let date: string | undefined = undefined ;
1416 async function handleSubmit() {
1517 submitting = true ;
1618 error = undefined ;
19+
20+ const userId = loggedIn && $user ?.$id ? $user .$id : undefined ;
21+
1722 const response = await fetch (` ${PUBLIC_GROWTH_ENDPOINT }/feedback/docs ` , {
1823 method: ' POST' ,
1924 headers: {
2328 email ,
2429 type: feedbackType ,
2530 route: $page .route .id ,
26- comment
31+ comment ,
32+ metaFields: {
33+ userId
34+ }
2735 })
2836 });
2937 submitting = false ;
3341 }
3442 comment = email = ' ' ;
3543 submitted = true ;
44+ setTimeout (() => (showFeedback = false ), 500 );
3645 }
3746
3847 function reset() {
4554 $ : if (! showFeedback ) {
4655 reset ();
4756 }
57+
58+ $ : if (showFeedback && loggedIn && $user ?.email ) {
59+ email = $user ?.email ;
60+ }
4861 </script >
4962
5063<section class =" web-content-footer" >
6073 class =" web-radio-button"
6174 aria-label =" helpful"
6275 on:click ={() => {
63- showFeedback = feedbackType === ' positive' ? false : true ;
76+ showFeedback = feedbackType !== ' positive' ;
6477 feedbackType = ' positive' ;
6578 }}
6679 >
7083 class =" web-radio-button"
7184 aria-label =" unhelpful"
7285 on:click ={() => {
73- showFeedback = feedbackType === ' negative' ? false : true ;
86+ showFeedback = feedbackType !== ' negative' ;
7487 feedbackType = ' negative' ;
7588 }}
7689 >
104117 on:submit |preventDefault ={handleSubmit }
105118 class =" web-card is-normal"
106119 style =" --card-padding:1rem"
120+ out:fade ={{ duration : 450 }}
107121 >
108122 <div class =" flex flex-col gap-2" >
109123 <label for =" message" >
You can’t perform that action at this time.
0 commit comments