Skip to content

Commit

Permalink
Fixed single item matches code (#410)
Browse files Browse the repository at this point in the history
* Fixed single item matches code

* Fixed comments

* added more unit tests, bug fixes

---------

Co-authored-by: hardikmashru <hardikmashru@iterable.com>
  • Loading branch information
hardikmashru and hardikmashru authored Jul 1, 2024
1 parent db1c7ae commit 0b1480e
Show file tree
Hide file tree
Showing 4 changed files with 409 additions and 82 deletions.
7 changes: 3 additions & 4 deletions react-example/src/views/AUTTesting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const AUTTesting: FC<Props> = () => {
);

const [cartItem, setCartItem] = useState<string>(
'{"items":[{"name":"piano","id":"fdsafds","price":100,"quantity":2}]}'
'{"items":[{"name":"piano","id":"fdsafds","price":100,"quantity":2}, {"name":"piano2","id":"fdsafds2","price":100,"quantity":5}]}'
);

const [purchaseItem, setPurchaseItem] = useState<string>(
Expand Down Expand Up @@ -59,7 +59,6 @@ export const AUTTesting: FC<Props> = () => {
const handleParseJson = (isUpdateCartCalled: boolean) => {
try {
// Parse JSON and assert its type
// {"items":[{"name":"piano","id":"fdsafds","price":100,"quantity":2}]}
if (isUpdateCartCalled) {
const parsedObject = JSON.parse(cartItem) as UpdateCartRequestParams;
return parsedObject;
Expand Down Expand Up @@ -109,11 +108,11 @@ export const AUTTesting: FC<Props> = () => {

const handleTrackPurchase = (e: FormEvent<HTMLFormElement>) => {
e.preventDefault();
const jsonObj = handleParseJson(false);
const jsonObj: TrackPurchaseRequestParams = handleParseJson(false);
if (jsonObj) {
setTrackingPurchase(true);
try {
trackPurchase({ ...jsonObj, total: 20 })
trackPurchase(jsonObj)
.then((response: any) => {
setTrackingPurchase(false);
setTrackPurchaseResponse(JSON.stringify(response.data));
Expand Down
Loading

0 comments on commit 0b1480e

Please sign in to comment.