goobs-frontend 0.7.70 → 0.7.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  'use client'
2
2
 
3
- import React from 'react'
3
+ import React, { useState, useCallback } from 'react'
4
4
  import {
5
5
  Drawer,
6
6
  Box,
@@ -11,6 +11,7 @@ import {
11
11
  AccordionSummary,
12
12
  AccordionDetails,
13
13
  List,
14
+ SelectChangeEvent,
14
15
  } from '@mui/material'
15
16
  import Dropdown from '../../Dropdown'
16
17
  import Searchbar from '../../Searchbar'
@@ -26,47 +27,23 @@ import {
26
27
  } from '../../../styles/palette'
27
28
  import { Typography } from './../../Typography'
28
29
 
29
- /**
30
- * Props for the VerticalVariant component.
31
- */
32
30
  export interface VerticalVariantProps {
33
- /** An array of navigation items, sub-navigation items, or views. */
34
31
  items: (NavProps | SubNav | View)[]
35
- /** Determines whether to show the search bar. */
36
32
  showSearchbar: boolean
37
- /** Determines whether to show the dropdown. */
38
33
  showDropdown: boolean
39
- /** Determines whether to show the title. */
40
34
  showTitle: boolean
41
- /** Determines whether to show a divider line. */
42
35
  showLine: boolean
43
- /** The title of the vertical navigation. */
44
36
  verticalNavTitle: string
45
- /** The label for the dropdown. */
46
37
  dropdownLabel: string
47
- /** The label for the search bar. */
48
38
  searchbarLabel: string
49
- /** The anchor position of the drawer ('left' or 'right'). */
50
39
  anchor: 'left' | 'right'
51
- /** An array of expanded navigation items. */
52
40
  expandedNavs: string[]
53
- /** Function to set the expanded navigation items. */
54
41
  setExpandedNavs: React.Dispatch<React.SetStateAction<string[]>>
55
- /** An array of expanded sub-navigation items. */
56
42
  expandedSubnavs: string[]
57
- /** Function to set the expanded sub-navigation items. */
58
43
  setExpandedSubnavs: React.Dispatch<React.SetStateAction<string[]>>
59
- /** The width of the vertical navigation drawer. */
60
44
  verticalNavWidth: string
61
45
  }
62
46
 
63
- /**
64
- * VerticalVariant component that renders a vertical navigation drawer.
65
- * It supports nested navigation items, sub-navigation items, and views.
66
- *
67
- * @param {VerticalVariantProps} props - The props for the VerticalVariant component.
68
- * @returns {JSX.Element} The rendered VerticalVariant component.
69
- */
70
47
  function VerticalVariant({
71
48
  items,
72
49
  showSearchbar,
@@ -84,174 +61,60 @@ function VerticalVariant({
84
61
  verticalNavWidth,
85
62
  }: VerticalVariantProps) {
86
63
  const router = useRouter()
64
+ const [selectedNav, setSelectedNav] = useState<string | null>(null)
87
65
 
88
- /**
89
- * Extracts navigation options from the items array.
90
- */
91
66
  const navOptions = items
92
67
  .filter((item): item is NavProps => 'title' in item && 'subnavs' in item)
93
- .map(nav => nav.title ?? '')
68
+ .map(nav => ({ value: nav.title ?? '', label: nav.title ?? '' }))
94
69
 
95
- /**
96
- * Handles click events on navigation items.
97
- * Supports different trigger types: route and onClick.
98
- *
99
- * @param {NavProps} nav - The navigation item that was clicked.
100
- */
101
- const handleNavClick = (nav: NavProps) => {
102
- console.log('Clicked Nav:', nav.title)
103
- if (nav.trigger === 'route') {
104
- if (nav.route) {
105
- router.push(nav.route)
70
+ const handleNavClick = useCallback(
71
+ (nav: NavProps) => {
72
+ console.log('Clicked Nav:', nav.title)
73
+ if (nav.trigger === 'route') {
74
+ if (nav.route) {
75
+ router.push(nav.route)
76
+ }
77
+ } else if (nav.trigger === 'onClick') {
78
+ if (nav.onClick) {
79
+ nav.onClick()
80
+ }
106
81
  }
107
- } else if (nav.trigger === 'onClick') {
108
- if (nav.onClick) {
109
- nav.onClick()
110
- }
111
- }
112
- }
82
+ },
83
+ [router]
84
+ )
113
85
 
114
- /**
115
- * Recursively renders navigation items, sub-navigation items, and views.
116
- *
117
- * @param {NavProps | SubNav | View} item - The item to render.
118
- * @param {number} level - The nesting level of the item.
119
- * @param {string} [activeAndHoverColor] - The color to use for active and hover states.
120
- * @returns {JSX.Element | null} The rendered item or null if the item type is not recognized.
121
- */
122
- const renderItem = (
123
- item: NavProps | SubNav | View,
124
- level: number,
125
- activeAndHoverColor = semiTransparentWhite.main
126
- ) => {
127
- if ('title' in item && 'subnavs' in item) {
128
- const nav = item as NavProps
129
- const isExpanded = expandedNavs.includes(nav.title ?? '')
130
- return (
131
- <MuiAccordion
132
- key={nav.title}
133
- disableGutters
134
- elevation={0}
135
- square
136
- expanded={isExpanded}
137
- onChange={() => {
138
- if (isExpanded) {
139
- setExpandedNavs(expandedNavs.filter(title => title !== nav.title))
140
- } else {
141
- setExpandedNavs([...expandedNavs, nav.title ?? ''])
142
- }
143
- }}
144
- sx={{
145
- pl: 0,
146
- backgroundColor: 'transparent',
147
- '.MuiAccordionSummary-root': {
148
- pl: 0,
149
- },
150
- '&:before': {
151
- display: 'none',
152
- },
153
- }}
154
- >
155
- <AccordionSummary
156
- expandIcon={
157
- nav.subnavs && nav.subnavs.length > 0 ? (
158
- <ExpandMoreIcon
159
- sx={{
160
- color: 'transparent',
161
- }}
162
- />
163
- ) : null
164
- }
165
- aria-controls="accordion-content"
166
- id="accordion-header"
167
- sx={{
168
- boxSizing: 'border-box',
169
- border: 'none',
170
- py: '6px',
171
- mt: 2,
172
- ml: 3,
173
- minHeight: 0,
174
- height: '32px',
175
- '& .MuiAccordionSummary-content': {
176
- m: 0,
177
- },
178
- '&:hover': {
179
- '& .MuiSvgIcon-root': {
180
- color: white.main,
181
- },
182
- },
183
- '&.Mui-expanded': {
184
- '& .MuiSvgIcon-root': {
185
- color: white.main,
186
- },
187
- },
188
- }}
189
- onClick={() => handleNavClick(nav)}
190
- >
191
- <Typography
192
- fontvariant="merrih5"
193
- fontcolor={white.main}
194
- text={nav.title ?? ''}
195
- marginLeft={4 * level}
196
- />
197
- </AccordionSummary>
198
- <AccordionDetails sx={{ border: 'none', p: 0 }}>
199
- <List sx={{ py: 0 }}>
200
- {nav.subnavs?.map(subnav =>
201
- renderItem(subnav, level + 1, activeAndHoverColor)
202
- )}
203
- </List>
204
- </AccordionDetails>
205
- </MuiAccordion>
206
- )
207
- } else if ('title' in item && 'views' in item) {
208
- const subnav = item as SubNav
209
- const isExpanded = expandedSubnavs.includes(subnav.title ?? '')
210
- if (subnav.views?.length === 0) {
211
- return (
212
- <Link
213
- key={subnav.title}
214
- style={{
215
- textDecoration: 'none',
216
- color: 'white',
217
- }}
218
- href={subnav.route ?? ''}
219
- >
220
- <MenuItem
221
- sx={{
222
- color: white.main,
223
- ml: '25px',
224
- '&:hover': {
225
- backgroundColor: activeAndHoverColor,
226
- },
227
- '&:active': {
228
- backgroundColor: activeAndHoverColor,
229
- },
230
- }}
231
- >
232
- <Typography
233
- fontvariant="merrih6"
234
- text={subnav.title ?? ''}
235
- fontcolor={white.main}
236
- />
237
- </MenuItem>
238
- </Link>
239
- )
240
- } else {
86
+ const handleDropdownChange = useCallback(
87
+ (event: SelectChangeEvent<unknown>) => {
88
+ const newValue = event.target.value as string
89
+ setSelectedNav(newValue)
90
+ console.log('Dropdown selection changed to:', newValue)
91
+ },
92
+ []
93
+ )
94
+
95
+ const renderItem = useCallback(
96
+ (
97
+ item: NavProps | SubNav | View,
98
+ level: number,
99
+ activeAndHoverColor = semiTransparentWhite.main
100
+ ) => {
101
+ if ('title' in item && 'subnavs' in item) {
102
+ const nav = item as NavProps
103
+ const isExpanded = expandedNavs.includes(nav.title ?? '')
241
104
  return (
242
105
  <MuiAccordion
243
- key={subnav.title}
106
+ key={nav.title}
244
107
  disableGutters
245
108
  elevation={0}
246
109
  square
247
110
  expanded={isExpanded}
248
111
  onChange={() => {
249
112
  if (isExpanded) {
250
- setExpandedSubnavs(
251
- expandedSubnavs.filter(title => title !== subnav.title)
113
+ setExpandedNavs(
114
+ expandedNavs.filter(title => title !== nav.title)
252
115
  )
253
116
  } else {
254
- setExpandedSubnavs([...expandedSubnavs, subnav.title ?? ''])
117
+ setExpandedNavs([...expandedNavs, nav.title ?? ''])
255
118
  }
256
119
  }}
257
120
  sx={{
@@ -267,11 +130,13 @@ function VerticalVariant({
267
130
  >
268
131
  <AccordionSummary
269
132
  expandIcon={
270
- <ExpandMoreIcon
271
- sx={{
272
- color: 'transparent',
273
- }}
274
- />
133
+ nav.subnavs && nav.subnavs.length > 0 ? (
134
+ <ExpandMoreIcon
135
+ sx={{
136
+ color: 'transparent',
137
+ }}
138
+ />
139
+ ) : null
275
140
  }
276
141
  aria-controls="accordion-content"
277
142
  id="accordion-header"
@@ -279,8 +144,8 @@ function VerticalVariant({
279
144
  boxSizing: 'border-box',
280
145
  border: 'none',
281
146
  py: '6px',
282
- mt: 0,
283
- ml: '8px',
147
+ mt: 2,
148
+ ml: 3,
284
149
  minHeight: 0,
285
150
  height: '32px',
286
151
  '& .MuiAccordionSummary-content': {
@@ -297,58 +162,177 @@ function VerticalVariant({
297
162
  },
298
163
  },
299
164
  }}
165
+ onClick={() => handleNavClick(nav)}
300
166
  >
301
167
  <Typography
302
- fontvariant="merrih6"
168
+ fontvariant="merrih5"
303
169
  fontcolor={white.main}
304
- text={subnav.title ?? ''}
305
- marginLeft={4}
170
+ text={nav.title ?? ''}
171
+ marginLeft={4 * level}
306
172
  />
307
173
  </AccordionSummary>
308
174
  <AccordionDetails sx={{ border: 'none', p: 0 }}>
309
175
  <List sx={{ py: 0 }}>
310
- {subnav.views?.map(view =>
311
- renderItem(view, level + 1, activeAndHoverColor)
176
+ {nav.subnavs?.map(subnav =>
177
+ renderItem(subnav, level + 1, activeAndHoverColor)
312
178
  )}
313
179
  </List>
314
180
  </AccordionDetails>
315
181
  </MuiAccordion>
316
182
  )
317
- }
318
- } else if ('title' in item && 'route' in item) {
319
- const view = item as View
320
- return (
321
- <Link
322
- key={view.title}
323
- style={{
324
- textDecoration: 'none',
325
- color: 'white',
326
- }}
327
- href={view.route ?? ''}
328
- >
329
- <MenuItem
330
- sx={{
331
- color: white.main,
332
- pl: level + 6,
333
- '&:hover': {
334
- backgroundColor: activeAndHoverColor,
335
- },
336
- '&:active': {
337
- backgroundColor: activeAndHoverColor,
338
- },
183
+ } else if ('title' in item && 'views' in item) {
184
+ const subnav = item as SubNav
185
+ const isExpanded = expandedSubnavs.includes(subnav.title ?? '')
186
+ if (subnav.views?.length === 0) {
187
+ return (
188
+ <Link
189
+ key={subnav.title}
190
+ style={{
191
+ textDecoration: 'none',
192
+ color: 'white',
193
+ }}
194
+ href={subnav.route ?? ''}
195
+ >
196
+ <MenuItem
197
+ sx={{
198
+ color: white.main,
199
+ ml: '25px',
200
+ '&:hover': {
201
+ backgroundColor: activeAndHoverColor,
202
+ },
203
+ '&:active': {
204
+ backgroundColor: activeAndHoverColor,
205
+ },
206
+ }}
207
+ >
208
+ <Typography
209
+ fontvariant="merrih6"
210
+ text={subnav.title ?? ''}
211
+ fontcolor={white.main}
212
+ />
213
+ </MenuItem>
214
+ </Link>
215
+ )
216
+ } else {
217
+ return (
218
+ <MuiAccordion
219
+ key={subnav.title}
220
+ disableGutters
221
+ elevation={0}
222
+ square
223
+ expanded={isExpanded}
224
+ onChange={() => {
225
+ if (isExpanded) {
226
+ setExpandedSubnavs(
227
+ expandedSubnavs.filter(title => title !== subnav.title)
228
+ )
229
+ } else {
230
+ setExpandedSubnavs([...expandedSubnavs, subnav.title ?? ''])
231
+ }
232
+ }}
233
+ sx={{
234
+ pl: 0,
235
+ backgroundColor: 'transparent',
236
+ '.MuiAccordionSummary-root': {
237
+ pl: 0,
238
+ },
239
+ '&:before': {
240
+ display: 'none',
241
+ },
242
+ }}
243
+ >
244
+ <AccordionSummary
245
+ expandIcon={
246
+ <ExpandMoreIcon
247
+ sx={{
248
+ color: 'transparent',
249
+ }}
250
+ />
251
+ }
252
+ aria-controls="accordion-content"
253
+ id="accordion-header"
254
+ sx={{
255
+ boxSizing: 'border-box',
256
+ border: 'none',
257
+ py: '6px',
258
+ mt: 0,
259
+ ml: '8px',
260
+ minHeight: 0,
261
+ height: '32px',
262
+ '& .MuiAccordionSummary-content': {
263
+ m: 0,
264
+ },
265
+ '&:hover': {
266
+ '& .MuiSvgIcon-root': {
267
+ color: white.main,
268
+ },
269
+ },
270
+ '&.Mui-expanded': {
271
+ '& .MuiSvgIcon-root': {
272
+ color: white.main,
273
+ },
274
+ },
275
+ }}
276
+ >
277
+ <Typography
278
+ fontvariant="merrih6"
279
+ fontcolor={white.main}
280
+ text={subnav.title ?? ''}
281
+ marginLeft={4}
282
+ />
283
+ </AccordionSummary>
284
+ <AccordionDetails sx={{ border: 'none', p: 0 }}>
285
+ <List sx={{ py: 0 }}>
286
+ {subnav.views?.map(view =>
287
+ renderItem(view, level + 1, activeAndHoverColor)
288
+ )}
289
+ </List>
290
+ </AccordionDetails>
291
+ </MuiAccordion>
292
+ )
293
+ }
294
+ } else if ('title' in item && 'route' in item) {
295
+ const view = item as View
296
+ return (
297
+ <Link
298
+ key={view.title}
299
+ style={{
300
+ textDecoration: 'none',
301
+ color: 'white',
339
302
  }}
303
+ href={view.route ?? ''}
340
304
  >
341
- <Typography
342
- fontvariant="merriparagraph"
343
- text={view.title ?? ''}
344
- fontcolor={white.main}
345
- />
346
- </MenuItem>
347
- </Link>
348
- )
349
- }
350
- return null
351
- }
305
+ <MenuItem
306
+ sx={{
307
+ color: white.main,
308
+ pl: level + 6,
309
+ '&:hover': {
310
+ backgroundColor: activeAndHoverColor,
311
+ },
312
+ '&:active': {
313
+ backgroundColor: activeAndHoverColor,
314
+ },
315
+ }}
316
+ >
317
+ <Typography
318
+ fontvariant="merriparagraph"
319
+ text={view.title ?? ''}
320
+ fontcolor={white.main}
321
+ />
322
+ </MenuItem>
323
+ </Link>
324
+ )
325
+ }
326
+ return null
327
+ },
328
+ [
329
+ expandedNavs,
330
+ setExpandedNavs,
331
+ expandedSubnavs,
332
+ setExpandedSubnavs,
333
+ handleNavClick,
334
+ ]
335
+ )
352
336
 
353
337
  return (
354
338
  <Drawer
@@ -369,10 +353,7 @@ function VerticalVariant({
369
353
  },
370
354
  }}
371
355
  >
372
- <Box
373
- // @ts-ignore
374
- px={`15px`}
375
- >
356
+ <Box px={`15px`}>
376
357
  {showTitle && (
377
358
  <Box pt="0px" pb="0px">
378
359
  <Link
@@ -398,9 +379,7 @@ function VerticalVariant({
398
379
  outlinecolor="none"
399
380
  fontcolor={black.main}
400
381
  shrunkfontcolor={white.main}
401
- onChange={() => {
402
- console.log('Dropdown selection changed')
403
- }}
382
+ onChange={handleDropdownChange}
404
383
  />
405
384
  )}
406
385
  {showSearchbar && (
@@ -428,7 +407,14 @@ function VerticalVariant({
428
407
  }}
429
408
  />
430
409
  )}
431
- {items.map(item => renderItem(item, 0))}
410
+ {selectedNav
411
+ ? items
412
+ .filter(
413
+ (item): item is NavProps =>
414
+ 'title' in item && item.title === selectedNav
415
+ )
416
+ .map(item => renderItem(item, 0))
417
+ : items.map(item => renderItem(item, 0))}
432
418
  </Drawer>
433
419
  )
434
420
  }
@@ -31,6 +31,7 @@ const defaultConfig: PricingProps = {
31
31
  },
32
32
  // Configuration for package columns
33
33
  packagecolumns: {
34
+ packagenames: ['ThothOS', 'ThothOS Pro', 'ThothOS Enterprise'],
34
35
  columnconfig: {
35
36
  row: 1,
36
37
  column: 2,
@@ -43,7 +44,11 @@ const defaultConfig: PricingProps = {
43
44
  },
44
45
  // Configuration for monthly pricing
45
46
  monthlyprice: {
46
- prices: 'Monthly Pricing - $10',
47
+ prices: [
48
+ 'Monthly Pricing - $10',
49
+ 'Monthly Pricing - $20',
50
+ 'Monthly Pricing - $30',
51
+ ],
47
52
  columnconfig: {
48
53
  row: 2,
49
54
  column: 1,
@@ -56,7 +61,11 @@ const defaultConfig: PricingProps = {
56
61
  },
57
62
  // Configuration for annual pricing
58
63
  annualprice: {
59
- annualprices: 'Annual Pricing - $100',
64
+ annualprices: [
65
+ 'Annual Pricing - $100',
66
+ 'Annual Pricing - $200',
67
+ 'Annual Pricing - $300',
68
+ ],
60
69
  columnconfig: {
61
70
  row: 2,
62
71
  column: 2,
@@ -89,7 +98,7 @@ const defaultConfig: PricingProps = {
89
98
  alignment: 'left' as Alignment,
90
99
  },
91
100
  tiedtopackage: {
92
- tiedtopackages: 'true',
101
+ tiedtopackages: ['true', 'true', 'true'],
93
102
  columnconfig: {
94
103
  row: 1,
95
104
  column: 2,
@@ -114,7 +123,7 @@ const defaultConfig: PricingProps = {
114
123
  alignment: 'left' as Alignment,
115
124
  },
116
125
  tiedtopackage: {
117
- tiedtopackages: 'true',
126
+ tiedtopackages: ['true', 'true', 'true'],
118
127
  columnconfig: {
119
128
  row: 2,
120
129
  column: 2,
@@ -140,7 +149,7 @@ const defaultConfig: PricingProps = {
140
149
  alignment: 'left' as Alignment,
141
150
  },
142
151
  tiedtopackage: {
143
- tiedtopackages: 'true',
152
+ tiedtopackages: ['true', 'true', 'true'],
144
153
  columnconfig: {
145
154
  row: 3,
146
155
  column: 2,
@@ -167,7 +176,7 @@ const defaultConfig: PricingProps = {
167
176
  alignment: 'left' as Alignment,
168
177
  },
169
178
  tiedtopackage: {
170
- tiedtopackages: 'true',
179
+ tiedtopackages: ['true', 'true', 'true'],
171
180
  columnconfig: {
172
181
  row: 4,
173
182
  column: 2,
@@ -193,7 +202,7 @@ const defaultConfig: PricingProps = {
193
202
  alignment: 'left' as Alignment,
194
203
  },
195
204
  tiedtopackage: {
196
- tiedtopackages: 'true',
205
+ tiedtopackages: ['true', 'true', 'true'],
197
206
  columnconfig: {
198
207
  row: 5,
199
208
  column: 2,
@@ -219,7 +228,7 @@ const defaultConfig: PricingProps = {
219
228
  alignment: 'left' as Alignment,
220
229
  },
221
230
  tiedtopackage: {
222
- tiedtopackages: 'true',
231
+ tiedtopackages: ['true', 'true', 'true'],
223
232
  columnconfig: {
224
233
  row: 6,
225
234
  column: 2,
@@ -236,8 +245,12 @@ const defaultConfig: PricingProps = {
236
245
  ],
237
246
  // Configuration for button columns
238
247
  buttoncolumns: {
239
- buttontexts: 'Learn More',
240
- buttonlinks: '#goobs-frontend-unlimited',
248
+ buttontexts: ['Learn More', 'Learn More', 'Learn More'],
249
+ buttonlinks: [
250
+ '#goobs-frontend-unlimited',
251
+ '#goobs-frontend-unlimited',
252
+ '#goobs-frontend-unlimited',
253
+ ],
241
254
  columnconfig: {
242
255
  row: 7,
243
256
  column: 2,