1
- import { $ , component$ , useSignal , useStore , useVisibleTask$ } from "@builder.io/qwik" ;
1
+ import {
2
+ $ ,
3
+ component$ ,
4
+ useSignal ,
5
+ useStore ,
6
+ useVisibleTask$ ,
7
+ } from "@builder.io/qwik" ;
2
8
import { useNavigate } from "@builder.io/qwik-city" ;
3
9
import Button from "~/components/button/button" ;
4
10
import { FaXmarkSolid } from "@qwikest/icons/font-awesome" ;
@@ -8,63 +14,75 @@ import {
8
14
recentBillsStore ,
9
15
} from "~/providers/recent-bills-store" ;
10
16
11
-
12
17
export default component$ ( ( ) => {
13
- const billData = useStore ( {
18
+ const billData = useStore ( {
14
19
billName : "" ,
15
- memberCount : 0
16
- } )
20
+ memberCount : 0 ,
21
+ } ) ;
17
22
18
23
const nav = useNavigate ( ) ;
19
24
const recentBills = useSignal < RecentBill [ ] > ( [ ] ) ;
20
- const titleBill = useSignal < string > ( "" ) ;
21
25
22
26
// eslint-disable-next-line qwik/no-use-visible-task
23
27
useVisibleTask$ ( ( ) => {
24
28
recentBills . value = recentBillsStore . getRecentBillsArray ( ) ;
25
29
} ) ;
26
30
27
- const onStart = $ ( async ( ) => {
28
- if ( billData . billName . trim ( ) === "" )
29
- {
31
+ const onStart = $ ( async ( ) => {
32
+ if ( billData . billName . trim ( ) === "" ) {
30
33
alert ( "Enter bill's name" ) ;
31
34
return ;
32
35
}
33
- if ( billData . memberCount === 0 )
34
- {
36
+ if ( billData . memberCount === 0 ) {
35
37
alert ( "Enter number of members" ) ;
36
38
return ;
37
39
}
38
40
billData . billName = billData . billName . trim ( ) ;
39
41
40
42
const searchParams = new URLSearchParams ( {
41
- billName : billData . billName ,
42
- memberCount : billData . memberCount . toString ( )
43
- } ) ;
44
- await nav ( "/start?" + searchParams . toString ( ) ) ;
43
+ billName : billData . billName ,
44
+ memberCount : billData . memberCount . toString ( ) ,
45
+ } ) ;
46
+ await nav ( "/start?" + searchParams . toString ( ) ) ;
45
47
} ) ;
46
48
47
49
return (
48
50
< >
49
51
< main >
50
52
< div class = "flex flex-col gap-4 items-center" >
51
53
< h2 class = "text-3xl" > Split your travel expenses easily</ h2 >
52
-
53
- < div class = "grid gap-6 mb-6 md:grid-cols-2" >
54
+
55
+ < div class = "grid gap-6 mb-6 md:grid-cols-2" >
54
56
< div >
55
- < label for = "bill-name" class = "block mb-2 text-xl font-medium" > Bill name</ label >
56
- < input type = "text" id = "bill-name" class = "border text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" placeholder = "Enter name of bill" onInput$ = { ( _ , el ) => ( billData . billName = el . value ) } />
57
-
57
+ < label for = "bill-name" class = "block mb-2 text-xl font-medium" >
58
+ Bill name
59
+ </ label >
60
+ < input
61
+ type = "text"
62
+ id = "bill-name"
63
+ class = "border text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5"
64
+ placeholder = "Enter name of bill"
65
+ onInput$ = { ( _ , el ) => ( billData . billName = el . value ) }
66
+ />
58
67
</ div >
59
68
< div >
60
- < label for = "bill-name" class = "block mb-2 text-xl font-medium" > Number of members</ label >
61
- < input type = "number" id = "bill-name" class = "border text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" placeholder = "Enter number of members" onInput$ = { ( _ , el ) => ( billData . memberCount = parseInt ( el . value ) ) } />
69
+ < label for = "bill-name" class = "block mb-2 text-xl font-medium" >
70
+ Number of members
71
+ </ label >
72
+ < input
73
+ type = "number"
74
+ id = "bill-name"
75
+ class = "border text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5"
76
+ placeholder = "Enter number of members"
77
+ onInput$ = { ( _ , el ) =>
78
+ ( billData . memberCount = parseInt ( el . value ) )
79
+ }
80
+ />
62
81
</ div >
63
-
64
- </ div >
65
- < Button size = { "big" } onClick$ = { onStart } >
66
- Start!
67
- </ Button >
82
+ </ div >
83
+ < Button size = { "big" } onClick$ = { onStart } >
84
+ Start!
85
+ </ Button >
68
86
{ recentBills . value . length > 0 && (
69
87
< div >
70
88
< h3 class = "text-2xl" > Recent Bills</ h3 >
0 commit comments