Skip to content

Commit

Permalink
feat: #49 (docs) add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Baroshem committed Aug 20, 2021
1 parent 529a451 commit 61bfd68
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ module.exports = {
['/composables/use-category', 'useCategory'],
['/composables/use-facet', 'useFacet'],
['/composables/use-cart', 'useCart'],
['/composables/use-billing', 'useBilling'],
['/composables/use-shipping', 'useShipping'],
]
},
]
Expand Down
74 changes: 74 additions & 0 deletions docs/composables/use-billing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# `useBilling`

## Features

`useBilling` composable can be used for:

* Loading billing address for the current cart.
* Saving billing address for the current cart.

## API

* `load` - function for fetching billing address. When invoked, it requests data from the API and populates `billing` property. This method accepts a single optional `params` object. The `params` has the following option:

* `customQuery?: CustomQuery`

```ts
type CustomQuery = {
getBasicProfile: string
}
```
* `save` - function for saving billing address. This method accepts a single `saveParams` object. The `saveParams` has the following options:
* `billingDetails: CreateAddressInput`
<https://www.vendure.io/docs/graphql-api/admin/input-types/#createaddressinput>
* `customQuery?: CustomQuery`
```ts
type CustomQuery = {
updateCart: string
}
```
* `billing: OrderAddress` - a main data object that contains a billing address.
<https://www.vendure.io/docs/graphql-api/admin/object-types/#orderaddress>
* `loading: boolean` - a reactive object containing information about loading state of your `load` or `save` method.
* `error: UseBillingErrors` - a reactive object containing the error message, if `load` or `save` failed for any reason.
```ts
interface UseBillingErrors {
load?: Error;
save?: Error;
}
```

## Getters

We do not provide getters for checkout and its parts.

## Example

```js
import { useBilling } from '@vue-storefront/vendure';
import { onSSR } from '@vue-storefront/core'

export default {
setup () {
const { load, billing } = useBilling();

onSSR(async () => {
await load();
});

return {
billing
};
}
}
```
74 changes: 74 additions & 0 deletions docs/composables/use-shipping.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# `useShipping`

## Features

`useShipping` composable can be used for:

* Loading shipping address for the current cart.
* Saving shipping address for the current cart.

## API

* `load` - function for fetching shipping address. When invoked, it requests data from the API and populates `shipping` property. This method accepts a single optional `params` object. The `params` has the following option:

* `customQuery?: CustomQuery`

```ts
type CustomQuery = {
getBasicProfile: string
}
```
* `save` - function for saving shipping address. This method accepts a single `saveParams` object. The `saveParams` has the following options:
* `shippingDetails: CreateAddressInput`
<https://www.vendure.io/docs/graphql-api/admin/input-types/#createaddressinput>
* `customQuery?: CustomQuery`
```ts
type CustomQuery = {
updateCart: string
}
```
* `shipping: OrderAddress` - a main data object that contains a shipping address.
<https://www.vendure.io/docs/graphql-api/admin/object-types/#orderaddress>
* `loading: boolean` - a reactive object containing information about loading state of your `load` or `save` method.
* `error: UseShippingErrors` - a reactive object containing the error message, if `load` or `save` failed for any reason.
```ts
interface UseShippingErrors {
load?: Error;
save?: Error;
}
```

## Getters

We do not provide getters for checkout and its parts.

## Example

```js
import { useShipping } from '@vue-storefront/vendure';
import { onSSR } from '@vue-storefront/core';

export default {
setup () {
const { load, shipping } = useShipping();

onSSR(async () => {
await load();
});

return {
shipping
};
}
}
```

0 comments on commit 61bfd68

Please sign in to comment.