From 82e03978b89938219958032efb1448cc76baa181 Mon Sep 17 00:00:00 2001 From: Saumit Date: Sat, 27 Sep 2025 02:14:26 +0530 Subject: Initial snapshot - OpenTelemetry demo 2.1.3 -f --- .../components/CheckoutForm/CheckoutForm.styled.ts | 59 ++++++ .../components/CheckoutForm/CheckoutForm.tsx | 202 +++++++++++++++++++++ src/frontend/components/CheckoutForm/index.ts | 4 + 3 files changed, 265 insertions(+) create mode 100644 src/frontend/components/CheckoutForm/CheckoutForm.styled.ts create mode 100644 src/frontend/components/CheckoutForm/CheckoutForm.tsx create mode 100644 src/frontend/components/CheckoutForm/index.ts (limited to 'src/frontend/components/CheckoutForm') diff --git a/src/frontend/components/CheckoutForm/CheckoutForm.styled.ts b/src/frontend/components/CheckoutForm/CheckoutForm.styled.ts new file mode 100644 index 0000000..c11ebc5 --- /dev/null +++ b/src/frontend/components/CheckoutForm/CheckoutForm.styled.ts @@ -0,0 +1,59 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +import styled from 'styled-components'; +import Button from '../Button'; + +export const CheckoutForm = styled.form``; + +export const StateRow = styled.div` + display: grid; + grid-template-columns: 35% 55%; + gap: 10%; +`; + +export const Title = styled.h1` + margin: 0; + margin-bottom: 24px; +`; + +export const CardRow = styled.div` + display: grid; + grid-template-columns: 35% 35% 20%; + gap: 5%; +`; + +export const SubmitContainer = styled.div` + display: flex; + justify-content: center; + align-items: center; + gap: 20px; + flex-direction: column-reverse; + + ${({ theme }) => theme.breakpoints.desktop} { + flex-direction: row; + justify-content: end; + align-items: center; + margin-top: 67px; + } +`; + +export const CartButton = styled(Button)` + padding: 16px 35px; + font-weight: ${({ theme }) => theme.fonts.regular}; + width: 100%; + + ${({ theme }) => theme.breakpoints.desktop} { + width: inherit; + } +`; + +export const EmptyCartButton = styled(Button)` + font-weight: ${({ theme }) => theme.fonts.regular}; + color: ${({ theme }) => theme.colors.otelRed}; + width: 100%; + + ${({ theme }) => theme.breakpoints.desktop} { + width: inherit; + } +`; diff --git a/src/frontend/components/CheckoutForm/CheckoutForm.tsx b/src/frontend/components/CheckoutForm/CheckoutForm.tsx new file mode 100644 index 0000000..1c8e5c9 --- /dev/null +++ b/src/frontend/components/CheckoutForm/CheckoutForm.tsx @@ -0,0 +1,202 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +import Link from 'next/link'; +import { useCallback, useState } from 'react'; +import { CypressFields } from '../../utils/enums/CypressFields'; +import Input from '../Input'; +import * as S from './CheckoutForm.styled'; + +const currentYear = new Date().getFullYear(); +const yearList = Array.from(new Array(20), (v, i) => i + currentYear); + +export interface IFormData { + email: string; + streetAddress: string; + city: string; + state: string; + country: string; + zipCode: string; + creditCardNumber: string; + creditCardCvv: number; + creditCardExpirationYear: number; + creditCardExpirationMonth: number; +} + +interface IProps { + onSubmit(formData: IFormData): void; +} + +const CheckoutForm = ({ onSubmit }: IProps) => { + const [ + { + email, + streetAddress, + city, + state, + country, + zipCode, + creditCardCvv, + creditCardExpirationMonth, + creditCardExpirationYear, + creditCardNumber, + }, + setFormData, + ] = useState({ + email: 'someone@example.com', + streetAddress: '1600 Amphitheatre Parkway', + city: 'Mountain View', + state: 'CA', + country: 'United States', + zipCode: "94043", + creditCardNumber: '4432-8015-6152-0454', + creditCardCvv: 672, + creditCardExpirationYear: 2030, + creditCardExpirationMonth: 1, + }); + + const handleChange = useCallback((e: React.ChangeEvent) => { + setFormData(formData => ({ + ...formData, + [e.target.name]: e.target.value, + })); + }, []); + + return ( + void; }) => { + event.preventDefault(); + onSubmit({ + email, + streetAddress, + city, + state, + country, + zipCode, + creditCardCvv, + creditCardExpirationMonth, + creditCardExpirationYear, + creditCardNumber, + }); + }} + > + Shipping Address + + + + + + + + + + + +
+ Payment Method +
+ + + + + + + + + + + + + + + + + + + + {yearList.map(year => ( + + ))} + + + + + + + Continue Shopping + + Place Order + +
+ ); +}; + +export default CheckoutForm; diff --git a/src/frontend/components/CheckoutForm/index.ts b/src/frontend/components/CheckoutForm/index.ts new file mode 100644 index 0000000..897f43b --- /dev/null +++ b/src/frontend/components/CheckoutForm/index.ts @@ -0,0 +1,4 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +export { default } from './CheckoutForm'; -- cgit v1.2.3