Skip to content
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: Update additional info functionality #57

Conversation

mtreacy002
Copy link
Member

@mtreacy002 mtreacy002 commented Jul 28, 2020

Description

Allow useer to update theeir additional information

Fixes #48

Type of Change:

  • Code
  • User Interface

Code/Quality Assurance Only

  • New feature (non-breaking change which adds functionality pre-approved by mentors)

How Has This Been Tested?

  • Create 2 users on backend Swagger UI, one with additional information and the other without
  • Login as user that has no additional information in the database
  • Go to My Space > Personal Details > Additional Info
  • see message as below:

Screen Shot 2020-08-03 at 8 05 26 pm

  • Create additional information
  • On successful create, see message

Screen Shot 2020-08-03 at 8 05 57 pm

Notice how Timezone is skipped by user (which could happen either accidentally or on purpose if user prefer not to disclose their timezone). If this happens, the system will automatically use the default value of GMT+00 as user timezone. To test this, click away to different page and come back to My Spacee > Additional Info and see GMT being the value displayed from GET /user/additional_info request.
Screen Shot 2020-08-03 at 8 06 08 pm

  • to test Update, now edit the additional information. On successful update, see message below

Screen Shot 2020-08-03 at 8 06 18 pm

  • to check if the data is updated, again, click away to different page and come back to My Space > Additional Info and see the updated data (in this example, the timezone field)

Screen Shot 2020-08-03 at 8 06 33 pm

Checklist:

  • My PR follows the style guidelines of this project
  • I have performed a self-review of my own code or materials

Code/Quality Assurance Only

  • My changes generate no new warnings
  • My PR currently breaks something (fix or feature that would cause existing functionality to not work as expected)
  • New and existing unit tests pass locally with my changes

@mtreacy002 mtreacy002 self-assigned this Jul 28, 2020
@mtreacy002 mtreacy002 added Category: Coding Changes to code base or refactored code that doesn't fix a bug. Program: GSOC Related to work completed during the Google Summer of Code Program. labels Jul 28, 2020
@mtreacy002
Copy link
Member Author

Update @meenakshi-dhanani . This PR is still a WIP. I'm having trouble getting the selected value on Timezone when submitting the form. Everything else are there except the is_organization_rep. Can you please help me troubleshoot this?
Thanks

Screen Shot 2020-07-28 at 4 32 27 pm

Because of the missing timezone value, backend responded with payload invalid.

Screen Shot 2020-07-28 at 4 33 08 pm

@mtreacy002 mtreacy002 force-pushed the issue48-update-additional-background branch 3 times, most recently from 915bd26 to ffbd145 Compare August 1, 2020 08:45
@mtreacy002 mtreacy002 changed the title WIP | Feat: Update additional background functionality Feat: Update additional info functionality Aug 1, 2020
@mtreacy002 mtreacy002 requested review from meenakshi-dhanani and a team August 1, 2020 08:53
@mtreacy002
Copy link
Member Author

Update @anitab-org/bridgeintech-maintainers . Here's the PR for Create and Update User Additional Information. Please review when you have time. Thanks

@mtreacy002 mtreacy002 force-pushed the issue48-update-additional-background branch from ffbd145 to 1529a67 Compare August 1, 2020 12:42
@mtreacy002
Copy link
Member Author

Update @anitab-org/bridgeintech-maintainers. I just pushed a bug fix for default checked for is_organization_rep checkbox.

@mtreacy002 mtreacy002 force-pushed the issue48-update-additional-background branch from 1529a67 to e7f63ab Compare August 2, 2020 11:49
@mtreacy002
Copy link
Member Author

Update @anitab-org/bridgeintech-maintainers . I've just pushed the bug fix for when timezone is not selected. Now a default value will automatically added when user hit save if no value is selected.

@mtreacy002 mtreacy002 force-pushed the issue48-update-additional-background branch 2 times, most recently from ff31de5 to 4eaed7d Compare August 2, 2020 14:03
})
.catch(() => setErrorMessage("The service is temporarily unavailable, please try again later."));
.catch(() => setResponseMessage(SERVICE_UNAVAILABLE_ERROR));
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't it be update all the time?
why does it try to create and then if conflict update? If it's on this page, it should always try to update correct?

Copy link
Member Author

@mtreacy002 mtreacy002 Aug 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@meenakshi-dhanani . Because when user retrieve the page for the first time, the additional info would have not yet been created. The first response that user will see is No additional information found with your data. Please provide them now. Then users will need to fill their additional info. The first time they click Save button, this will send POST /user/additional_info request to backend. With this request, the data will be created.
But since we don't know which login user will already have created the additional information or not, every time user go to this page and fill in the information, on the Save button click the system would by default try to send POST request, which will return error message 409 Conflict, then will automatically send PUT request to continue with update information. Does this make sense?

Remember that we only have this one form/page to do both create (POST) and update (PUT) additional information. This POST and PUT will be similar later to Personal background. The Personal Details page Is the only one that is different since there is no POST /user/personal_details endpoint since the data for this is created through POST /register

add default value to is_organization_rep

Fix if else and fetch bug

Fix POST and PUT additional info

Fix bug defaultChecked checkbox is_organization_rep

fix bug timezone not selected

Refactor api requests to PUT for both create and update additional info
@mtreacy002 mtreacy002 force-pushed the issue48-update-additional-background branch from 4eaed7d to 7c87442 Compare August 3, 2020 10:08
@mtreacy002
Copy link
Member Author

Update @anitab-org/bridgeintech-maintainers . I've refactored this PR to reeflect the changes in backend api endpoint for POST and PUT to just PUT /user/additional_info ( PR 101 ). Please check when you have time.

@mtreacy002
Copy link
Member Author

Update @meenakshi-dhanani and @anitab-org/bridgeintech-maintainers . I've modified this PR to reflect the changes in backend API endpoint (PR 101). Please re-review if you have time.

Copy link
Contributor

@meenakshi-dhanani meenakshi-dhanani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@meenakshi-dhanani
Copy link
Contributor

There is a PR in the backend that this is based on. @ramitsawhney27 could you review the backend PR as well as this? I've reviewed both and they seem fine to me

Copy link

@foongminwong foongminwong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes made in this PR were tested locally. Following are the results:

  1. Code review - Done

  2. All possible responses were tested as below:

    • Test PR 57
      Screenshot/gif/url:

    test-bit-pr-57

    Expected Result: As a user, I should be able to update additional information.
    Actual Result: Same as expected.

  3. OS Version: Windows 10

@meenakshi-dhanani meenakshi-dhanani merged commit 0f8637d into anitab-org:develop Aug 10, 2020
Copy link

@foongminwong foongminwong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a test case for future reference:

{
  "is_organization_rep": true,
  "timezone": "America/New_York",
  "phone": "123-456-789",
  "mobile": "123-444-555",
  "personal_website": "https://africaa.com"
}

@mtreacy002 mtreacy002 deleted the issue48-update-additional-background branch September 12, 2020 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Coding Changes to code base or refactored code that doesn't fix a bug. Program: GSOC Related to work completed during the Google Summer of Code Program.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update User Additional Info
3 participants