@campxdev/react-blueprint 0.1.52 → 0.1.54

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@campxdev/react-blueprint",
3
- "version": "0.1.52",
3
+ "version": "0.1.54",
4
4
  "main": "./export.ts",
5
5
  "private": false,
6
6
  "dependencies": {
package/src/App.tsx CHANGED
@@ -10,6 +10,7 @@ function App() {
10
10
  actions={[<p>asdjflsf</p>]}
11
11
  userFullName="Srikanth Yellapragada"
12
12
  collapsed={false}
13
+ institutionsData={[]}
13
14
  />
14
15
  </Providers>
15
16
  );
@@ -65,7 +65,7 @@ export const Tutorial = ({
65
65
  if (!userTours.includes(tourName)) {
66
66
  localStorage.setItem(
67
67
  "userTours",
68
- JSON.stringify([...JSON.parse(userTours), { ...reqData }])
68
+ JSON.stringify([...JSON.parse(userTours), tourName])
69
69
  );
70
70
  }
71
71
  await axios.post("/square/tours/complete", { reqData });
@@ -0,0 +1,45 @@
1
+ import { Box } from "@mui/material";
2
+ // const brokenImage = require("./broken-image.png");
3
+
4
+ interface ImageProps {
5
+ src: string;
6
+ alt: string;
7
+ height: string | number;
8
+ width: string | number;
9
+ fit?: "cover" | "contain" | "fill";
10
+ radius?: string | number;
11
+ defaultImage?: any;
12
+ }
13
+
14
+ export default function Image({
15
+ src,
16
+ alt,
17
+ height,
18
+ width,
19
+ fit = "contain",
20
+ radius = "10px",
21
+ defaultImage = null,
22
+ }: ImageProps) {
23
+ return (
24
+ <Box
25
+ sx={{
26
+ height: height,
27
+ width: width,
28
+ "& > img": {
29
+ borderRadius: radius,
30
+ width: "100%",
31
+ height: "100%",
32
+ objectFit: fit,
33
+ },
34
+ }}
35
+ >
36
+ <img
37
+ src={src || defaultImage}
38
+ alt={alt}
39
+ onError={(e: any) => {
40
+ e.target.src = defaultImage ? defaultImage : "";
41
+ }}
42
+ />
43
+ </Box>
44
+ );
45
+ }
@@ -14,6 +14,7 @@ export interface AppHeaderProps {
14
14
  userFullName: string;
15
15
  designation?: string;
16
16
  collapsed: boolean;
17
+ institutionsData?: any[];
17
18
  profileSx?: any;
18
19
  showActiveDevices?: boolean;
19
20
  }
@@ -26,6 +27,7 @@ export const AppHeader = ({
26
27
  clientName,
27
28
  userFullName,
28
29
  collapsed,
30
+ institutionsData,
29
31
  showActiveDevices = true,
30
32
  }: AppHeaderProps) => {
31
33
  return (
@@ -42,6 +44,7 @@ export const AppHeader = ({
42
44
  <UserBox
43
45
  fullName={userFullName}
44
46
  actions={[]}
47
+ institutionsData={institutionsData}
45
48
  profileSx={profileSx}
46
49
  designation={designation}
47
50
  showActiveDevices={showActiveDevices}
@@ -0,0 +1,100 @@
1
+ import { Box, Stack, TextField, Typography, styled } from "@mui/material";
2
+ import Cookies from "js-cookie";
3
+ import { useState } from "react";
4
+ import { isDevelopment } from "../../../../utils/constants";
5
+ import Image from "../../../Image/Image";
6
+
7
+ const SwitchInstitution = ({ close, institutions }: any) => {
8
+ const [searchText, setSearchText] = useState<string>("");
9
+
10
+ const filteredInstitutions = institutions?.filter((item: any) =>
11
+ item.name.toLowerCase().includes(searchText.toLowerCase())
12
+ );
13
+
14
+ return (
15
+ <Box sx={{ padding: "20px" }}>
16
+ <Stack>
17
+ <Typography variant="subtitle3" textAlign={"center"}>
18
+ Select an Institution
19
+ </Typography>
20
+
21
+ <TextField
22
+ label="Search Institution"
23
+ variant="outlined"
24
+ value={searchText}
25
+ sx={{
26
+ display: "flex",
27
+ alignItems: "center",
28
+ }}
29
+ fullWidth
30
+ onChange={(e) => setSearchText(e.target.value)}
31
+ />
32
+ </Stack>
33
+ <StyledInstitutionContainer>
34
+ {filteredInstitutions?.map((item: any, index: number) => (
35
+ <InstitutionCard institution={item} key={index} />
36
+ ))}
37
+ </StyledInstitutionContainer>
38
+ </Box>
39
+ );
40
+ };
41
+
42
+ const InstitutionCard = ({ institution }: any) => {
43
+ const handleClick = () => {
44
+ if (isDevelopment) {
45
+ Cookies.set("campx_institution", institution?.code);
46
+ } else {
47
+ }
48
+
49
+ window.location.replace(`${window.location.origin}/${institution?.code}`);
50
+ };
51
+
52
+ return (
53
+ <StyledInstitutionCard onClick={handleClick}>
54
+ <Image
55
+ alt="logo"
56
+ height={"100px"}
57
+ width="100%"
58
+ src={institution?.imageSquare?.url}
59
+ />
60
+ <Typography variant="body2">{institution?.name}</Typography>
61
+ </StyledInstitutionCard>
62
+ );
63
+ };
64
+
65
+ const StyledInstitutionCard = styled(Box)(({ theme }) => ({
66
+ display: "flex",
67
+ flexDirection: "column",
68
+ alignItems: "center",
69
+ gap: "20px",
70
+ padding: "14px",
71
+ border: "1px solid black",
72
+ borderRadius: "10px",
73
+ cursor: "pointer",
74
+ width: "200px",
75
+ flexShrink: 0,
76
+ }));
77
+
78
+ export const StyledInstitutionContainer = styled(Box)(({ theme }) => ({
79
+ marginTop: "20px",
80
+ display: "flex",
81
+ justifyContent: "center",
82
+ padding: "20px",
83
+ flexWrap: "wrap",
84
+ gap: "20px",
85
+ "&::-webkit-scrollbar": {
86
+ width: "0.5em",
87
+ height: "0.5em",
88
+ backgroundColor: "rgba(0, 0, 0, 0.1)",
89
+ },
90
+ "&::-webkit-scrollbar-thumb": {
91
+ backgroundColor: "rgba(0, 0, 0, 0.2)",
92
+ borderRadius: "3px",
93
+
94
+ "&:hover": {
95
+ background: "rgba(0, 0, 0, 0.3)",
96
+ },
97
+ },
98
+ }));
99
+
100
+ export default SwitchInstitution;
@@ -1,8 +1,11 @@
1
- import { Avatar, Stack, Typography, useTheme } from "@mui/material";
1
+ import { Avatar, Box, Stack, Typography, useTheme } from "@mui/material";
2
2
  import { ReactNode } from "react";
3
+ import DialogButton from "../../../Navigation/DialogButton/DialogButton";
3
4
  import { DropdownMenu } from "../../../Navigation/DropDownMenu/DropDownMenu";
4
5
  import { DropdownMenuItem } from "../../../Navigation/DropDownMenu/DropdownMenuItem";
6
+ import { StyledMenuItem } from "../../../Navigation/DropDownMenu/styles";
5
7
  import { Icons } from "../../../export";
8
+ import SwitchInstitution from "./SwitchInstitution";
6
9
 
7
10
  const getStartingLetters = (text: string) => {
8
11
  if (!text) return "";
@@ -18,12 +21,14 @@ export default function UserBox({
18
21
  actions,
19
22
  profileUrl,
20
23
  profileSx = {},
24
+ institutionsData,
21
25
  avatar = true, // Make avatar optional, default to true
22
26
  navigationIcon = true, // Make navigationIcon optional, default to true
23
27
  showActiveDevices = true, // Make active devices optional, default to true
24
28
  }: {
25
29
  fullName: string;
26
30
  designation?: string;
31
+ institutionsData?: any[];
27
32
  actions: {
28
33
  label: ReactNode;
29
34
  icon?: ReactNode;
@@ -39,75 +44,102 @@ export default function UserBox({
39
44
  const theme = useTheme();
40
45
 
41
46
  return (
42
- <DropdownMenu
43
- anchor={({ open }) => (
44
- <Avatar src={profileUrl ?? ""} onClick={open} sx={profileSx}>
45
- {getStartingLetters(fullName)}
46
- </Avatar>
47
- )}
48
- menuListProps={{
49
- sx: {
50
- width: "300px",
51
- borderRadius: "5px",
52
- },
53
- }}
54
- menu={[
55
- <DropdownMenuItem
56
- label={
57
- <Stack gap={0.5} sx={{ width: "100%" }}>
58
- <Typography variant="subtitle3">Account</Typography>
59
- <Stack
60
- direction={"row"}
61
- alignItems={"center"}
62
- justifyContent={"space-between"}
63
- >
64
- {avatar && (
65
- <Stack direction={"row"} gap={1}>
66
- <Avatar src={profileUrl ?? ""} sx={profileSx}>
67
- {getStartingLetters(fullName)}
68
- </Avatar>
69
- <Stack direction={"row"} justifyContent={"space-between"}>
70
- <Stack>
71
- <Typography variant="subtitle3">{fullName}</Typography>
72
- <Typography variant="caption">{designation}</Typography>
47
+ <>
48
+ <DropdownMenu
49
+ anchor={({ open }) => (
50
+ <Avatar src={profileUrl ?? ""} onClick={open} sx={profileSx}>
51
+ {getStartingLetters(fullName)}
52
+ </Avatar>
53
+ )}
54
+ menuListProps={{
55
+ sx: {
56
+ width: "300px",
57
+ borderRadius: "5px",
58
+ },
59
+ }}
60
+ menu={[
61
+ <DropdownMenuItem
62
+ label={
63
+ <Stack gap={0.5} sx={{ width: "100%" }}>
64
+ <Typography variant="subtitle3">Account</Typography>
65
+ <Stack
66
+ direction={"row"}
67
+ alignItems={"center"}
68
+ justifyContent={"space-between"}
69
+ >
70
+ {avatar && (
71
+ <Stack direction={"row"} gap={1}>
72
+ <Avatar src={profileUrl ?? ""} sx={profileSx}>
73
+ {getStartingLetters(fullName)}
74
+ </Avatar>
75
+ <Stack direction={"row"} justifyContent={"space-between"}>
76
+ <Stack>
77
+ <Typography variant="subtitle3">
78
+ {fullName}
79
+ </Typography>
80
+ <Typography variant="caption">
81
+ {designation}
82
+ </Typography>
83
+ </Stack>
73
84
  </Stack>
74
85
  </Stack>
75
- </Stack>
76
- )}
77
- {navigationIcon && <Icons.NavigationIcon />}
86
+ )}
87
+ {navigationIcon && <Icons.NavigationIcon />}
88
+ </Stack>
78
89
  </Stack>
79
- </Stack>
80
- }
81
- onClick={() => alert("Action 1 clicked")}
82
- />,
83
- showActiveDevices && (
90
+ }
91
+ onClick={() => alert("Action 1 clicked")}
92
+ />,
93
+ showActiveDevices && (
94
+ <DropdownMenuItem
95
+ label={
96
+ <Stack gap={0.5}>
97
+ <Typography variant="subtitle3">Active Devices</Typography>
98
+ </Stack>
99
+ }
100
+ onClick={() => alert("Action 1 clicked")}
101
+ />
102
+ ),
103
+ <Box>
104
+ <DialogButton
105
+ anchor={({ open }) => (
106
+ <StyledMenuItem
107
+ onClick={() => {
108
+ open();
109
+ }}
110
+ >
111
+ Change Institution
112
+ </StyledMenuItem>
113
+ )}
114
+ content={({ close }) => (
115
+ <SwitchInstitution
116
+ close={close}
117
+ institutions={institutionsData}
118
+ />
119
+ )}
120
+ title=""
121
+ />
122
+ </Box>,
123
+
84
124
  <DropdownMenuItem
85
125
  label={
86
- <Stack gap={0.5}>
87
- <Typography variant="subtitle3">Active Devices</Typography>
126
+ <Stack
127
+ gap={0.5}
128
+ direction={"row"}
129
+ justifyContent={"space-between"}
130
+ width={"100%"}
131
+ >
132
+ <Typography variant="subtitle3">Logout</Typography>
133
+ <Icons.LogoutIcon
134
+ hoverColor={theme.palette.tertiary.main}
135
+ size={20}
136
+ />
88
137
  </Stack>
89
138
  }
90
139
  onClick={() => alert("Action 1 clicked")}
91
- />
92
- ),
93
- <DropdownMenuItem
94
- label={
95
- <Stack
96
- gap={0.5}
97
- direction={"row"}
98
- justifyContent={"space-between"}
99
- width={"100%"}
100
- >
101
- <Typography variant="subtitle3">Logout</Typography>
102
- <Icons.LogoutIcon
103
- hoverColor={theme.palette.tertiary.main}
104
- size={20}
105
- />
106
- </Stack>
107
- }
108
- onClick={() => alert("Action 1 clicked")}
109
- />,
110
- ]}
111
- />
140
+ />,
141
+ ]}
142
+ />
143
+ </>
112
144
  );
113
145
  }
@@ -1,9 +1,6 @@
1
1
  import Cookies from "js-cookie";
2
2
 
3
- export const isDevelopment: boolean =
4
- process.env.NODE_ENV === "development" ||
5
- window.location.origin.split("campx")[1] === ".dev";
6
-
3
+ export const isDevelopment: boolean = process.env.NODE_ENV === "development";
7
4
  export const urlTenantKey = window.location.pathname.split("/")[1];
8
5
  export const institutionKey = window.location.pathname.split("/")[2];
9
6
  export const sessionKey = Cookies.get("campx_session_key");