Skip to content

Commit cfa9975

Browse files
committed
fix multi-select
1 parent 1637972 commit cfa9975

File tree

9 files changed

+173
-27
lines changed

9 files changed

+173
-27
lines changed

package-lock.json

Lines changed: 128 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"@mui/icons-material": "^6.4.7",
1212
"@mui/material": "^6.4.7",
1313
"@mui/x-date-pickers": "^7.27.3",
14+
"add": "^2.0.6",
1415
"arquero": "^8.0.1",
1516
"axios": "^1.6.7",
1617
"cors": "^2.8.5",
@@ -24,6 +25,7 @@
2425
"react-dom": "^19.0.0",
2526
"react-router": "^7.3.0",
2627
"react-router-dom": "^7.3.0",
28+
"react-select": "^5.10.1",
2729
"web-vitals": "^4.2.4"
2830
},
2931
"scripts": {

src/admin/ViewQRCode.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import DialogTitle from '@mui/material/DialogTitle';
88
import TextField from '@mui/material/TextField';
99
import Slider from '@mui/material/Slider';
1010
import QrCodeIcon from '@mui/icons-material/QrCode';
11-
import QRCode from 'qrcode.react';
11+
import { QRCodeCanvas } from 'qrcode.react';
1212

1313
interface ViewQRCodeProp {
1414
identity: string;
@@ -47,10 +47,10 @@ export default function ViewQRCode(props: ViewQRCodeProp) {
4747
<DialogContentText>
4848
The code will be valid for 30 minuites
4949
</DialogContentText>
50-
<QRCode
50+
<QRCodeCanvas
5151
size={size}
5252
value={props.qrCode.length > 1500 ? '' : props.qrCode}
53-
></QRCode>
53+
></QRCodeCanvas>
5454
<Slider
5555
defaultValue={512}
5656
min={64}

src/index.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
1-
// import React from 'react';
2-
import { Route, BrowserRouter, Routes } from 'react-router-dom';
3-
import ReactDOM from 'react-dom';
1+
import { createRoot } from 'react-dom/client';
2+
import { BrowserRouter, Routes, Route } from 'react-router-dom';
43
import Vis from './vis/Vis';
54
import Login from './admin/Login';
65
import AdminPortal from './admin/AdminPortal';
76
import './index.css';
87

9-
ReactDOM.render(
8+
// Get the root element
9+
const rootElement = document.getElementById('root');
10+
11+
// Make sure the element exists
12+
if (!rootElement) throw new Error('Failed to find the root element');
13+
14+
// Create a root
15+
const root = createRoot(rootElement);
16+
17+
// Render your app
18+
root.render(
1019
<BrowserRouter>
1120
<Routes>
1221
<Route path='/' element={<Vis />} />
@@ -23,6 +32,5 @@ ReactDOM.render(
2332
element={<AdminPortal page='edit-data' />}
2433
/>
2534
</Routes>
26-
</BrowserRouter>,
27-
document.getElementById('root'),
35+
</BrowserRouter>
2836
);

src/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type DisplayOption = {
2020
checked: boolean;
2121
};
2222

23-
type SiteStatus = 'active' | 'confirmed' | 'in-conversation';
23+
type SiteStatus = 'active' | 'confirmed' | 'in-conversation' | 'unknown';
2424

2525
type DeviceType = 'CPEL' | 'CPEH' | 'LGG8' | 'Pixel4';
2626

src/vis/DateSelect.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ const DateSelect = (props: SidebarProps) => {
3939
label='Start Date'
4040
value={dayjs(props.timeFrom)}
4141
onChange={handleChangeTimeFrom}
42+
disabled={!props.loading}
4243
/>
4344
<DateTimePicker
4445
label='End Date'
4546
value={dayjs(props.timeTo)}
4647
onChange={handleChangeTimeTo}
48+
disabled={!props.loading}
4749
/>
4850
</Stack>
4951
</LocalizationProvider>

src/vis/DeviceSelect.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import Typography from '@mui/material/Typography';
33
import Box from '@mui/material/Box';
4-
import { MultiSelect } from 'react-multi-select-component';
4+
import Select from 'react-select';
55
import { DEVICE_OPTIONS } from '../utils/config';
66
import '@fontsource/roboto';
77

@@ -12,22 +12,24 @@ interface SidebarProps {
1212
}
1313

1414
const DeviceSelect = (props: SidebarProps) => {
15-
const siteOptions = DEVICE_OPTIONS.map(({ label, value }) => ({
15+
const deviceOptions = DEVICE_OPTIONS.map(({ label, value }) => ({
1616
label: value,
1717
value: value,
1818
}));
19+
1920
return (
20-
<Box mb={2} style={{ zIndex: 1450 }}>
21+
<Box mb={2} sx={{ zIndex: 1450 }}>
2122
<Typography variant='overline'>Display markers</Typography>
22-
<MultiSelect
23-
options={siteOptions}
23+
<Select
24+
isMulti
25+
options={deviceOptions}
2426
value={props.selectedDevices}
25-
onChange={props.setSelectedDevices}
26-
labelledBy='Select'
27-
disabled={props.loading}
27+
onChange={(selected) => props.setSelectedDevices(selected as DeviceOption[])}
28+
isDisabled={props.loading}
29+
placeholder="Select..."
2830
/>
2931
</Box>
3032
);
3133
};
3234

33-
export default DeviceSelect;
35+
export default DeviceSelect;

src/vis/DisplaySelection.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export default function DisplaySelection(props: DisplayOptionsProps) {
5555
checked={option.checked}
5656
name={option.name}
5757
onChange={handleChange}
58+
disabled={!props.loading}
5859
/>
5960
}
6061
label={option.label}

0 commit comments

Comments
 (0)