-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spinner #214
Spinner #214
Changes from 4 commits
e65cc1a
f75caba
8f551eb
38014ff
529ef90
c8b135f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import React, { useEffect, useRef, useState } from "react"; | ||
import { Box, Flex } from "@chakra-ui/react"; | ||
import { Box, Flex, Spinner } from "@chakra-ui/react"; | ||
|
||
import Pagination from "../../common/Pagination"; | ||
import NavigationBar from "../../common/NavigationBar"; | ||
|
@@ -13,7 +13,7 @@ import CreateEmployee from "../../forms/CreateEmployee"; | |
|
||
const EmployeeDirectoryPage = (): React.ReactElement => { | ||
const [users, setUsers] = useState<User[]>([]); | ||
const [numUsers, setNumUsers] = useState<number>(0); | ||
const [numUsers, setNumUsers] = useState<number>(-1); | ||
const [resultsPerPage, setResultsPerPage] = useState<number>(25); | ||
const [pageNum, setPageNum] = useState<number>(1); | ||
const [userPageNum, setUserPageNum] = useState(pageNum); | ||
|
@@ -71,23 +71,34 @@ const EmployeeDirectoryPage = (): React.ReactElement => { | |
/> | ||
</Flex> | ||
|
||
<EmployeeDirectoryTable | ||
users={users} | ||
tableRef={tableRef} | ||
userPageNum={userPageNum} | ||
setUserPageNum={setUserPageNum} | ||
getRecords={getUsers} | ||
countUsers={countUsers} | ||
/> | ||
<Pagination | ||
numRecords={numUsers} | ||
pageNum={pageNum} | ||
userPageNum={userPageNum} | ||
setUserPageNum={setUserPageNum} | ||
resultsPerPage={resultsPerPage} | ||
setResultsPerPage={setResultsPerPage} | ||
getRecords={getUsers} | ||
/> | ||
{numUsers < 0 ? ( | ||
<Spinner | ||
thickness="4px" | ||
speed="0.65s" | ||
emptyColor="gray.200" | ||
size="xl" | ||
/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there is no way to put these props in the default props section in the SpinnerStyles.tsx file. it just won't work. trust me, me and gpt have tried There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. skill issue There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So as Connor mentioned, the best way to implement this is usually using a state variable that simply keeps track of the loading state as a boolean ; we then would conditionally render the spinner only if "loading" is taking place. Here's a working snippet
|
||
) : ( | ||
connor-bechthold marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<Box> | ||
<EmployeeDirectoryTable | ||
users={users} | ||
tableRef={tableRef} | ||
userPageNum={userPageNum} | ||
setUserPageNum={setUserPageNum} | ||
getRecords={getUsers} | ||
countUsers={countUsers} | ||
/> | ||
<Pagination | ||
numRecords={numUsers} | ||
pageNum={pageNum} | ||
userPageNum={userPageNum} | ||
setUserPageNum={setUserPageNum} | ||
resultsPerPage={resultsPerPage} | ||
setResultsPerPage={setResultsPerPage} | ||
getRecords={getUsers} | ||
/> | ||
</Box> | ||
)} | ||
</Box> | ||
</Box> | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type { ComponentStyleConfig } from "@chakra-ui/theme"; | ||
|
||
// Spinner styling | ||
const Spinner: ComponentStyleConfig = { | ||
baseStyle: { | ||
color: "teal.400", | ||
marginTop: "5%", | ||
}, | ||
defaultProps: { | ||
size: "xl", | ||
}, | ||
}; | ||
|
||
export default Spinner; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there some sort of error that appears that required this to be changed? residents should never be null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't recall changing this file in this PR, but yeah there is some error that requires this to be changed. i believe owen made a pr for it