-
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
Conversation
speed="0.65s" | ||
emptyColor="gray.200" | ||
size="xl" | ||
/> |
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
skill issue
Visit the preview URL for this PR (updated for commit c8b135f): https://blueprintsupportivehousing--pr214-kelly-spinner-gtn7bdnt.web.app (expires Sun, 10 Dec 2023 19:46:17 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: f6bcdba7452bf82a6ec1a299c37d1bdff7870d09 |
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.
this looks great however it would be nice if this spinner could also show when something is being added/edited/deleted (since it triggers a refetch of the table)
what you can do is have a loading state that's initially set to false. everytime you refetch new records (i.e. call getLogRecords()
), you can set the loading state to True
before the call, and then False
after the call
ex.
setIsLoading(True)
const data = await LogRecordAPIClient.filterLogRecords({
buildingId: buildingIds,
employeeId: employeeIds,
attnTo: attentionToIds,
dateRange: dateRange[0] === "" && dateRange[1] === "" ? [] : dateRange,
residents: residentsIds,
tags: tagsValues,
flagged,
resultsPerPage,
pageNumber,
});
setIsLoading(False)
that way the spinner can show on inital page renders AND adds/edits/deletes. the rest of the logic you implemented should be able to stay the same
@@ -375,7 +375,7 @@ const EditLog = ({ | |||
placeholder="Select Residents" | |||
onChange={handleResidentsChange} | |||
defaultValue={residentOptions.filter( | |||
(item) => logRecord.residents.includes(item.label), | |||
(item) => logRecord.residents && logRecord.residents.includes(item.label), |
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
speed="0.65s" | ||
emptyColor="gray.200" | ||
size="xl" | ||
/> |
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.
skill issue
{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 comment
The 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
// Initially set to false ; this way by DEFAULT we display the spinner
const [loadedUsers, setLoadedUsers] = useState(false)
// At the "onMount" useEffect (the one w no dependencies), we'd want to set the loaded users state to true
// The only reason I don't want to set it in the other useEffect as well is because from what I understand, we don't want to display the spinner for every batched fetch of users
useEffect(() => {
countUsers();
setLoadedUsers(true)
}, []);
// Then below in the JSX:
{!loadedUsers ? <Spinnner> : <other stuff>}
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.
LGTM 👍
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.
lgtm!!!
Notion task link
n/a
Implementation description
Steps to test
Checklist