Skip to content

Commit f7ccb1c

Browse files
Added modal
1 parent 2979913 commit f7ccb1c

File tree

1 file changed

+52
-6
lines changed

1 file changed

+52
-6
lines changed

dashboard-ui/src/views/IntakeDetail/intakeDetail.jsx

+52-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import {
55
Grid,
66
Group,
77
Text,
8+
Table,
89
Stepper,
10+
Modal,
911
Button,
1012
Box,
1113
Badge,
@@ -16,6 +18,7 @@ import {
1618
List,
1719
Divider,
1820
} from "@mantine/core";
21+
import { useDisclosure } from '@mantine/hooks';
1922
import { AppHeader } from "../../components/AppHeader/appHeader";
2023
import { IconInfoCircle } from "@tabler/icons-react";
2124
import { IconPhoto, IconExternalLink, IconArrowRight } from '@tabler/icons-react';
@@ -29,9 +32,10 @@ export function IntakeDetail() {
2932
const [activeTab, setActiveTab] = useState(""); // Track active tab
3033
const [data, setData] = useState([]); // Stubbed dynamic data
3134
const [detail, setDetail] = useState("");
32-
35+
const [mutableUrl, setmutableUrl] = useState("")
3336
const params = useParams()
3437
const navigate = useNavigate();
38+
const [modalOpen, { open, close }] = useDisclosure(false);
3539

3640
const nextStep = () =>
3741
setActiveStep((current) => (current < overallSteps.length - 1 ? current + 1 : current));
@@ -42,7 +46,7 @@ export function IntakeDetail() {
4246
console.log('success', res)
4347
setData(res?.surveys)
4448
setDetail(res?.detail)
45-
49+
setmutableUrl(res?.mutable_url)
4650
if (res?.surveys?.[0]?.title) {
4751
setActiveTab(res.surveys[0].title); // Default to first tab
4852
}
@@ -128,6 +132,41 @@ export function IntakeDetail() {
128132
);
129133
}
130134

135+
const renderTable = () => {
136+
const tab = {
137+
caption: 'Survey Details',
138+
head: ['Field', 'Value'],
139+
body: detail
140+
? Object.entries(detail).map(([key, value]) => [key, value || "No value"])
141+
: [],
142+
}
143+
144+
return (
145+
<Table.ScrollContainer h={400}>
146+
<Table
147+
stickyHeader
148+
striped
149+
data={tab}
150+
/>
151+
</Table.ScrollContainer>
152+
);
153+
}
154+
155+
const viewParentIntake = () => {
156+
157+
// // Open a new window or tab
158+
// const newWindow = window.open('', '_blank');
159+
//
160+
// if (newWindow) {
161+
// // Write the HTML content to the new window
162+
// newWindow.document.open();
163+
// newWindow.document.write(detail?.summary);
164+
// newWindow.document.close();
165+
// } else {
166+
// console.error('Unable to open a new window. Please check your browser settings.');
167+
// }
168+
}
169+
131170
const { projectInfo, tabs, overallSteps, tabLinks, user } = data;
132171

133172
const renderContent = () => {
@@ -314,16 +353,23 @@ export function IntakeDetail() {
314353
{/* </List.Item>*/}
315354
{/*</List>*/}
316355
</Blockquote>
317-
318356
<Divider label="Universal Intake submissions" labelPosition="center" my="md" />
319-
357+
<Modal size="xl" opened={modalOpen} onClose={close} title="Universal Intake Submission I">
358+
{modalOpen && renderTable()}
359+
</Modal>
320360
<Card shadow="sm" p="lg" my="lg">
321361
<Timeline active={1} lineWidth={3} bulletSize={18}>
322362
<Timeline.Item title="Universal Intake submission I">
323-
<Text c="dimmed" size="sm">View prior survey submission <Text variant="link" component="span" inherit>here</Text></Text>
363+
<Group spacing="xs" align="center">
364+
<Text c="dimmed" size="sm">View prior survey submission:</Text>
365+
<Button onClick={open} variant="light" size="xs">View</Button>
366+
</Group>
324367
</Timeline.Item>
325368
<Timeline.Item title="Universal Intake submission II">
326-
<Text c="dimmed" size="sm">View or Edit prior survey submission<Text variant="link" component="span" inherit>here</Text></Text>
369+
<Group spacing="xs" align="center">
370+
<Text c="dimmed" size="sm">View or Edit prior survey submission:</Text>
371+
<Button component="a" href={mutableUrl} variant="light" size="xs">View</Button>
372+
</Group>
327373
</Timeline.Item>
328374
<Timeline.Item title="Complete additional surveys required for requested services" lineVariant="dashed">
329375
<Text c="dimmed" size="sm">Please complete each intake for the requested services below</Text>

0 commit comments

Comments
 (0)