forked from nareshbhatia/react-testing-techniques
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProductView.tsx
29 lines (26 loc) · 874 Bytes
/
ProductView.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
import React from 'react';
import { NumberUtils } from '@react-force/number-utils';
import { Product } from '../../models';
import { HorizontalContainer } from '../Containers';
import './ProductView.css';
export interface ProductViewProps {
product: Product;
onClick: (productId: string) => void;
}
export const ProductView = ({ product, onClick }: ProductViewProps) => {
const { id, name, description, price, photo } = product;
return (
<HorizontalContainer
testId="product"
className="product paper border-paper items-center"
onClick={() => onClick(id)}
>
<img className="product__photo" src={photo} alt={name} />
<div className="ml-4">
<h3>{name}</h3>
<p className="mt-0">{description}</p>
<p className="mb-0">${NumberUtils.formatAsMoney(price)}</p>
</div>
</HorizontalContainer>
);
};