Git Product home page Git Product logo

dajr_david_michel_13_13_03_2023's People

Contributors

david-mi avatar

Watchers

 avatar

dajr_david_michel_13_13_03_2023's Issues

Add utils file

  • remove getToken method from User service and make it a function exported from utils file, named getStorageToken
  • Add getStorageTokenOrThrow method
  • Call it outside services, inside middlewares
  • Add setStorageToken
  • Add deleteStorageToken

display errors

  • remove generic error messages in reducers
  • custom error should show when failing login
  • custom error should display when failing form edit
  • remove error message in store when closing edit form

add Error middleware

  • add an error middleware to handle error type
  • add a MissingTokenErrorclass to handle missing tokens

Rework middlewares and reducers Logic

  • use normal Thunks instead of createAsyncThunk to have more sequencials actions
  • convert extraReducers to reducers
  • add authenticated and hasDisconnected to initial states

add Remember me functionnality

  • If remember me is checked, put token in localStorage on login submit succeed
  • if remember me is not checked put token in session storage on login submit succeed
  • on page load, if we find a token from local storage, check the box

prevent authenticated user from showing login page

  • Move useEffect from private to app.js, so it can applies for Login page also
  • remove login useEffect to disconnect if users got an error
  • Add useEffec in login to redirect user to profile page if authenticated

Simplify App.js logic

  • Remove hasDisconnected from the store
  • Remove conditions inside App.js useEffect
    Prefer this:
      useEffect(() => {
        dispatch(getProfileMiddleware);
      }, []);
  • Remove useSelectors from App.js

Refacto App.js

  • instead of having navProps variable, directly pass it to

add fields validation on edit form

  • use native html validation
  • use pattern attribute with regex
  • show error messages for both
  • show firstName and lastName as default input value on component render

Add Loaders

  • Add loaders for all 3 fetch requests
  • use svg
  • use fake delay for testing, conditionnal method in services
  • Disable form buttons when loading, to avoid multiple fetch requests (maybe add an abortController)
  • set inititial get status state to pending, to avoid enabling form buttons too early #40

rework global state structure

  • initial user slice state should have this structure :
const initialState = {
  firstName: "",
  lastName: "",
  email: "",
  get: {
    status: fetchStatus.PENDING,
    error: null
  },
  edit: {
    status: fetchStatus.IDLE,
    error: null
  },
  login: {
    status: fetchStatus.IDLE,
    error: null
  },
  authenticated: false
};
  • each rejected reducers should have an error message (for now only generic messages)

Migrate to TypeScript

  • make it in a separate branch and start it when you're sure almost everything else is finished
  • Make 2 Errors classes MissingTokenError and FetchError (I can't add status to a normal Error instance, typescript complains
  • Add hooks.ts with useAppDispatch and useAppSelector recommended by the documentation
  • Add global.d.ts with declare module '*.css'; to accept css modules

Renamings

  • rename SignForm to AuthForm
  • rename handler to loginFormHandler in Login
  • rename formEditHandler to editFormHandler in Profile
  • rename handlerto submitHandler in AuthForm

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.