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

Checkout Button Schema #315

Closed
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Added
- Schema to the `checkout button`, this makes it possible to define via admin where the user will be directed after the click

## [2.63.5] - 2022-07-28

### Fixed
Expand Down
11 changes: 9 additions & 2 deletions react/CheckoutButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC } from 'react'
import React from 'react'
import { FormattedMessage } from 'react-intl'
import { Button } from 'vtex.styleguide'
import { CssHandlesTypes, useCssHandles } from 'vtex.css-handles'
Expand All @@ -13,7 +13,10 @@ interface Props {
classes?: CssHandlesTypes.CustomClasses<typeof CSS_HANDLES>
}

const CheckoutButton: FC<Props> = ({ finishShoppingButtonLink, classes }) => {
const CheckoutButton: StoreFunctionComponent<Props> = ({
finishShoppingButtonLink,
classes,
}): JSX.Element => {
const { url: checkoutUrl } = useCheckoutURL()
const { handles } = useCssHandles(CSS_HANDLES, { classes })
const goToCheckout = useCheckout()
Expand All @@ -32,4 +35,8 @@ const CheckoutButton: FC<Props> = ({ finishShoppingButtonLink, classes }) => {
)
}

CheckoutButton.schema = {
title: 'store/finish-shopping-button-label',
}

export default CheckoutButton
28 changes: 28 additions & 0 deletions react/typings/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { FC } from 'react'

declare global {
interface StoreFunctionComponent<P = {}> extends FC<P> {
schema?: object
}

type QuantityDisplayType = 'always' | 'never' | 'not-empty'

type MinicartTotalItemsType =
| 'total'
| 'distinct'
| 'totalAvailable'
| 'distinctAvailable'

type SlideDirectionType =
| 'horizontal'
| 'vertical'
| 'rightToLeft'
| 'leftToRight'

type MinicartVariationType =
| 'popup'
| 'drawer'
| 'link'
| 'popupWithLink'
| 'block'
}
20 changes: 0 additions & 20 deletions react/typings/global.ts

This file was deleted.

12 changes: 11 additions & 1 deletion store/interfaces.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,17 @@
"allowed": ["product-list"]
},
"minicart-checkout-button": {
"component": "CheckoutButton"
"component": "CheckoutButton",
"content": {
"title": "store/finish-shopping-button-label",
"properties": {
"finishShoppingButtonLink": {
"type": "string",
"title": "admin/editor.minicart.linkButtonFinishShopping.title",
"default": "/checkout/#/cart"
}
}
}
},
"minicart-summary": {
"component": "Summary",
Expand Down