2
2
3
3
import { InstitutionsTabsList } from "../InstitutionsTabsList" ;
4
4
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" ;
6
15
import { useVisualViewportSize } from "../../app/hooks" ;
7
16
import classes from "./InstitutionsList.module.css" ;
8
17
import { useFormContext } from "react-hook-form" ;
@@ -29,16 +38,11 @@ function InstitutionsList({
29
38
variant = "grid"
30
39
padding = { isInstitutionOpen || 2 }
31
40
>
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
+ />
42
46
{ isInstitutionOpen || (
43
47
< InstitutionsTabsList
44
48
simulateKeyboard = { isKeyboardOpened }
@@ -51,3 +55,55 @@ function InstitutionsList({
51
55
}
52
56
53
57
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 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
+ }
0 commit comments