@graphcommerce/magento-cart-coupon 2.105.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Api/Coupon.gql.ts +4 -0
- package/Api/Coupon.graphql +7 -0
- package/ApplyCouponForm/ApplyCouponForm.gql.ts +13 -0
- package/ApplyCouponForm/ApplyCouponForm.graphql +7 -0
- package/ApplyCouponForm/ApplyCouponForm.tsx +54 -0
- package/CHANGELOG.md +123 -0
- package/CouponAccordion/CouponAccordion.tsx +119 -0
- package/CouponAccordion/GetCoupon.gql.ts +12 -0
- package/CouponAccordion/GetCoupon.graphql +5 -0
- package/RemoveCouponForm/RemoveCouponForm.gql.ts +12 -0
- package/RemoveCouponForm/RemoveCouponForm.graphql +8 -0
- package/RemoveCouponForm/RemoveCouponForm.tsx +54 -0
- package/index.ts +10 -0
- package/package.json +39 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import * as Types from '@graphcommerce/graphql';
|
|
3
|
+
|
|
4
|
+
export type CouponFragment = { __typename: 'Cart', id: string, applied_coupons?: Types.Maybe<Array<Types.Maybe<{ code: string }>>>, shipping_addresses: Array<Types.Maybe<{ selected_shipping_method?: Types.Maybe<{ carrier_code: string, method_code: string, method_title: string, carrier_title: string, amount: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } }>, available_shipping_methods?: Types.Maybe<Array<Types.Maybe<{ carrier_code: string, method_code?: Types.Maybe<string>, price_incl_tax: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }, price_excl_tax: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } }>>> }>>, prices?: Types.Maybe<{ __typename: 'CartPrices', applied_taxes?: Types.Maybe<Array<Types.Maybe<{ label: string, amount: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } }>>>, discounts?: Types.Maybe<Array<Types.Maybe<{ label: string, amount: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } }>>>, grand_total?: Types.Maybe<{ currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }>, subtotal_excluding_tax?: Types.Maybe<{ currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }>, subtotal_including_tax?: Types.Maybe<{ currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }>, subtotal_with_discount_excluding_tax?: Types.Maybe<{ currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }> }> };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import * as Types from '@graphcommerce/graphql';
|
|
3
|
+
|
|
4
|
+
import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
|
|
5
|
+
|
|
6
|
+
export const ApplyCouponFormDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"ApplyCouponForm"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"cartId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"couponCode"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"applyCouponToCart"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"cart_id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"cartId"}}},{"kind":"ObjectField","name":{"kind":"Name","value":"coupon_code"},"value":{"kind":"Variable","name":{"kind":"Name","value":"couponCode"}}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cart"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"Field","name":{"kind":"Name","value":"applied_coupons"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}}]}},{"kind":"Field","name":{"kind":"Name","value":"shipping_addresses"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"selected_shipping_method"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"carrier_code"}},{"kind":"Field","name":{"kind":"Name","value":"method_code"}},{"kind":"Field","name":{"kind":"Name","value":"method_title"}},{"kind":"Field","name":{"kind":"Name","value":"carrier_title"}},{"kind":"Field","name":{"kind":"Name","value":"amount"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"available_shipping_methods"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"carrier_code"}},{"kind":"Field","name":{"kind":"Name","value":"method_code"}},{"kind":"Field","name":{"kind":"Name","value":"price_incl_tax"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}},{"kind":"Field","name":{"kind":"Name","value":"price_excl_tax"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"prices"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"Field","name":{"kind":"Name","value":"applied_taxes"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"amount"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}},{"kind":"Field","name":{"kind":"Name","value":"label"}}]}},{"kind":"Field","name":{"kind":"Name","value":"discounts"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"amount"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}},{"kind":"Field","name":{"kind":"Name","value":"label"}}]}},{"kind":"Field","name":{"kind":"Name","value":"grand_total"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}},{"kind":"Field","name":{"kind":"Name","value":"subtotal_excluding_tax"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}},{"kind":"Field","name":{"kind":"Name","value":"subtotal_including_tax"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}},{"kind":"Field","name":{"kind":"Name","value":"subtotal_with_discount_excluding_tax"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode<ApplyCouponFormMutation, ApplyCouponFormMutationVariables>;
|
|
7
|
+
export type ApplyCouponFormMutationVariables = Types.Exact<{
|
|
8
|
+
cartId: Types.Scalars['String'];
|
|
9
|
+
couponCode: Types.Scalars['String'];
|
|
10
|
+
}>;
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
export type ApplyCouponFormMutation = { applyCouponToCart?: Types.Maybe<{ cart: { __typename: 'Cart', id: string, applied_coupons?: Types.Maybe<Array<Types.Maybe<{ code: string }>>>, shipping_addresses: Array<Types.Maybe<{ selected_shipping_method?: Types.Maybe<{ carrier_code: string, method_code: string, method_title: string, carrier_title: string, amount: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } }>, available_shipping_methods?: Types.Maybe<Array<Types.Maybe<{ carrier_code: string, method_code?: Types.Maybe<string>, price_incl_tax: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }, price_excl_tax: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } }>>> }>>, prices?: Types.Maybe<{ __typename: 'CartPrices', applied_taxes?: Types.Maybe<Array<Types.Maybe<{ label: string, amount: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } }>>>, discounts?: Types.Maybe<Array<Types.Maybe<{ label: string, amount: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } }>>>, grand_total?: Types.Maybe<{ currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }>, subtotal_excluding_tax?: Types.Maybe<{ currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }>, subtotal_including_tax?: Types.Maybe<{ currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }>, subtotal_with_discount_excluding_tax?: Types.Maybe<{ currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }> }> } }> };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { FormControl, makeStyles, TextField, Theme } from '@material-ui/core'
|
|
2
|
+
import { useFormGqlMutationCart, ApolloCartErrorAlert } from '@graphcommerce/magento-cart'
|
|
3
|
+
import { Button, responsiveVal, UseStyles } from '@graphcommerce/next-ui'
|
|
4
|
+
import React from 'react'
|
|
5
|
+
import { ApplyCouponFormDocument } from './ApplyCouponForm.gql'
|
|
6
|
+
|
|
7
|
+
const useStyles = makeStyles((theme: Theme) => ({
|
|
8
|
+
couponForm: {
|
|
9
|
+
display: 'grid',
|
|
10
|
+
alignItems: 'center',
|
|
11
|
+
gridTemplateColumns: `1fr minmax(min-content, ${responsiveVal(70, 140)})`,
|
|
12
|
+
gridColumnGap: theme.spacings.sm,
|
|
13
|
+
},
|
|
14
|
+
button: {
|
|
15
|
+
whiteSpace: 'nowrap',
|
|
16
|
+
},
|
|
17
|
+
}))
|
|
18
|
+
|
|
19
|
+
export type ApplyCouponFormProps = UseStyles<typeof useStyles>
|
|
20
|
+
|
|
21
|
+
export default function ApplyCouponForm(props: ApplyCouponFormProps) {
|
|
22
|
+
const form = useFormGqlMutationCart(ApplyCouponFormDocument)
|
|
23
|
+
const { handleSubmit, muiRegister, formState, required, error } = form
|
|
24
|
+
const submitHandler = handleSubmit(() => {})
|
|
25
|
+
const classes = useStyles(props)
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<form onSubmit={submitHandler} noValidate className={classes.couponForm}>
|
|
29
|
+
<TextField
|
|
30
|
+
variant='outlined'
|
|
31
|
+
type='text'
|
|
32
|
+
error={!!formState.errors.couponCode || !!error}
|
|
33
|
+
required={required.couponCode}
|
|
34
|
+
{...muiRegister('couponCode', { required: required.couponCode })}
|
|
35
|
+
helperText={formState.errors.couponCode?.message}
|
|
36
|
+
disabled={formState.isSubmitting}
|
|
37
|
+
/>
|
|
38
|
+
<FormControl>
|
|
39
|
+
<Button
|
|
40
|
+
type='submit'
|
|
41
|
+
className={classes.button}
|
|
42
|
+
loading={formState.isSubmitting}
|
|
43
|
+
color='secondary'
|
|
44
|
+
variant='pill'
|
|
45
|
+
size='small'
|
|
46
|
+
>
|
|
47
|
+
Apply
|
|
48
|
+
</Button>
|
|
49
|
+
</FormControl>
|
|
50
|
+
|
|
51
|
+
<ApolloCartErrorAlert error={error} />
|
|
52
|
+
</form>
|
|
53
|
+
)
|
|
54
|
+
}
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## [2.105.1](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart-coupon@2.105.0...@graphcommerce/magento-cart-coupon@2.105.1) (2021-09-27)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @graphcommerce/magento-cart-coupon
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# 2.105.0 (2021-09-27)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* coupon animations, spacing, rippl;ie ([cef3a08](https://github.com/ho-nl/m2-pwa/commit/cef3a08d0545947518873c5257c59fc1b98f1a21))
|
|
20
|
+
* coupon stylign ([796bbb2](https://github.com/ho-nl/m2-pwa/commit/796bbb2ad5eda6dc9c5aa37034586705b24a0023))
|
|
21
|
+
* ignore md files from triggering version updates ([4f98392](https://github.com/ho-nl/m2-pwa/commit/4f9839250b3a32d3070da5290e5efcc5e2243fba))
|
|
22
|
+
* implement next-ui barrel imports ([75bea70](https://github.com/ho-nl/m2-pwa/commit/75bea703dba898f18a2a1dfa3243ebd0a4e6f0e1))
|
|
23
|
+
* remove coupon form style was too large ([30df274](https://github.com/ho-nl/m2-pwa/commit/30df274ecdffdcebd76710a5304d6fa248e81211))
|
|
24
|
+
* rename NextButton to Button, change imports ([976adb0](https://github.com/ho-nl/m2-pwa/commit/976adb0bf906310d1efce888dcc9be1e28ce0f1b))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Features
|
|
28
|
+
|
|
29
|
+
* **cart:** when a cart is not active anymore show a clear cart button ([5d04a14](https://github.com/ho-nl/m2-pwa/commit/5d04a14726c040b20b34c0b88f923aee1dff22e5))
|
|
30
|
+
* coupon form on payment page ([a163961](https://github.com/ho-nl/m2-pwa/commit/a1639617be756b357177fcce255cf662c5314499))
|
|
31
|
+
* **graphql:** introduced new graphql package that holds all generated files ([a3e7aa0](https://github.com/ho-nl/m2-pwa/commit/a3e7aa05540540533b5ced9a95f1f802ecbe499f))
|
|
32
|
+
* **image:** introduced completely rewritten Image component ([e3413b3](https://github.com/ho-nl/m2-pwa/commit/e3413b3a57392d6571ea64cb8d9c8dca05ea31df))
|
|
33
|
+
* **magento-customer:** introduced ApolloCustomerErrorAlert ([e5406d9](https://github.com/ho-nl/m2-pwa/commit/e5406d91f914de290c5f097955e312312e567972))
|
|
34
|
+
* next.js 11 ([7d61407](https://github.com/ho-nl/m2-pwa/commit/7d614075a778f488045034f74be4f75b93f63c43))
|
|
35
|
+
* **playwright:** added new playwright package to enable browser testing ([6f49ec7](https://github.com/ho-nl/m2-pwa/commit/6f49ec7595563775b96ebf21c27e39da1282e8d9))
|
|
36
|
+
* renamed all packages to use [@graphcommerce](https://github.com/graphcommerce) instead of [@reachdigital](https://github.com/reachdigital) ([491e4ce](https://github.com/ho-nl/m2-pwa/commit/491e4cec9a2686472dac36b79f999257c0811ffe))
|
|
37
|
+
* **theme:** restructured fonts and applied to home and category page ([6adf5f1](https://github.com/ho-nl/m2-pwa/commit/6adf5f11321bdfbf499125f1161c5abf5a1bfe4a))
|
|
38
|
+
* upgraded to nextjs 11 ([0053beb](https://github.com/ho-nl/m2-pwa/commit/0053beb7ef597c190add7264256a0eaec35868da))
|
|
39
|
+
* useFormMutationCart and simpler imports ([012f090](https://github.com/ho-nl/m2-pwa/commit/012f090e8f54d09f35d393c61ad1e2319f5a90ff))
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
### Reverts
|
|
43
|
+
|
|
44
|
+
* Revert "chore: upgrade @apollo/client" ([55ff24e](https://github.com/ho-nl/m2-pwa/commit/55ff24ede0e56c85b8095edadadd1ec5e0b1b8d2))
|
|
45
|
+
* Revert "style: coupon input conform design" ([3ac7182](https://github.com/ho-nl/m2-pwa/commit/3ac7182eb6bb7c86ccba6464d1f206dc30a5a1da))
|
|
46
|
+
* Revert "style: coupon accordion icon/button alignment" ([165f91c](https://github.com/ho-nl/m2-pwa/commit/165f91c8f0e587ea26bcf441f48a6a13df74891c))
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
# Change Log
|
|
53
|
+
|
|
54
|
+
All notable changes to this project will be documented in this file. See
|
|
55
|
+
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
56
|
+
|
|
57
|
+
# [2.104.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart-coupon@2.103.2...@graphcommerce/magento-cart-coupon@2.104.0) (2021-08-13)
|
|
58
|
+
|
|
59
|
+
### Features
|
|
60
|
+
|
|
61
|
+
- coupon form on payment page
|
|
62
|
+
([a163961](https://github.com/ho-nl/m2-pwa/commit/a1639617be756b357177fcce255cf662c5314499))
|
|
63
|
+
|
|
64
|
+
# [2.103.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart-coupon@2.102.3...@graphcommerce/magento-cart-coupon@2.103.0) (2021-08-12)
|
|
65
|
+
|
|
66
|
+
### Bug Fixes
|
|
67
|
+
|
|
68
|
+
- remove coupon form style was too large
|
|
69
|
+
([30df274](https://github.com/ho-nl/m2-pwa/commit/30df274ecdffdcebd76710a5304d6fa248e81211))
|
|
70
|
+
|
|
71
|
+
### Features
|
|
72
|
+
|
|
73
|
+
- upgraded to nextjs 11
|
|
74
|
+
([0053beb](https://github.com/ho-nl/m2-pwa/commit/0053beb7ef597c190add7264256a0eaec35868da))
|
|
75
|
+
|
|
76
|
+
## [2.102.2](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart-coupon@2.102.1...@graphcommerce/magento-cart-coupon@2.102.2) (2021-08-09)
|
|
77
|
+
|
|
78
|
+
### Reverts
|
|
79
|
+
|
|
80
|
+
- Revert "chore: upgrade @apollo/client"
|
|
81
|
+
([55ff24e](https://github.com/ho-nl/m2-pwa/commit/55ff24ede0e56c85b8095edadadd1ec5e0b1b8d2))
|
|
82
|
+
|
|
83
|
+
# [2.102.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart-coupon@2.101.6...@graphcommerce/magento-cart-coupon@2.102.0) (2021-08-06)
|
|
84
|
+
|
|
85
|
+
### Features
|
|
86
|
+
|
|
87
|
+
- **theme:** restructured fonts and applied to home and category page
|
|
88
|
+
([6adf5f1](https://github.com/ho-nl/m2-pwa/commit/6adf5f11321bdfbf499125f1161c5abf5a1bfe4a))
|
|
89
|
+
|
|
90
|
+
## [2.101.6](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart-coupon@2.101.5...@graphcommerce/magento-cart-coupon@2.101.6) (2021-08-04)
|
|
91
|
+
|
|
92
|
+
### Bug Fixes
|
|
93
|
+
|
|
94
|
+
- coupon stylign
|
|
95
|
+
([796bbb2](https://github.com/ho-nl/m2-pwa/commit/796bbb2ad5eda6dc9c5aa37034586705b24a0023))
|
|
96
|
+
|
|
97
|
+
## [2.101.5](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart-coupon@2.101.4...@graphcommerce/magento-cart-coupon@2.101.5) (2021-08-03)
|
|
98
|
+
|
|
99
|
+
### Bug Fixes
|
|
100
|
+
|
|
101
|
+
- coupon animations, spacing, rippl;ie
|
|
102
|
+
([cef3a08](https://github.com/ho-nl/m2-pwa/commit/cef3a08d0545947518873c5257c59fc1b98f1a21))
|
|
103
|
+
|
|
104
|
+
### Reverts
|
|
105
|
+
|
|
106
|
+
- Revert "style: coupon input conform design"
|
|
107
|
+
([3ac7182](https://github.com/ho-nl/m2-pwa/commit/3ac7182eb6bb7c86ccba6464d1f206dc30a5a1da))
|
|
108
|
+
- Revert "style: coupon accordion icon/button alignment"
|
|
109
|
+
([165f91c](https://github.com/ho-nl/m2-pwa/commit/165f91c8f0e587ea26bcf441f48a6a13df74891c))
|
|
110
|
+
|
|
111
|
+
# [2.101.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart-coupon@2.100.19...@graphcommerce/magento-cart-coupon@2.101.0) (2021-07-26)
|
|
112
|
+
|
|
113
|
+
### Features
|
|
114
|
+
|
|
115
|
+
- **playwright:** added new playwright package to enable browser testing
|
|
116
|
+
([6f49ec7](https://github.com/ho-nl/m2-pwa/commit/6f49ec7595563775b96ebf21c27e39da1282e8d9))
|
|
117
|
+
|
|
118
|
+
## [2.100.11](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart-coupon@2.100.10...@graphcommerce/magento-cart-coupon@2.100.11) (2021-07-20)
|
|
119
|
+
|
|
120
|
+
### Bug Fixes
|
|
121
|
+
|
|
122
|
+
- ignore md files from triggering version updates
|
|
123
|
+
([4f98392](https://github.com/ho-nl/m2-pwa/commit/4f9839250b3a32d3070da5290e5efcc5e2243fba))
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { Button, makeStyles, Theme, Typography } from '@material-ui/core'
|
|
2
|
+
import { useCartQuery } from '@graphcommerce/magento-cart'
|
|
3
|
+
import {
|
|
4
|
+
AnimatedRow,
|
|
5
|
+
iconChevronDown,
|
|
6
|
+
iconChevronUp,
|
|
7
|
+
SvgImage,
|
|
8
|
+
UseStyles,
|
|
9
|
+
} from '@graphcommerce/next-ui'
|
|
10
|
+
import clsx from 'clsx'
|
|
11
|
+
import { AnimatePresence, m } from 'framer-motion'
|
|
12
|
+
import React, { useState } from 'react'
|
|
13
|
+
import ApplyCouponForm from '../ApplyCouponForm/ApplyCouponForm'
|
|
14
|
+
import RemoveCouponForm from '../RemoveCouponForm/RemoveCouponForm'
|
|
15
|
+
import { GetCouponDocument } from './GetCoupon.gql'
|
|
16
|
+
|
|
17
|
+
const useStyles = makeStyles((theme: Theme) => ({
|
|
18
|
+
accordion: {
|
|
19
|
+
'&:before': {
|
|
20
|
+
background: 'none',
|
|
21
|
+
},
|
|
22
|
+
boxShadow: 'none',
|
|
23
|
+
border: '1px solid #ededed',
|
|
24
|
+
borderRadius: 8,
|
|
25
|
+
overflow: 'hidden',
|
|
26
|
+
},
|
|
27
|
+
button: {
|
|
28
|
+
padding: `${theme.spacings.xs} ${theme.spacings.sm}`,
|
|
29
|
+
width: '100%',
|
|
30
|
+
|
|
31
|
+
'& .MuiButton-label': {
|
|
32
|
+
display: 'flex',
|
|
33
|
+
justifyContent: 'flex-start',
|
|
34
|
+
'& span:last-child': {
|
|
35
|
+
marginLeft: 'auto',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
'& > span': {
|
|
39
|
+
display: 'inline',
|
|
40
|
+
'& > h6': {
|
|
41
|
+
textAlign: 'left',
|
|
42
|
+
marginRight: theme.spacings.sm,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
couponFormWrap: {
|
|
47
|
+
background: 'rgba(0,0,0,0.04)',
|
|
48
|
+
padding: `0 ${theme.spacings.sm} ${theme.spacings.xs}`,
|
|
49
|
+
},
|
|
50
|
+
buttonOpen: {
|
|
51
|
+
background: 'rgba(0,0,0,0.04)',
|
|
52
|
+
borderBottomLeftRadius: 0,
|
|
53
|
+
borderBottomRightRadius: 0,
|
|
54
|
+
},
|
|
55
|
+
disabled: {
|
|
56
|
+
cursor: 'default',
|
|
57
|
+
'&:hover': {
|
|
58
|
+
background: 'transparent',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
}))
|
|
62
|
+
|
|
63
|
+
export type CouponAccordionProps = UseStyles<typeof useStyles>
|
|
64
|
+
|
|
65
|
+
export default function CouponAccordion(props: CouponAccordionProps) {
|
|
66
|
+
const classes = useStyles(props)
|
|
67
|
+
const { data } = useCartQuery(GetCouponDocument)
|
|
68
|
+
const [open, setOpen] = useState<boolean>(false)
|
|
69
|
+
|
|
70
|
+
if (!data?.cart?.id) return null
|
|
71
|
+
|
|
72
|
+
const coupon = data?.cart?.applied_coupons?.[0]?.code
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<AnimatedRow key='discount-codes'>
|
|
76
|
+
<m.div className={classes.accordion}>
|
|
77
|
+
<Button
|
|
78
|
+
component={coupon ? 'div' : 'button'}
|
|
79
|
+
onClick={() => setOpen(!open)}
|
|
80
|
+
disableRipple={!!coupon}
|
|
81
|
+
className={clsx(classes.button, {
|
|
82
|
+
[classes.buttonOpen]: !coupon && open,
|
|
83
|
+
[classes.disabled]: coupon,
|
|
84
|
+
})}
|
|
85
|
+
endIcon={
|
|
86
|
+
<>
|
|
87
|
+
{!coupon && open && <SvgImage src={iconChevronUp} alt='Open' loading='eager' />}
|
|
88
|
+
{!coupon && !open && <SvgImage src={iconChevronDown} alt='Close' loading='eager' />}
|
|
89
|
+
</>
|
|
90
|
+
}
|
|
91
|
+
>
|
|
92
|
+
<Typography variant='subtitle1'>Discount code</Typography>
|
|
93
|
+
<AnimatePresence>
|
|
94
|
+
{coupon && (
|
|
95
|
+
<m.div
|
|
96
|
+
key='remove'
|
|
97
|
+
initial={{ opacity: 0 }}
|
|
98
|
+
animate={{ opacity: 1 }}
|
|
99
|
+
exit={{ opacity: 0 }}
|
|
100
|
+
>
|
|
101
|
+
<RemoveCouponForm {...data.cart} />
|
|
102
|
+
</m.div>
|
|
103
|
+
)}
|
|
104
|
+
</AnimatePresence>
|
|
105
|
+
</Button>
|
|
106
|
+
|
|
107
|
+
<AnimatePresence>
|
|
108
|
+
{open && !coupon && (
|
|
109
|
+
<AnimatedRow key='discount-codes-form-wrap'>
|
|
110
|
+
<div className={classes.couponFormWrap}>
|
|
111
|
+
<ApplyCouponForm />
|
|
112
|
+
</div>
|
|
113
|
+
</AnimatedRow>
|
|
114
|
+
)}
|
|
115
|
+
</AnimatePresence>
|
|
116
|
+
</m.div>
|
|
117
|
+
</AnimatedRow>
|
|
118
|
+
)
|
|
119
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import * as Types from '@graphcommerce/graphql';
|
|
3
|
+
|
|
4
|
+
import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
|
|
5
|
+
|
|
6
|
+
export const GetCouponDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetCoupon"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"cartId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cart"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"cart_id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"cartId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"Field","name":{"kind":"Name","value":"applied_coupons"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}}]}},{"kind":"Field","name":{"kind":"Name","value":"shipping_addresses"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"selected_shipping_method"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"carrier_code"}},{"kind":"Field","name":{"kind":"Name","value":"method_code"}},{"kind":"Field","name":{"kind":"Name","value":"method_title"}},{"kind":"Field","name":{"kind":"Name","value":"carrier_title"}},{"kind":"Field","name":{"kind":"Name","value":"amount"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"available_shipping_methods"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"carrier_code"}},{"kind":"Field","name":{"kind":"Name","value":"method_code"}},{"kind":"Field","name":{"kind":"Name","value":"price_incl_tax"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}},{"kind":"Field","name":{"kind":"Name","value":"price_excl_tax"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"prices"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"Field","name":{"kind":"Name","value":"applied_taxes"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"amount"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}},{"kind":"Field","name":{"kind":"Name","value":"label"}}]}},{"kind":"Field","name":{"kind":"Name","value":"discounts"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"amount"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}},{"kind":"Field","name":{"kind":"Name","value":"label"}}]}},{"kind":"Field","name":{"kind":"Name","value":"grand_total"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}},{"kind":"Field","name":{"kind":"Name","value":"subtotal_excluding_tax"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}},{"kind":"Field","name":{"kind":"Name","value":"subtotal_including_tax"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}},{"kind":"Field","name":{"kind":"Name","value":"subtotal_with_discount_excluding_tax"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}}]}}]}}]}}]} as unknown as DocumentNode<GetCouponQuery, GetCouponQueryVariables>;
|
|
7
|
+
export type GetCouponQueryVariables = Types.Exact<{
|
|
8
|
+
cartId: Types.Scalars['String'];
|
|
9
|
+
}>;
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export type GetCouponQuery = { cart?: Types.Maybe<{ __typename: 'Cart', id: string, applied_coupons?: Types.Maybe<Array<Types.Maybe<{ code: string }>>>, shipping_addresses: Array<Types.Maybe<{ selected_shipping_method?: Types.Maybe<{ carrier_code: string, method_code: string, method_title: string, carrier_title: string, amount: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } }>, available_shipping_methods?: Types.Maybe<Array<Types.Maybe<{ carrier_code: string, method_code?: Types.Maybe<string>, price_incl_tax: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }, price_excl_tax: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } }>>> }>>, prices?: Types.Maybe<{ __typename: 'CartPrices', applied_taxes?: Types.Maybe<Array<Types.Maybe<{ label: string, amount: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } }>>>, discounts?: Types.Maybe<Array<Types.Maybe<{ label: string, amount: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } }>>>, grand_total?: Types.Maybe<{ currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }>, subtotal_excluding_tax?: Types.Maybe<{ currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }>, subtotal_including_tax?: Types.Maybe<{ currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }>, subtotal_with_discount_excluding_tax?: Types.Maybe<{ currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }> }> }> };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import * as Types from '@graphcommerce/graphql';
|
|
3
|
+
|
|
4
|
+
import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
|
|
5
|
+
|
|
6
|
+
export const RemoveCouponFormDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"RemoveCouponForm"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"cartId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"removeCouponFromCart"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"cart_id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"cartId"}}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cart"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"Field","name":{"kind":"Name","value":"applied_coupons"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}}]}},{"kind":"Field","name":{"kind":"Name","value":"shipping_addresses"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"selected_shipping_method"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"carrier_code"}},{"kind":"Field","name":{"kind":"Name","value":"method_code"}},{"kind":"Field","name":{"kind":"Name","value":"method_title"}},{"kind":"Field","name":{"kind":"Name","value":"carrier_title"}},{"kind":"Field","name":{"kind":"Name","value":"amount"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"available_shipping_methods"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"carrier_code"}},{"kind":"Field","name":{"kind":"Name","value":"method_code"}},{"kind":"Field","name":{"kind":"Name","value":"price_incl_tax"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}},{"kind":"Field","name":{"kind":"Name","value":"price_excl_tax"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"prices"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"Field","name":{"kind":"Name","value":"applied_taxes"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"amount"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}},{"kind":"Field","name":{"kind":"Name","value":"label"}}]}},{"kind":"Field","name":{"kind":"Name","value":"discounts"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"amount"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}},{"kind":"Field","name":{"kind":"Name","value":"label"}}]}},{"kind":"Field","name":{"kind":"Name","value":"grand_total"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}},{"kind":"Field","name":{"kind":"Name","value":"subtotal_excluding_tax"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}},{"kind":"Field","name":{"kind":"Name","value":"subtotal_including_tax"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}},{"kind":"Field","name":{"kind":"Name","value":"subtotal_with_discount_excluding_tax"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode<RemoveCouponFormMutation, RemoveCouponFormMutationVariables>;
|
|
7
|
+
export type RemoveCouponFormMutationVariables = Types.Exact<{
|
|
8
|
+
cartId: Types.Scalars['String'];
|
|
9
|
+
}>;
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export type RemoveCouponFormMutation = { removeCouponFromCart?: Types.Maybe<{ cart?: Types.Maybe<{ __typename: 'Cart', id: string, applied_coupons?: Types.Maybe<Array<Types.Maybe<{ code: string }>>>, shipping_addresses: Array<Types.Maybe<{ selected_shipping_method?: Types.Maybe<{ carrier_code: string, method_code: string, method_title: string, carrier_title: string, amount: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } }>, available_shipping_methods?: Types.Maybe<Array<Types.Maybe<{ carrier_code: string, method_code?: Types.Maybe<string>, price_incl_tax: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }, price_excl_tax: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } }>>> }>>, prices?: Types.Maybe<{ __typename: 'CartPrices', applied_taxes?: Types.Maybe<Array<Types.Maybe<{ label: string, amount: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } }>>>, discounts?: Types.Maybe<Array<Types.Maybe<{ label: string, amount: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } }>>>, grand_total?: Types.Maybe<{ currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }>, subtotal_excluding_tax?: Types.Maybe<{ currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }>, subtotal_including_tax?: Types.Maybe<{ currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }>, subtotal_with_discount_excluding_tax?: Types.Maybe<{ currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> }> }> }> }> };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { IconButton, makeStyles, Theme } from '@material-ui/core'
|
|
2
|
+
import { useFormGqlMutationCart, ApolloCartErrorAlert } from '@graphcommerce/magento-cart'
|
|
3
|
+
import { UseStyles, iconClose, SvgImageSimple } from '@graphcommerce/next-ui'
|
|
4
|
+
import React from 'react'
|
|
5
|
+
import { CouponFragment } from '../Api/Coupon.gql'
|
|
6
|
+
import { RemoveCouponFormDocument } from './RemoveCouponForm.gql'
|
|
7
|
+
|
|
8
|
+
const useStyles = makeStyles(
|
|
9
|
+
(theme: Theme) => ({
|
|
10
|
+
inlineCoupon: {
|
|
11
|
+
background: `${theme.palette.secondary.main}12`,
|
|
12
|
+
margin: `-1px 0 -2px`,
|
|
13
|
+
padding: `4px ${theme.spacings.xxs} 4px ${theme.spacings.xxs}`,
|
|
14
|
+
color: theme.palette.secondary.main,
|
|
15
|
+
borderRadius: 4,
|
|
16
|
+
...theme.typography.body2,
|
|
17
|
+
fontWeight: 600,
|
|
18
|
+
display: 'flex',
|
|
19
|
+
alignItems: 'center',
|
|
20
|
+
'& .MuiIconButton-root': {
|
|
21
|
+
width: 14,
|
|
22
|
+
height: 14,
|
|
23
|
+
marginLeft: 4,
|
|
24
|
+
color: theme.palette.grey[400],
|
|
25
|
+
'& .MuiSvgIcon-root': {
|
|
26
|
+
padding: 2,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
}),
|
|
31
|
+
{ name: 'RemoveCouponForm' },
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
export type CartCouponProps = CouponFragment & UseStyles<typeof useStyles>
|
|
35
|
+
|
|
36
|
+
export default function RemoveCouponForm(props: CartCouponProps) {
|
|
37
|
+
const { applied_coupons } = props
|
|
38
|
+
const classes = useStyles(props)
|
|
39
|
+
const form = useFormGqlMutationCart(RemoveCouponFormDocument)
|
|
40
|
+
|
|
41
|
+
const { handleSubmit, error } = form
|
|
42
|
+
const submitHandler = handleSubmit(() => {})
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<form className={classes.inlineCoupon} onSubmit={submitHandler} noValidate>
|
|
46
|
+
{applied_coupons?.[0]?.code}
|
|
47
|
+
<IconButton type='submit'>
|
|
48
|
+
<SvgImageSimple src={iconClose} size='small' muted />
|
|
49
|
+
</IconButton>
|
|
50
|
+
|
|
51
|
+
<ApolloCartErrorAlert error={error} />
|
|
52
|
+
</form>
|
|
53
|
+
)
|
|
54
|
+
}
|
package/index.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './Api/Coupon.gql'
|
|
2
|
+
|
|
3
|
+
export * from './ApplyCouponForm/ApplyCouponForm'
|
|
4
|
+
export { default as ApplyCouponForm } from './ApplyCouponForm/ApplyCouponForm'
|
|
5
|
+
|
|
6
|
+
export * from './CouponAccordion/CouponAccordion'
|
|
7
|
+
export { default as CouponAccordion } from './CouponAccordion/CouponAccordion'
|
|
8
|
+
|
|
9
|
+
export * from './RemoveCouponForm/RemoveCouponForm'
|
|
10
|
+
export { default as RemoveCouponForm } from './RemoveCouponForm/RemoveCouponForm'
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@graphcommerce/magento-cart-coupon",
|
|
3
|
+
"version": "2.105.1",
|
|
4
|
+
"sideEffects": false,
|
|
5
|
+
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
6
|
+
"browserslist": [
|
|
7
|
+
"extends @graphcommerce/browserslist-config-pwa"
|
|
8
|
+
],
|
|
9
|
+
"eslintConfig": {
|
|
10
|
+
"extends": "@graphcommerce/eslint-config-pwa",
|
|
11
|
+
"parserOptions": {
|
|
12
|
+
"project": "./tsconfig.json"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@graphcommerce/browserslist-config-pwa": "^3.0.1",
|
|
17
|
+
"@graphcommerce/eslint-config-pwa": "^3.0.1",
|
|
18
|
+
"@graphcommerce/prettier-config-pwa": "^3.0.1",
|
|
19
|
+
"@graphcommerce/typescript-config-pwa": "^3.0.1",
|
|
20
|
+
"@playwright/test": "^1.14.1"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@apollo/client": "^3.3.21",
|
|
24
|
+
"@graphcommerce/graphql": "^2.103.1",
|
|
25
|
+
"@graphcommerce/image": "^2.104.1",
|
|
26
|
+
"@graphcommerce/magento-cart": "^3.0.1",
|
|
27
|
+
"@graphcommerce/magento-store": "^3.0.1",
|
|
28
|
+
"@graphcommerce/next-ui": "^3.0.1",
|
|
29
|
+
"@graphcommerce/react-hook-form": "^2.102.1",
|
|
30
|
+
"@graphql-typed-document-node/core": "^3.1.0",
|
|
31
|
+
"@material-ui/core": "^4.12.3",
|
|
32
|
+
"@material-ui/lab": "^4.0.0-alpha.60",
|
|
33
|
+
"clsx": "^1.1.1",
|
|
34
|
+
"framer-motion": "^4.1.17",
|
|
35
|
+
"next": "^11.1.2",
|
|
36
|
+
"react": "^17.0.2",
|
|
37
|
+
"react-dom": "^17.0.2"
|
|
38
|
+
}
|
|
39
|
+
}
|