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
feat(react): sign in feature #2683
Conversation
partially moved from angularjs service
lacking footer, will probably do footer first then
# Conflicts: # frontend/__tests__/storyshots/jest.config.js # frontend/tsconfig.paths.json
# Conflicts: # frontend/package-lock.json # frontend/package.json
* Mock Service Worker (0.35.0). | ||
* @see https://github.com/mswjs/msw | ||
* - Please do NOT modify this file. | ||
* - Please do NOT serve this file on production. |
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 I ran npm run build
and saw that mockServiceWorker.js
is included in frontend/build
(which presumably will change to dist/frontend
once we configure it correctly). if we use app.use(express.static(path.resolve('dist/frontend')))
(as per #2675) will that mean someone would be able to get this file from form.gov.sg/mockServiceWorker.js
?
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.
Yes they would, but it would be useless because the service worker would not be registered anyways. I guess we can add a .dockerignore entry and it'll not be in the image
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.
sounds good
# Conflicts: # frontend/package-lock.json # frontend/package.json # frontend/src/app/App.tsx # frontend/src/pages/workspace/WorkspacePage.tsx
) | ||
|
||
// Grid area styling for the left sidebar that only displays on tablet and desktop breakpoints. | ||
const NonMobileSidebarGridArea: FC = ({ children }) => ( |
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.
JSX.Element? haha
we actually have some govt users with non-gov.sg emails
Problem
This PR implements the sign in feature, with mocked API calls using
msw
. This allows for the storybook to be rendered and working almost as close to the real thing (calling server endpoints) as possible.Closes #2489
Solution
Features:
Add LoginPage component and related stories. Subcomponent consists of
useInterval
hook.Add a bunch of new hooks to facilitate this feature:
useLocalStorage
used for storing logged in state (in favour of storying the user object, since the user object will be stale and can be fetched from the /user endpoint)useInterval
used for rendering updates in an intervaluseUser
basically a react-query hook to retrieve the current logged in userAuthContext/useAuth
hook providing a bunch of authentication related functionsAdd a bunch of services (copy-pasted from AngularJS folder) to facilitate this feature
axios
, but may switch towretched
?)Add
msw
package for mocking API calls. Used inside storybook (and locally, can be disabled when the server is up)Before & After Screenshots
Working flow in storybook
No need to scroll on smaller laptop screen resolutions
1366px x 768px desktop layout
1280px x 800px desktop layout
Deploy Notes
New dependencies:
react-query
for making api callsNew dev dependencies:
msw
for mocking network calls in appmsw-storybook-addon
for mocking network calls in storybook