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

Collect data from user and send it to API for coupon creation #2

Open
sync-by-unito bot opened this issue Jul 25, 2024 · 19 comments
Open

Collect data from user and send it to API for coupon creation #2

sync-by-unito bot opened this issue Jul 25, 2024 · 19 comments

Comments

@sync-by-unito
Copy link

sync-by-unito bot commented Jul 25, 2024

Goals

  1. Collect data from the user to create a coupon code and send it to the backend API.
  2. Implement a function to handle API requests for coupon creation and display the response on the frontend.
  3. Validate discount and date inputs, showing error messages for invalid entries.
  4. Validate the discount percentage against price deductions and remaining amount to pay.

Steps

Collect User Data:

  • Capture enterprise ID, discount percentage, and expiry date from user inputs.
  • Obtain token and CSRF token for API authentication.

Create API Request Function:

  • Develop a function to construct an HTTP POST request to the backend API.
  • Include required headers for authorization and CSRF token validation.
  • Send payload containing enterprise ID, discount percentage, and expiry date.

Handle API Response:

  • Parse the response from the backend API upon successful coupon creation.
  • Display the generated coupon code or any error messages returned by the API.

Implement Validations:

Discount Validation:

  • Ensure the discount value is numeric and within valid limits.
  • Display an error message if the discount is invalid.

Expiry Date Validation:

  • Validate the expiry date to ensure it allows sufficient time for redemption.
  • Show a warning message if the redemption period is inadequate.

Integrate Price Validation API:

  • Fetch API data to validate the discount percentage against expected price deductions.
  • Display a message indicating the amount deducted and the remaining amount to pay based on the discount.

Validation

Discount Input:

  • Validate numeric input for discount percentage.
  • Display an error if the input is invalid.

Expiry Date:

  • Validate the selected expiry date to ensure it allows sufficient time for coupon redemption.
  • Warn the user if the selected date restricts redemption too soon.

Acceptance Criteria

Functionality:

  • User inputs enterprise ID, discount percentage, and expiry date into the coupon creation form.
  • Data is sent to the backend API using a POST request with proper authentication tokens.
  • The API responds with a generated coupon code or error message, which is displayed on the frontend.

Validation:

  • Discount input validation ensures only numeric values and appropriate ranges are accepted.
  • Expiry date validation ensures sufficient time for coupon redemption is allowed.

Error Handling:

  • Display appropriate error messages if input data is invalid or if the API request fails.
  • Ensure the user receives feedback on successful coupon creation or encountered issues.

┆Issue is synchronized with this Jira Task by Unito
┆Attachments: Screenshot from 2024-07-23 17-30-07.png | Screenshot from 2024-07-23 17-30-33.png | Screenshot from 2024-07-23 17-31-07.png

Copy link
Author

sync-by-unito bot commented Jul 25, 2024

➤ Neeraja commented:

Work Summary - 10/07/2024
Worked on resolving the API integration issue and collaborating with the backend team to find a solution. Resolved “CORS” issue

Copy link
Author

sync-by-unito bot commented Jul 25, 2024

➤ Neeraja commented:

Work Summary - 11/07/2024

Continued working on resolving the API integration issue and collaborated with the backend team to find a solution. Fixed all issues except one caused by parsing errors in the data format sent from the frontend and the response received from the backend. Addressed this issue with the help of seniors and have come up with a solution. Will need to verify if it works; if not, a different approach will be required.

Copy link
Author

sync-by-unito bot commented Jul 25, 2024

➤ Neeraja commented:

Work Summary - 12/07/2024
Worked on resolving the API integration issue with the help of Nithin and discovered that the error may have occurred due to the CSRF token not being passed correctly in the headers. I tried various approaches to solve this issue, including using interceptors to identify the potential error causing the problem with the API integration.

To do: Examine the CSRF token issue further

Copy link
Author

sync-by-unito bot commented Jul 25, 2024

➤ Neeraja commented:

Work Summary - 15/07/2024
I have been working on resolving the API integration issue and identified that the CSRF token is not being fetched because it is undefined. It seems that the token is not being correctly set as it cannot be retrieved from cookies, likely due to the cookies not being set properly. This may be the reason why we are unable to get the CSRF token. I need to work on solving this issue.

Copy link
Author

sync-by-unito bot commented Jul 25, 2024

➤ Neeraja commented:

Work Summary - 16/07/2024
I temporarily put the coupon generation API on hold to focus on the subscription price discount calculation, but encountered the same error. I tried various solutions, but the issue persists. APIs defined within the same application endpoints work, but those with different endpoints do not, likely due to cross-platform activities. I sought help from Devi, but we couldn't find a solution. Now, I need to try sending data similarly to how it is sent in the mobile API.

Issues : Unexpectedly, while making changes for API integration, the Angular CLI and Node versions got upgraded, causing the application to fail to open. I tried different approaches to downgrade the versions, but the changes didn't take effect. I need to resolve this issue before addressing the actual problem.

