Project created using Create React App.
A retailer offers a rewards program to its customers, awarding points based on each recorded purchase.
A customer receives 2 points for every dollar spent over $100 in each transaction, plus 1 point for every dollar spent between $50 and $100 in each transaction.
(e.g. a $120 purchase = 2x$20 + 1x$50 = 90 points). Given a record of every transaction during a three month period, calculate the reward points earned for each customer per month and total.
Assumption:- The record could be of many years so displaying the records of the latest three months in descending order and combined points as per customer ID for the last three months.
https://github.com/vibhavawasthi/Assignment_Infosys
npm install
npm start
npm test
The testcases file can be found in '/workspaces/Assign/src/RewardPointsCaluclator/tests/testCases.test.js'
The code has passed below test cases
calculatePoints function
✓ should handle negative amount
✓ should handle decimal amount
✓ should handle large amount like 1,000,000
✓ should calculate points correctly for amount over $100 (2 ms)
✓ should calculate points correctly for amount between $50 and $100
✓ should calculate points correctly for amount exactly $50
✓ should handle amount less than $50
processTransactions function
✓ should process transactions and calculate points correctly (1 ms)
✓ should handle empty transactions array
fetchTransactions
✓ should fetch transaction data successfully (1 ms)
✓ should handle 404 error (49 ms)
✓ should handle 500 error (3 ms)
✓ should handle other fetch errors (2 ms)
✓ should handle network errors (3 ms)
npm run build
Assumption:- The record could be of many years so displaying the records of the latest three months in descending order and combined points as per customer ID for the last three months.
To modify the json-server data, make changes to the file in public/transactionData.json
List of contributors:
- Vibhav Awasthi - Developer (vibhavawasthi54@gmail.com)