Skip to content

Commit 6879236

Browse files
committed
Improve admin page UI
1 parent d48b728 commit 6879236

File tree

4 files changed

+55
-40
lines changed

4 files changed

+55
-40
lines changed

src/components/admin/AdminView.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const AdminView = () => {
2828
const setIsPendingStageEnabledMutation =
2929
trpc.admin.setIsPendingStageEnabled.useMutation();
3030

31+
// When the site settings are loaded, set the state to the current values
3132
useEffect(() => {
3233
if (siteSettings) {
3334
setIsPendingStageEnabled(
@@ -85,7 +86,7 @@ const AdminView = () => {
8586
<AdminList assignmentsOrLocationsProps={locations} isAssignment={false} />
8687
<Flex direction="column" mt={10} mb={3}>
8788
<Text fontSize="3xl" fontWeight="semibold">
88-
General Settings
89+
Settings
8990
</Text>
9091
<Flex>
9192
<Text fontSize="xl">Pending Stage</Text>

src/components/admin/ImportUsers.tsx

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Radio, RadioGroup, Stack, Text } from "@chakra-ui/react";
1+
import { Box, Flex, Radio, RadioGroup, Stack, Text } from "@chakra-ui/react";
22
import { UserRole } from "@prisma/client";
33
import { useState } from "react";
44
import { trpc } from "../../utils/trpc";
@@ -42,11 +42,24 @@ const ImportUsers = () => {
4242
</Radio>
4343
</Stack>
4444
</RadioGroup>
45-
{importType === ImportNumberPossibilities.BATCH_IMPORT ? (
46-
<BatchImporter handleAddUsers={handleAddUsers} />
47-
) : (
48-
<SingleImporter handleAddUsers={handleAddUsers} />
49-
)}
45+
46+
<Flex
47+
mt={2}
48+
hidden={importType === ImportNumberPossibilities.SINGLE_IMPORT}
49+
>
50+
<Text>
51+
The CSV should have 2 columns. One for email and one for role (
52+
{Object.values(UserRole).join(" or ")})
53+
</Text>
54+
</Flex>
55+
56+
<Box mt={2} mb={6}>
57+
{importType === ImportNumberPossibilities.BATCH_IMPORT ? (
58+
<BatchImporter handleAddUsers={handleAddUsers} />
59+
) : (
60+
<SingleImporter handleAddUsers={handleAddUsers} />
61+
)}
62+
</Box>
5063
</>
5164
);
5265
};

src/components/admin/ImportUsersMethod.tsx

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
Button,
3+
Divider,
34
Flex,
45
Input,
56
Radio,
@@ -154,33 +155,26 @@ const ImportUsersMethod = () => {
154155
Only allow students from from email domain (Leave blank for all
155156
domains)
156157
</Text>
157-
<Input
158-
placeholder="@berkeley.edu"
159-
value={emailDomain}
160-
onChange={handleDomainChange}
161-
maxLength={25}
162-
/>
163-
<Button
164-
mt={2}
165-
colorScheme="telegram"
166-
onClick={handleDomainSubmit}
167-
disabled={!isValidDomain}
168-
>
169-
Confirm
170-
</Button>
158+
<Flex direction="row">
159+
<Input
160+
placeholder="@berkeley.edu"
161+
value={emailDomain}
162+
onChange={handleDomainChange}
163+
maxLength={25}
164+
mr={1}
165+
/>
166+
<Button
167+
colorScheme="telegram"
168+
onClick={handleDomainSubmit}
169+
disabled={!isValidDomain}
170+
>
171+
Confirm
172+
</Button>
173+
</Flex>
171174
</Flex>
172175

173-
<Flex mt={2}>
174-
<Text>
175-
The CSV should have 2 columns. One for email and one for role (
176-
{isImportStaffAndStudents ? "STUDENT OR " : ""}
177-
STAFF or INTERN)
178-
</Text>
179-
</Flex>
176+
<Divider mt={2} mb={2} />
180177

181-
<Text mb={2} fontSize="sm" hidden={isImportStaffAndStudents}>
182-
Please still specify STAFF or INTERN role when importing.
183-
</Text>
184178
<ImportUsers />
185179
</Flex>
186180
);

src/components/admin/import/SingleImporter.tsx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Button, Flex, Input, useToast } from "@chakra-ui/react";
1+
import { Button, Flex, FormControl, Input, useToast } from "@chakra-ui/react";
22
import { UserRole } from "@prisma/client";
33
import { Select, SingleValue } from "chakra-react-select";
44
import { useState } from "react";
@@ -55,6 +55,8 @@ const SingleImporter = ({ handleAddUsers }: SingleImporterProps) => {
5555
position: "top-right",
5656
}),
5757
);
58+
59+
setEmail("");
5860
};
5961

6062
const userRoles = Object.values(UserRole).map((role: UserRole) => ({
@@ -65,18 +67,23 @@ const SingleImporter = ({ handleAddUsers }: SingleImporterProps) => {
6567
return (
6668
<Flex direction="row">
6769
<Input
70+
mr={1}
6871
placeholder="Input email"
69-
w="400px"
7072
value={email}
7173
onChange={(e) => setEmail(e.target.value)}
7274
/>
73-
<Select
74-
options={userRoles}
75-
onChange={(val: SingleValue<{ label: UserRole; value: UserRole }>) =>
76-
setRole(val?.value)
77-
}
78-
/>
79-
<Button onClick={handleAddUser}>Import</Button>
75+
<FormControl width="20%" mr={1}>
76+
<Select
77+
placeholder="Role"
78+
options={userRoles}
79+
onChange={(val: SingleValue<{ label: UserRole; value: UserRole }>) =>
80+
setRole(val?.value)
81+
}
82+
/>
83+
</FormControl>
84+
<Button colorScheme="telegram" onClick={handleAddUser}>
85+
Import
86+
</Button>
8087
</Flex>
8188
);
8289
};

0 commit comments

Comments
 (0)