-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
Copy pathCheckoutItem.tsx
61 lines (56 loc) · 1.77 KB
/
CheckoutItem.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
import Image from 'next/image';
import { useState } from 'react';
import { CypressFields } from '../../utils/Cypress';
import { Address } from '../../protos/demo';
import { IProductCheckoutItem } from '../../types/Cart';
import ProductPrice from '../ProductPrice';
import * as S from './CheckoutItem.styled';
interface IProps {
checkoutItem: IProductCheckoutItem;
address: Address;
}
const CheckoutItem = ({
checkoutItem: {
item: {
quantity,
product: { picture, name },
},
cost = { currencyCode: 'USD', units: 0, nanos: 0 },
},
address: { streetAddress = '', city = '', state = '', zipCode = '', country = '' },
}: IProps) => {
const [isCollapsed, setIsCollapsed] = useState(false);
return (
<S.CheckoutItem data-cy={CypressFields.CheckoutItem}>
<S.ItemDetails>
<S.ItemImage src={"/images/products/" + picture} alt={name} />
<S.Details>
<S.ItemName>{name}</S.ItemName>
<p>Quantity: {quantity}</p>
<p>
Total: <ProductPrice price={cost} />
</p>
</S.Details>
</S.ItemDetails>
<S.ShippingData>
<S.ItemName>Shipping Data</S.ItemName>
<p>Street: {streetAddress}</p>
{!isCollapsed && <S.SeeMore onClick={() => setIsCollapsed(true)}>See More</S.SeeMore>}
{isCollapsed && (
<>
<p>City: {city}</p>
<p>State: {state}</p>
<p>Zip Code: {zipCode}</p>
<p>Country: {country}</p>
</>
)}
</S.ShippingData>
<S.Status>
<Image src="/icons/Check.svg" alt="check" height="14" width="16" /> <span>Done</span>
</S.Status>
</S.CheckoutItem>
);
};
export default CheckoutItem;