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

Fixed single item matches code #410

Merged
merged 3 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading