Skip to content

Commit 76c0c91

Browse files
Berardo Matègiacomosardo
authored andcommitted
feat: new address form bottom component
1 parent 29b41dd commit 76c0c91

8 files changed

Lines changed: 70 additions & 21 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { useTranslation } from "react-i18next"
2+
3+
import { AddressSectionSaveOnAddressBook } from "../AddressSectionSaveOnAddressBook"
4+
5+
import { LinkButton } from "components/ui/LinkButton"
6+
7+
import { Wrapper } from "./styled"
8+
9+
interface Props {
10+
addressType: "billing" | "shipping"
11+
onClick?: () => void
12+
className?: string
13+
}
14+
15+
export const AddressFormBottom: React.FC<Props> = ({
16+
addressType,
17+
onClick,
18+
className,
19+
}) => {
20+
const { t } = useTranslation()
21+
22+
return (
23+
<Wrapper className={className}>
24+
<AddressSectionSaveOnAddressBook addressType={addressType} />
25+
<LinkButton label={t("stepCustomer.closeForm")} onClick={onClick} />
26+
</Wrapper>
27+
)
28+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import styled from "styled-components"
2+
import tw from "twin.macro"
3+
4+
export const Wrapper = styled.div`
5+
${tw`flex justify-between`}
6+
`

components/composite/StepCustomer/CheckoutCustomerAddresses.tsx

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ import { GridContainer } from "components/ui/GridContainer"
2020
import { SpinnerIcon } from "components/ui/SpinnerIcon"
2121
import { Toggle } from "components/ui/Toggle"
2222

23+
import { AddressFormBottom } from "./AddressFormBottom"
2324
import { AddressSectionEmail } from "./AddressSectionEmail"
2425
import { AddressSectionSaveForm } from "./AddressSectionSaveForm"
25-
import { AddressSectionSaveOnAddressBook } from "./AddressSectionSaveOnAddressBook"
2626
import { AddressSectionTitle } from "./AddressSectionTitle"
2727
import { BillingAddressFormNew } from "./BillingAddressFormNew"
2828
import { ShippingAddressFormNew } from "./ShippingAddressFormNew"
@@ -163,15 +163,10 @@ export const CheckoutCustomerAddresses: React.FC<Props> = ({
163163
{mountBillingAddressForm ? (
164164
<>
165165
<BillingAddressFormNew billingAddress={billingAddressFill} />
166-
<div className="flex justify-between" key="actionsWrapper">
167-
<AddressSectionSaveOnAddressBook addressType="billing" />
168-
<p
169-
className="font-extrabold text-red-400 border-b border-red-100 cursor-pointer text-ss"
170-
onClick={handleShowBillingForm}
171-
>
172-
Close
173-
</p>
174-
</div>
166+
<AddressFormBottom
167+
addressType="billing"
168+
onClick={handleShowBillingForm}
169+
/>
175170
</>
176171
) : (
177172
<Fragment />
@@ -244,15 +239,11 @@ export const CheckoutCustomerAddresses: React.FC<Props> = ({
244239
<ShippingAddressFormNew
245240
shippingAddress={shippingAddressFill}
246241
/>
247-
<div className="flex justify-between mb-4">
248-
<AddressSectionSaveOnAddressBook addressType="shipping" />
249-
<p
250-
className="font-extrabold text-red-400 border-b border-red-100 cursor-pointer text-ss"
251-
onClick={handleShowShippingForm}
252-
>
253-
Close
254-
</p>
255-
</div>
242+
<AddressFormBottom
243+
addressType="shipping"
244+
onClick={handleShowShippingForm}
245+
className="mb-4"
246+
/>
256247
</>
257248
) : (
258249
<Fragment />

components/ui/LinkButton/index.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import LinkButtonProps from "./props"
2+
import { Button } from "./styled"
3+
4+
export const LinkButton: React.FC<LinkButtonProps> = ({ onClick, label }) => {
5+
return <Button onClick={onClick}>{label}</Button>
6+
}

components/ui/LinkButton/props.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
interface LinkButtonProps {
2+
onClick?: () => void
3+
label?: string
4+
}
5+
6+
export default LinkButtonProps
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import styled from "styled-components"
2+
import tw from "twin.macro"
3+
4+
import LinkButtonProps from "./props"
5+
6+
export const Button = styled.a.attrs(
7+
(props: LinkButtonProps) => ({})
8+
)<LinkButtonProps>`
9+
${tw`text-ss font-bold cursor-pointer border-b border-gray-200 text-primary`}
10+
`

public/static/locales/en/common.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@
6464
"addNewBillingAddress": "Add new billing address",
6565
"addNewShippingAddress": "Add new shipping address",
6666
"continueToDelivery": "Continue to delivery",
67-
"notSet": "Fill in your Billing/Shipping Address"
67+
"notSet": "Fill in your Billing/Shipping Address",
68+
"closeForm": "Choose address"
6869
},
6970

7071
"stepShipping": {

public/static/locales/it/common.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@
6464
"addNewBillingAddress": "Aggiungi nuovo indirizzo di fatturazione",
6565
"addNewShippingAddress": "Aggiungi un nuovo indirizzo di spedizione",
6666
"continueToDelivery": "Continuare alla consegna",
67-
"notSet": "Inserisci il tuo indirizzo di fatturazione/spedizione"
67+
"notSet": "Inserisci il tuo indirizzo di fatturazione/spedizione",
68+
"closeForm": "Scegli indirizzo"
6869
},
6970

7071
"stepShipping": {

0 commit comments

Comments
 (0)