1
1
/* eslint-disable react/jsx-props-no-spreading */
2
+ /* eslint-disable jsx-a11y/no-noninteractive-tabindex */
2
3
/* eslint-disable jsx-a11y/label-has-associated-control */
3
4
4
5
import { Category } from '@prisma/client' ;
5
- import MainLayout from 'components/layout/MainLayout' ;
6
6
import useZodForm from 'lib/form' ;
7
7
import { useSession } from 'next-auth/react' ;
8
8
import Image from 'next/image' ;
9
- import Link from 'next/link ' ;
9
+ import { FaTimes } from 'react-icons/fa ' ;
10
10
import { toast } from 'react-toastify' ;
11
11
import { Categories } from 'types' ;
12
12
import { trpc } from 'utils/trpc' ;
13
13
import { z } from 'zod' ;
14
+ import useDialogStore from '../stores/DialogStore' ;
15
+ import { Dialog } from './Dialog' ;
16
+
17
+ export default function SubscriptionDialog ( ) {
18
+ const { dialog, clearDialog, manageSubscriptionsDialog } = useDialogStore ( ) ;
19
+
20
+ const context = trpc . useContext ( ) ;
14
21
15
- export default function SubscribePage ( ) {
16
22
const { data : subscriptions , status } = trpc . subscription . list . useQuery ( ) ;
17
23
const { data : session , status : sessionStatus } = useSession ( {
18
24
required : true
19
25
} ) ;
20
26
21
- const context = trpc . useContext ( ) ;
22
-
23
27
const subscriptionCreate = trpc . subscription . create . useMutation ( {
24
28
onSuccess : ( ) => {
25
29
toast ( 'Subscription created!' ) ;
@@ -54,9 +58,21 @@ export default function SubscribePage() {
54
58
if ( status === 'loading' ) return < div > Loading...</ div > ;
55
59
56
60
return (
57
- < MainLayout >
58
- < div className = "flex flex-col gap-2" >
59
- < div className = "text-2xl font-bold md:text-4xl" > Item Subscription</ div >
61
+ < Dialog isOpen = { dialog === 'subscribe' } onClose = { clearDialog } >
62
+ < div className = "flex h-full flex-col gap-2" >
63
+ < div className = "flex items-center justify-between" >
64
+ < span className = "text-2xl font-bold md:text-3xl" >
65
+ Email Notification Sign-Up
66
+ </ span >
67
+ < button
68
+ type = "button"
69
+ onClick = { clearDialog }
70
+ className = "btn-ghost btn-circle btn"
71
+ >
72
+ < FaTimes className = "h-6 w-6" />
73
+ </ button >
74
+ </ div >
75
+ < div className = "divider my-0" />
60
76
< div >
61
77
< div className = "flex items-center gap-2" >
62
78
< div className = "relative h-20 w-20" >
@@ -67,26 +83,25 @@ export default function SubscribePage() {
67
83
</ span >
68
84
</ div >
69
85
</ div >
70
- < div className = "prose-sm prose" >
86
+ < div className = "prose-neutral prose" >
71
87
< strong >
72
88
< ol >
73
- < li > Add your information below. </ li >
89
+ < li > Select up to two product categories below</ li >
74
90
< li >
75
- You'll receive an email at the end of each day filtered to
76
- your selected category.
91
+ You'll receive a daily email listing newly lost items for
92
+ each category. Email notifications will run for seven
93
+ consecutive days.
77
94
</ li >
78
95
< li >
79
- You'll receive emails for seven days, and you can
80
- unsubscribe at any time .
96
+ If you wish to renew notifications after this period, please
97
+ revisit this page .
81
98
</ li >
82
99
</ ol >
83
100
</ strong >
84
101
</ div >
85
- < div >
86
- < span className = "text-lg font-bold" > Add Item Information</ span >
87
- </ div >
102
+ < div className = "divider my-0" />
88
103
< form
89
- className = "flex w-full flex-col gap-2 font-bold"
104
+ className = "flex w-full flex-1 flex- col gap-2 font-bold"
90
105
onSubmit = { methods . handleSubmit ( async ( data ) => {
91
106
data . categories . forEach ( async ( category ) => {
92
107
await subscriptionCreate . mutateAsync ( { category } ) ;
@@ -95,7 +110,7 @@ export default function SubscribePage() {
95
110
>
96
111
< div className = "form-control gap-1" >
97
112
< label className = "label" >
98
- < span className = "label-text" > Email Address </ span >
113
+ < span className = "label-text text-lg" > Contact Information </ span >
99
114
</ label >
100
115
< input
101
116
type = "email"
@@ -106,7 +121,7 @@ export default function SubscribePage() {
106
121
</ div >
107
122
< div className = "form-control gap-1" >
108
123
< label className = "label" >
109
- < span className = "label-text" > Item Category</ span >
124
+ < span className = "label-text text-lg" > Select Item Category</ span >
110
125
</ label >
111
126
< div className = "flex flex-wrap gap-2" >
112
127
{ Object . values ( Category ) . map ( ( category ) => (
@@ -130,26 +145,24 @@ export default function SubscribePage() {
130
145
{ methods . formState . errors . categories ?. message }
131
146
</ span >
132
147
</ div >
133
- < div className = "form-control" >
148
+ < div className = "form-control mt-4 flex-1 justify-end gap-2 " >
134
149
< button
135
150
type = "submit"
136
151
className = "btn-accent btn-sm btn"
137
152
disabled = { ! methods . formState . isDirty }
138
153
>
139
154
Subscribe
140
155
</ button >
141
- </ div >
142
- < div className = "divider" />
143
- < div className = "form-control" >
144
- < Link
145
- href = "/subscriptions"
146
- className = "btn-outline btn-accent btn-ghost btn-sm btn"
156
+ < button
157
+ type = "button"
158
+ onClick = { manageSubscriptionsDialog }
159
+ className = "btn-accent btn-ghost btn-outline btn-sm btn"
147
160
>
148
161
Manage Subscriptions
149
- </ Link >
162
+ </ button >
150
163
</ div >
151
164
</ form >
152
165
</ div >
153
- </ MainLayout >
166
+ </ Dialog >
154
167
) ;
155
168
}
0 commit comments