Copy link
Author

sync-by-unito bot commented Jul 25, 2024

➤ Neeraja commented:

Work Summary - 17/07/2024

Worked on the issue mentioned in the previous comment. During the API integration process, the Angular CLI and Node versions were unexpectedly upgraded, causing the application to fail to open. Initially, I tried various approaches to downgrade the versions, but the errors persisted. This may have been due to caching issues from repeatedly upgrading and downgrading different versions of Node and Angular.
To solve the issue, I reverted the codebase to the state before any changes were made by fetching it directly from the repository. I then re-implemented the logic I had previously developed, ensuring the application now functions correctly.

Copy link
Author

sync-by-unito bot commented Jul 25, 2024

➤ Neeraja commented:

Work Summary - 18/07/2024

Worked on API integration for material price. Took help from Sathana V to solve some of the errors. Found some techniques to be implemented to solve the error and will try them out.

Copy link
Author

sync-by-unito bot commented Jul 25, 2024

➤ Neeraja commented:

Work Summary - 22/07/2024

Successfully completed the API integration for material prices by modifying the API call method. Applied a similar strategy for coupon code generation. Encountered an error due to recent backend code updates, but collaborated with the backend team and resolved the issue.Will have to check if this strategy works fine for coupon code generation

Copy link
Author

sync-by-unito bot commented Jul 25, 2024

➤ Neeraja commented:

Work Summary - 23/07/2024

Completed API integration for material price and coupon code generation. Successfully retrieved responses from the backend, performed necessary actions, and displayed the results on the frontend.
Pending task: Retrieve the token directly from the API instead of hard-coding it.

Copy link
Author

sync-by-unito bot commented Jul 25, 2024

➤ Neeraja commented:

Completed validations - Dialog Box without any selections

!Screenshot from 2024-07-23 17-30-07.png|width=1920,height=1080,alt="Screenshot from 2024-07-23 17-30-07.png"!

Copy link
Author

sync-by-unito bot commented Jul 25, 2024

➤ Neeraja commented:

Completed validations - Material price

!Screenshot from 2024-07-23 17-30-33.png|width=1920,height=1080,alt="Screenshot from 2024-07-23 17-30-33.png"!

Copy link
Author

sync-by-unito bot commented Jul 25, 2024

➤ Neeraja commented:

Completed validations - Coupon code generation

!Screenshot from 2024-07-23 17-31-07.png|width=1920,height=1080,alt="Screenshot from 2024-07-23 17-31-07.png"!

Copy link
Author

sync-by-unito bot commented Jul 25, 2024

➤ Neeraja commented:

Work Summary - 24/07/2024

Successfully retrieved the token directly from the API instead of hard-coding it and verified all functionalities within the local server setup. Everything worked fine. However, when the server's IP was changed, an unexpected error occurred: the client's connection to the server was closed whenever an API was hit. This issue needs to be addressed.

Copy link
Author

sync-by-unito bot commented Jul 25, 2024

➤ Neeraja commented:

Work Summary - 25/07/2024

The issue persists despite trying different methods. Will have to explore alternative approaches to resolve it.

Copy link
Author

sync-by-unito bot commented Aug 1, 2024

➤ Neeraja commented:

Work Summary - 26/07/2024

I worked on the issue today and explored various techniques, but unfortunately, the error remains unresolved. I'll need to consider alternative approaches to address the problem.

Copy link
Author

sync-by-unito bot commented Aug 1, 2024

➤ Neeraja commented:

Work Summary - 29/07/2024

I worked on the issue today and discovered that code that was previously functioning on the local server is now also failing. I received assistance from Nandha L , reverted the code to its original format, and then accessed the GitHub repository to clone the project. Despite reverting the code and making necessary changes to call the API, the same error persists. I am currently focused on resolving the new error that has arisen with the local server.

Copy link
Author

sync-by-unito bot commented Aug 1, 2024

➤ Neeraja commented:

Work Summary - 30/07/2024

Today, I set up a new project with just one API to isolate and address the error. Despite focusing on resolving the issue with this single API function, the error still persists.

Copy link
Author

sync-by-unito bot commented Aug 1, 2024

➤ Neeraja commented:

Work Summary - 31/07/2024

With Nandha L 's assistance, we determined that the error might be due to the “Content-Length” not being passed to the server. I will now try explicitly setting the Content-Length in the request header to resolve the issue.

Copy link
Author

sync-by-unito bot commented Aug 1, 2024

➤ Neeraja commented:

Work Summary - 01/08/2024

I explicitly set the “Content-Length” in the request header, but the issue persisted. With Nandha L's assistance, I then attempted to replicate the operation using plain HTML and JavaScript instead of Angular. I also set up a sample server locally to troubleshoot the error with a basic HTML and JavaScript setup, but the same error continues to occur. I will need to experiment with different “Content-Type” and “Content-Length” values to resolve the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants