Skip to content

Commit 8820b7d

Browse files
committed
InternalNotesDrawer component plus changes to ModalTitle, AuditDrawer, Action Components
1 parent 3403438 commit 8820b7d

File tree

2 files changed

+135
-5
lines changed

2 files changed

+135
-5
lines changed

packages/ui/components/data-portal/Action.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Button } from '~ui/components/core/Button'
55
import { AuditDrawer } from '~ui/components/data-portal/AuditDrawer'
66
import { InternalNotesDrawer } from '~ui/components/data-portal/InternalNotesDrawer'
77

8-
const useMessageBodyStyles = createStyles((theme) => ({
8+
const useStyles = createStyles((theme) => ({
99
actionBlock: {
1010
display: 'flex',
1111
gap: rem(10),
@@ -16,7 +16,7 @@ const useMessageBodyStyles = createStyles((theme) => ({
1616
export const Action = () => {
1717
const [auditOpen, setAuditOpen] = useState(false)
1818
const [internalOpen, setInternalOpen] = useState(false)
19-
const { classes } = useMessageBodyStyles()
19+
const { classes } = useStyles()
2020
const onAuditClose = () => {
2121
setAuditOpen(false)
2222
}
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,97 @@
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'
35

6+
import { Button } from '~ui/components/core/Button'
47
import { ModalTitle } from '~ui/modals/ModalTitle'
58

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+
659
interface InternalNotesDrawerProps {
760
opened: boolean
861
onClose: () => void
962
}
1063

1164
export const InternalNotesDrawer: React.FC<InternalNotesDrawerProps> = ({ opened, onClose }) => {
65+
const { classes } = useStyles()
66+
1267
const drawerTitle = useMemo(
1368
() => <ModalTitle breadcrumb={{ option: 'close', onClick: onClose }} maxWidth='100%' />,
1469
[onClose]
1570
)
1671

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+
1795
return (
1896
<Drawer
1997
opened={opened}
@@ -24,7 +102,59 @@ export const InternalNotesDrawer: React.FC<InternalNotesDrawerProps> = ({ opened
24102
withCloseButton={false}
25103
title={drawerTitle}
26104
>
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>
28158
</Drawer>
29159
)
30160
}

0 commit comments

Comments
 (0)