Skip to content

Commit

Permalink
added Semantic Versioning actions
Browse files Browse the repository at this point in the history
  • Loading branch information
JeelRajodiya committed Jul 8, 2023
1 parent c72c881 commit efc9650
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/Semantic Versioning.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- name: Git Semantic Version
uses: PaulHatch/[email protected]
13 changes: 12 additions & 1 deletion lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export type MySession = {
};
} | null;

export type UserDataOnClient = Exclude<
export type ReceivedUserDataOnClient = Exclude<
UserCol,
| "courses"
| "notifications"
Expand All @@ -38,3 +38,14 @@ export type UserDataOnClient = Exclude<
| "seenNotificationsCount"
| "passwordHash"
>;
export type SentUserDataFromClient = Exclude<
UserCol,
| "courses"
| "notifications"
| "seenNotifications"
| "notificationsCount"
| "seenNotificationsCount"
| "passwordHash"
> & {
password: string;
};
38 changes: 33 additions & 5 deletions pages/Admin/Users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import Layout from "../Layout";
import {
Button,
FormControl,
FormHelperText,
FormLabel,
InputGroup,
InputLeftElement,
InputRightElement,
Expand All @@ -12,7 +14,10 @@ import {
useDisclosure,
} from "@chakra-ui/react";
import useSWR from "swr";
import { UserDataOnClient } from "../../lib/types";
import {
ReceivedUserDataOnClient,
SentUserDataFromClient,
} from "../../lib/types";
import { useState } from "react";
import { Badge } from "@chakra-ui/react";
import { useToast } from "@chakra-ui/react";
Expand All @@ -36,13 +41,13 @@ function useSearch(searchQuery: string, role: string, page: number) {
fetcher
);
return {
users: data as UserDataOnClient[],
users: data as ReceivedUserDataOnClient[],
isLoading,
error: error,
};
}

function UserListItem({ userData }: { userData: UserDataOnClient }) {
function UserListItem({ userData }: { userData: ReceivedUserDataOnClient }) {
return (
<div className={styles.userListItem}>
<div>
Expand All @@ -61,7 +66,10 @@ export default function Users() {
const { isOpen, onOpen, onClose } = useDisclosure();
const [role, setRole] = useState("student");
const { users, isLoading, error } = useSearch(searchQuery, role, 1);
const [newUserData, setNewUserData] = useState<SentUserDataFromClient>();

const toast = useToast();

let componentToRender;
if (isLoading) {
componentToRender = <div>Loading...</div>;
Expand Down Expand Up @@ -123,9 +131,29 @@ export default function Users() {
<Modal isOpen={isOpen} onClose={onClose}>
<ModalOverlay />
<ModalContent>
<ModalHeader>Modal Title</ModalHeader>
<ModalHeader>Create new user</ModalHeader>
<ModalCloseButton />
<ModalBody></ModalBody>
<ModalBody>
<FormControl>
<FormLabel>Name</FormLabel>
<Input type="Text" />
<FormLabel>Role</FormLabel>
<RadioGroup defaultValue="Student">
<Stack spacing={5} direction="row">
<Radio value="Student">Student</Radio>
<Radio value="Faculty">Faculty</Radio>
<Radio value="Admin">Admin</Radio>
</Stack>
{/* Text for now, in future we will retrive all the houses */}
<FormLabel>House</FormLabel>
<Input type="text" />
<FormLabel>Email address</FormLabel>
<Input type="email" />
<FormLabel>Password</FormLabel>
<Input type="password" />
</RadioGroup>
</FormControl>
</ModalBody>

<ModalFooter>
<Button colorScheme="blue" mr={3} onClick={onClose}>
Expand Down

0 comments on commit efc9650

Please sign in to comment.