Skip to content

Commit ee17df6

Browse files
authored
Merge pull request #92 from skorphil/87-previous-institutions-were-loaded
added new record initial state
2 parents 320824a + 64a525b commit ee17df6

File tree

4 files changed

+74
-16
lines changed

4 files changed

+74
-16
lines changed

components/InstitutionContainer/InstitutionContainer.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ export function InstitutionContainer({ institutionName, isInstitutionOpen }) {
2929

3030
return (
3131
<VStack
32-
bg="gray.800"
33-
borderRadius={isInstitutionOpen || "lg"}
34-
h="100%"
35-
minHeight="100%"
32+
// bg="gray.800"
33+
// borderRadius={isInstitutionOpen || "lg"}
34+
// h="100%"
35+
// minHeight="100%"
3636
>
3737
{isInstitutionOpen && (
3838
<Box

components/InstitutionsList/InstitutionsList.jsx

Lines changed: 67 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,16 @@
22

33
import { InstitutionsTabsList } from "../InstitutionsTabsList";
44
import { InstitutionContainer } from "../InstitutionContainer";
5-
import { Tabs, TabPanels, TabPanel } from "@chakra-ui/react";
5+
import {
6+
Tabs,
7+
Text,
8+
TabPanels,
9+
TabPanel,
10+
Center,
11+
Heading,
12+
VStack,
13+
Image,
14+
} from "@chakra-ui/react";
615
import { useVisualViewportSize } from "../../app/hooks";
716
import classes from "./InstitutionsList.module.css";
817
import { useFormContext } from "react-hook-form";
@@ -29,16 +38,11 @@ function InstitutionsList({
2938
variant="grid"
3039
padding={isInstitutionOpen || 2}
3140
>
32-
<TabPanels flexGrow={1} flexShrink={1} h="200px">
33-
{institutions.map((institution, index) => (
34-
<TabPanel p={0} key={institution.id} h="100%">
35-
<InstitutionContainer
36-
institutionName={`institutions.${index}`}
37-
isInstitutionOpen={isInstitutionOpen}
38-
/>
39-
</TabPanel>
40-
))}
41-
</TabPanels>
41+
<ContentPanel
42+
institutions={institutions}
43+
selectedInstitution={selectedInstitution}
44+
isInstitutionOpen={isInstitutionOpen}
45+
/>
4246
{isInstitutionOpen || (
4347
<InstitutionsTabsList
4448
simulateKeyboard={isKeyboardOpened}
@@ -51,3 +55,55 @@ function InstitutionsList({
5155
}
5256

5357
export { InstitutionsList };
58+
59+
function ContentPanel({
60+
institutions,
61+
selectedInstitution,
62+
isInstitutionOpen,
63+
}) {
64+
return (
65+
<TabPanels
66+
bg="gray.800"
67+
borderRadius={isInstitutionOpen || "lg"}
68+
h="100%"
69+
minHeight="260px"
70+
flexGrow={1}
71+
flexShrink={1}
72+
>
73+
{selectedInstitution === null ? (
74+
<ContentPanelOverlay
75+
image="/institutions-loaded.svg"
76+
headingText="Institutions loaded from latest&nbsp;record"
77+
text="Edit institutions to reflect asset updates"
78+
/>
79+
) : (
80+
false
81+
)}
82+
{institutions.map((institution, index) => (
83+
<TabPanel p={0} key={institution.id} h="100%">
84+
<InstitutionContainer
85+
institutionName={`institutions.${index}`}
86+
isInstitutionOpen={isInstitutionOpen}
87+
/>
88+
</TabPanel>
89+
))}
90+
</TabPanels>
91+
);
92+
}
93+
94+
function ContentPanelOverlay({ image, headingText, text }) {
95+
return (
96+
<Center h="100%" p={2}>
97+
<VStack gap={12}>
98+
<Image src={image} alt="Illustration" boxSize="140px" />
99+
100+
<VStack>
101+
<Heading textAlign="center" size="md">
102+
{headingText}
103+
</Heading>
104+
<Text>{text}</Text>
105+
</VStack>
106+
</VStack>
107+
</Center>
108+
);
109+
}

components/RecordForm/RecordForm.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ import { handleSavingSuccess, handleSavingError } from "./handlers";
2222

2323
export function RecordForm() {
2424
const [isInstitutionOpen, setIsInstitutionOpen] = useState(false);
25-
const [selectedInstitutionIndex, setSelectedInstitutionIndex] = useState(0);
25+
const [selectedInstitutionIndex, setSelectedInstitutionIndex] =
26+
useState(null);
2627
const [formOverlay, setFormOverlay] = useState(false);
2728
const [warningState, setWarningState] = useState(null);
2829
const toast = useToast({ position: "top" });

0 commit comments

Comments
 (0)