AlexisTercero55 / contact-list

https://alexistercero55.github.io/contact-list/
1 stars 0 forks source link

New profile ACTION definition #12

Closed AlexisTercero55 closed 1 year ago

AlexisTercero55 commented 1 year ago
AlexisTercero55 commented 1 year ago

Define the Profiles/newProfile action

https://github.com/AlexisTercero55/contact-list/blob/73179bfe0244b956ee34c649eac03a88641f6e7e/src/context/ProfileContext.jsx#L31

export const ProfileActions = {
  changeProject : 'Profile/Project',
  deleteProfile : 'Profile/Delete',
  newProfile    : 'Profile/newProfile',
}

Reduce action newProfile

https://github.com/AlexisTercero55/contact-list/blob/73179bfe0244b956ee34c649eac03a88641f6e7e/src/context/ProfileContext.jsx#L63

case ProfileActions.newProfile:
      newState = [...state,ProfileData(
        payload.name,
        payload.email,
        'https://bootdey.com/img/Content/avatar/avatar4.png',
        payload.position,
        payload.projectID
      )]
      return newState;

Needs dynamic Avatar.

AlexisTercero55 commented 1 year ago

Dispatch that action from the new contact form

https://github.com/AlexisTercero55/contact-list/blob/73179bfe0244b956ee34c649eac03a88641f6e7e/src/App.jsx#L77

https://github.com/AlexisTercero55/contact-list/blob/73179bfe0244b956ee34c649eac03a88641f6e7e/src/App.jsx#L25

 const handleClose = (e) => {
    e?.preventDefault();
    if(e)
    {
      dispatch({
        type: ProfileActions.newProfile,
        payload: {
          name: name,
          position: position,
          email: mail,
          projectID: parseInt(projectID)
        }
      })

      setname('');
      setPosition('');
      setMail('');
      setprojectID('');

    }

    setShow(false);
  }
AlexisTercero55 commented 1 year ago

Review comments

ISSUE | Needs dynamic Avatar

Annotation on second comment raise issue #15 .