1
- import { Drawer } from '@mantine/core'
2
- import { useMemo } from 'react'
1
+ import { Avatar , createStyles , Drawer , rem , Stack , Table , Text , Textarea , Title } from '@mantine/core'
2
+ import { useForm , zodResolver } from '@mantine/form'
3
+ import { useEffect , useMemo } from 'react'
4
+ import { z } from 'zod'
3
5
6
+ import { Button } from '~ui/components/core/Button'
4
7
import { ModalTitle } from '~ui/modals/ModalTitle'
5
8
9
+ const noteSchema = z . object ( {
10
+ note : z . string ( ) . min ( 1 , 'Note cannot be empty' ) ,
11
+ organizationId : z . string ( ) ,
12
+ } )
13
+
14
+ const useStyles = createStyles ( ( theme ) => ( {
15
+ contentContainer : {
16
+ gap : rem ( 24 ) ,
17
+ padding : `${ rem ( 40 ) } ${ rem ( 64 ) } ${ rem ( 40 ) } ${ rem ( 64 ) } ` ,
18
+ } ,
19
+ commentsContainer : {
20
+ display : 'flex' ,
21
+ gap : rem ( 40 ) ,
22
+ width : '100%' ,
23
+ alignItems : 'flex-start' ,
24
+ paddingTop : rem ( 40 ) ,
25
+ } ,
26
+ commentsTable : {
27
+ flex : 3 ,
28
+ paddingRight : '20px' ,
29
+ minHeight : '200px' ,
30
+ gap : rem ( 24 ) ,
31
+ } ,
32
+ commentsForm : {
33
+ flex : 1 ,
34
+ minWidth : '250px' ,
35
+ gap : rem ( 24 ) ,
36
+ } ,
37
+ } ) )
38
+
39
+ const comments = [
40
+ {
41
+ avatar : 'https://randomuser.me/api/portraits/men/1.jpg' ,
42
+ name : 'John Doe' ,
43
+ date : '2025-03-15' ,
44
+ comment : 'This is a sample comment.' ,
45
+ } ,
46
+ {
47
+ avatar : 'https://randomuser.me/api/portraits/men/2.jpg' ,
48
+ name : 'Jane Smith' ,
49
+ date : '2025-03-14' ,
50
+ comment : 'Another sample comment.' ,
51
+ } ,
52
+ ]
53
+
54
+ interface FormFields {
55
+ note : string
56
+ organizationId : string
57
+ }
58
+
6
59
interface InternalNotesDrawerProps {
7
60
opened : boolean
8
61
onClose : ( ) => void
9
62
}
10
63
11
64
export const InternalNotesDrawer : React . FC < InternalNotesDrawerProps > = ( { opened, onClose } ) => {
65
+ const { classes } = useStyles ( )
66
+
12
67
const drawerTitle = useMemo (
13
68
( ) => < ModalTitle breadcrumb = { { option : 'close' , onClick : onClose } } maxWidth = '100%' /> ,
14
69
[ onClose ]
15
70
)
16
71
72
+ const form = useForm < FormFields > ( {
73
+ initialValues : {
74
+ organizationId : '' ,
75
+ note : '' ,
76
+ } ,
77
+ validate : zodResolver ( noteSchema ) ,
78
+ } )
79
+
80
+ // Simulating external data for organization ID
81
+ const status = 'success' // Mock status
82
+ const orgQuery = { id : '123' } // Mock organization ID
83
+
84
+ useEffect ( ( ) => {
85
+ if ( status === 'success' && orgQuery ?. id ) {
86
+ form . setFieldValue ( 'organizationId' , orgQuery . id )
87
+ }
88
+ } , [ status , orgQuery ?. id , form ] )
89
+
90
+ // Placeholder function for submitting notes
91
+ const submitNote = ( values : FormFields ) => {
92
+ console . log ( 'Note submitted:' , values )
93
+ }
94
+
17
95
return (
18
96
< Drawer
19
97
opened = { opened }
@@ -24,7 +102,59 @@ export const InternalNotesDrawer: React.FC<InternalNotesDrawerProps> = ({ opened
24
102
withCloseButton = { false }
25
103
title = { drawerTitle }
26
104
>
27
- Content goes here...
105
+ < div className = { classes . contentContainer } >
106
+ < Stack style = { { textAlign : 'center' , paddingTop : rem ( 40 ) } } >
107
+ < Title > Internal Notes</ Title >
108
+ < Text > Organization name: Placeholder</ Text >
109
+ </ Stack >
110
+ < div className = { classes . commentsContainer } >
111
+ < div className = { classes . commentsTable } >
112
+ < Table striped >
113
+ < tbody >
114
+ { comments . map ( ( comment , index ) => (
115
+ < tr key = { index } >
116
+ < td >
117
+ < Avatar src = { comment . avatar } alt = { comment . name } radius = 'xl' />
118
+ </ td >
119
+ < td >
120
+ < div style = { { display : 'flex' , flexDirection : 'column' } } >
121
+ < Text size = 'sm' weight = { 500 } >
122
+ { comment . name }
123
+ </ Text >
124
+ < Text size = 'xs' color = 'dimmed' >
125
+ { comment . date }
126
+ </ Text >
127
+ </ div >
128
+ </ td >
129
+ < td >
130
+ < Text size = 'sm' > { comment . comment } </ Text >
131
+ </ td >
132
+ </ tr >
133
+ ) ) }
134
+ </ tbody >
135
+ </ Table >
136
+ </ div >
137
+ < div className = { classes . commentsForm } >
138
+ < form
139
+ onSubmit = { form . onSubmit ( ( values ) => {
140
+ submitNote ( values )
141
+ } ) }
142
+ >
143
+ < Stack spacing = 'sm' >
144
+ < Textarea
145
+ label = 'Add a note'
146
+ placeholder = 'Enter your note here...'
147
+ { ...form . getInputProps ( 'note' ) }
148
+ minRows = { 3 }
149
+ />
150
+ < Button variant = 'secondary' type = 'submit' >
151
+ Add Note
152
+ </ Button >
153
+ </ Stack >
154
+ </ form >
155
+ </ div >
156
+ </ div >
157
+ </ div >
28
158
</ Drawer >
29
159
)
30
160
}
0 commit comments