Skip to content
Draft
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
7 changes: 7 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Fixing the warning:
# npm WARN lifecycle The node binary used for scripts is {...}/node but npm is using /usr/local/bin/node itself.
# Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
scripts-prepend-node-path=true
# https://docs.npmjs.com/using-private-packages-in-a-ci-cd-workflow#set-the-token-as-an-environment-variable-on-the-cicd-server
//npm.deity.io/:_authToken=${NPM_TOKEN}
@deity:registry=https://npm.deity.io/
7 changes: 0 additions & 7 deletions docs/platform/packages/falcon-front-kit.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
id: checkout-provider
title: '<CheckoutProvider />'
sidebar_label: '<CheckoutProvider />'
---

A `<CheckoutProvider />` component keeps the state of checkout process and orchestrate its flow. In order to access `<CheckoutProvider />` state plase look at `<Checkout />` component or its hook alternative `userCheckout`.

# Import

```javascript
import { CheckoutProvider } from '@deity/falcon-front-kit';
```

# Props

| Name | Type | Default | Description |
| ----------------------- | ------------------------------------------------------ | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| `initialValues` | `undefined` &#124; [`CheckoutValues`](checkout-values) | `{}` | initial values |
| `stepsOrder` | `string[]` | `['email', 'shippingAddress', 'billingAddress', 'shippingMethod', 'paymentMethod', 'placeOrder']` | wizard steps and its order, it is possible to specify custom step, but removing any of them is not supported |
| `billingSameAsShipping` | `undefined` &#124; `boolean` | `false` | determines if `billingAddress` should be the same as `shippingAddress` and vice versa |
| `autoStepForward` | `boolean` | `true` | determines if a `stepForward` should be automatically invoked when the value for the current step is set |
| `children` | `ReactNode` | `undefined` | React component |

# Example

```javascript
<CheckoutProvider
stepsOrder={['shippingAddress', 'billingAddress', 'email', 'shippingMethod', 'paymentMethod', 'placeOrder']}
billingSameAsShipping
>
{/* your checkout wizard */}
</CheckoutProvider>
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
id: checkout-values
title: 'CheckoutValues'
sidebar_label: 'CheckoutValues'
---

A `CheckoutValues`
63 changes: 63 additions & 0 deletions docs/platform/packages/falcon-front-kit/checkout/checkout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
id: checkout
title: '<Checkout /> & useCheckout'
sidebar_label: '<Checkout />'
---

A `<Checkout />` (`useCheckout`) provides access to checkout state keept via `<CheckoutProvider />`

# Import

```javascript
import { Checkout } from '@deity/falcon-front-kit';
```

# Props

| Name | Type | Default | Description |
| ---------- | ------------------------------------------------- | ----------- | ------------ |
| `children` | `(renderProps: CheckoutContextType) => ReactNode` | `undefined` | render props |

## CheckoutContextType

| Name | Type | Description |
| -------------------------- | ----------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `values` | [`CheckoutValues`](checkout-values) | current checkout state |
| `step` | `string` | current step, one of `['email', 'shippingAddress', 'billingAddress', 'shippingMethod', 'paymentMethod', 'placeOrder']` or your custom defined value |
| `nextStep` | `undefined` &#124; `string` | next possible step for the current one, the calculation is based on `stepsOrder`, `undefined` if no more steps available |
| `stepForward` | `() => voud` | sets `step` to value of `nextStep` |
| `setStep` | `(string) => void` | sets `step`, if possible for current `values` |
| `isLoading` | `boolean` | determines if checkout state is synchonizing with backend |
| `setLoading` | `(boolean) => void` | sets `isLoading` |
| `isBillingSameAsShipping` | `boolean` | determines if `billingAddress` should be the same as `shippingAddress` and vice versa |
| `setBillingSameAsShipping` | `(boolean) => void` | sets `isBillingSameAsShipping` |
| `result` | `PlaceOrderResult` | result of checkout process (after placing order) |
| `setResult` | `(PlaceOrderResult) => void` | sets `result` |
| `setEmail` | `(string) => void` | sets `values.email` |
| `setShippingAddress` | `(CheckoutAddress) => void` | sets `values.setShippingAddress` |
| `setBillingAddress` | `(CheckoutAddress) => void` | sets `values.setBillingAddress` |
| `setShippingMethod` | `(ShippingMethod) => void` | sets `values.setShippingMethod` |
| `setPaymentMethod` | `(PaymentMethodData) => void` | sets `values.setPaymentMethod` |
| `setOrderData` | `(PaymentMethodData) => void` | sets `values` (override them), useful when order was placed via `<PlaceOrder />` or `usePlaceOrder` hook with some overrides and state needs to be synchronized |

# Example

```javascript
<Checkout>
{({ values, step, setEmail }) => {
const { email } = values;

return null;
}}
</Checkout>
```

beare in mind that `<Checkout />` (`useCheckout`) require `<checkoutProvider />` to be rendered beforre in components tree

```javascript
<CheckoutProvider>
{...}
<Checkout />
{...}
</CheckoutProvider>
```
7 changes: 7 additions & 0 deletions docs/platform/packages/falcon-front-kit/checkout/overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
id: overview
title: '@deity/falcon-front-kit/checkout'
sidebar_label: 'Overview'
---

**Coming Soon**
12 changes: 12 additions & 0 deletions docs/platform/packages/falcon-front-kit/overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
id: overview
title: '@deity/falcon-front-kit'
sidebar_label: 'Overview'
---

**Coming Soon**

* TODO: why this package exists
* TODO: what this package contains
* TODO: how to install

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@docusaurus/core": "^2.0.0-alpha.43",
"@docusaurus/preset-classic": "^2.0.0-alpha.43",
"classnames": "^2.2.6",
"docusaurus": "2.0.0-alpha.48",
"react": "^16.8.4",
"react-dom": "^16.8.4"
},
Expand Down
5 changes: 5 additions & 0 deletions prettier.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
tabWidth: 2,
singleQuote: true,
printWidth: 120
};
17 changes: 16 additions & 1 deletion sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,22 @@ module.exports = {
"platform/packages/falcon-client",
"platform/packages/falcon-data",
"platform/packages/falcon-errors",
"platform/packages/falcon-front-kit",
{
type: 'category',
label: '@deity/falcon-front-kit',
items: [
"platform/packages/falcon-front-kit/overview",
{
type: 'category',
label: 'Checkout',
items: [
"platform/packages/falcon-front-kit/checkout/overview",
"platform/packages/falcon-front-kit/checkout/checkout-provider",
"platform/packages/falcon-front-kit/checkout/checkout",
],
}
],
},
"platform/packages/falcon-i18n-webpack-plugin",
"platform/packages/falcon-i18n",
"platform/packages/falcon-logger",
Expand Down
Loading