@graphcommerce/magento-cart 3.0.8 → 3.0.9

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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [3.0.9](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart@3.0.8...@graphcommerce/magento-cart@3.0.9) (2021-09-30)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * dependency cycle issues causes release version issues ([f9d82e3](https://github.com/ho-nl/m2-pwa/commit/f9d82e3bf152acaf90f9d5328bc3d020ca1c53d8))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [3.0.5](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart@3.0.4...@graphcommerce/magento-cart@3.0.5) (2021-09-28)
7
18
 
8
19
 
@@ -0,0 +1,19 @@
1
+ fragment CartAddress on CartAddressInterface {
2
+ __typename
3
+ firstname
4
+ lastname
5
+ city
6
+ company
7
+ country {
8
+ code
9
+ label
10
+ }
11
+ postcode
12
+ region {
13
+ code
14
+ label
15
+ region_id
16
+ }
17
+ street
18
+ telephone
19
+ }
@@ -0,0 +1,17 @@
1
+ import { CountryCodeEnum } from '@graphcommerce/graphql'
2
+ import { AddressMultiLine } from '@graphcommerce/magento-customer'
3
+ import React from 'react'
4
+ import { CartAddressFragment } from '../CartAddress/CartAddress.gql'
5
+
6
+ export type CartAddressMultiLineProps = Partial<CartAddressFragment>
7
+
8
+ export default function CartAddressMultiLine(props: CartAddressMultiLineProps) {
9
+ const { country, region, ...addressProps } = props
10
+ return (
11
+ <AddressMultiLine
12
+ {...addressProps}
13
+ country_code={country?.code as CountryCodeEnum}
14
+ region={{ region_code: region?.code, region_id: region?.region_id, region: region?.label }}
15
+ />
16
+ )
17
+ }
@@ -0,0 +1,11 @@
1
+ import { CountryCodeEnum } from '@graphcommerce/graphql'
2
+ import { AddressSingleLine } from '@graphcommerce/magento-customer'
3
+ import React from 'react'
4
+ import { CartAddressFragment } from '../CartAddress/CartAddress.gql'
5
+
6
+ export type CartAddressSingleLineProps = CartAddressFragment & { locale?: CountryCodeEnum }
7
+
8
+ export default function CartAddressSingleLine(props: CartAddressSingleLineProps) {
9
+ const { locale } = props
10
+ return <AddressSingleLine {...props} country_code={locale} />
11
+ }
@@ -1,9 +1,9 @@
1
- import { CartAddressMultiLine } from '@graphcommerce/magento-cart-address'
2
1
  import { SectionContainer, UseStyles } from '@graphcommerce/next-ui'
3
2
  import { Link, makeStyles, Theme, Typography } from '@material-ui/core'
4
3
  import PageLink from 'next/link'
5
4
  import React from 'react'
6
5
  import { useCartQuery } from '../../hooks'
6
+ import CartAddressMultiLine from '../CartAddressMultiLine'
7
7
  import { GetCartSummaryDocument } from './GetCartSummary.gql'
8
8
 
9
9
  const useStyles = makeStyles(
@@ -0,0 +1,10 @@
1
+ query InlineAccount($cartId: String!) {
2
+ cart(cart_id: $cartId) {
3
+ __typename
4
+ id
5
+ shipping_addresses {
6
+ ...CartAddress
7
+ }
8
+ email
9
+ }
10
+ }
@@ -0,0 +1,152 @@
1
+ import { useQuery } from '@apollo/client'
2
+ import { SignUpFormInline } from '@graphcommerce/magento-customer'
3
+ import {
4
+ CustomerTokenDocument,
5
+ IsEmailAvailableDocument,
6
+ } from '@graphcommerce/magento-customer/hooks'
7
+ import Button from '@graphcommerce/next-ui/Button'
8
+ import FormRow from '@graphcommerce/next-ui/Form/FormRow'
9
+ import { UseStyles } from '@graphcommerce/next-ui/Styles'
10
+ import { makeStyles, TextField, Theme, Typography } from '@material-ui/core'
11
+ import React, { useState } from 'react'
12
+ import { useCartQuery } from '../../hooks/useCartQuery'
13
+ import { InlineAccountDocument } from './InlineAccount.gql'
14
+
15
+ const useStyles = makeStyles(
16
+ (theme: Theme) => ({
17
+ root: {
18
+ borderRadius: 4,
19
+ border: `1px solid ${theme.palette.divider}`,
20
+ padding: theme.spacings.md,
21
+ },
22
+ innerContainer: {
23
+ display: 'flex',
24
+ justifyContent: 'space-between',
25
+ flexDirection: 'column',
26
+ alignItems: 'flex-start',
27
+ gap: 32,
28
+ [theme.breakpoints.up('sm')]: {
29
+ alignItems: 'flex-end',
30
+ flexDirection: 'unset',
31
+ gap: 0,
32
+ },
33
+ },
34
+ form: {
35
+ marginTop: theme.spacings.sm,
36
+ },
37
+ button: {
38
+ minWidth: 160,
39
+ },
40
+ title: {
41
+ paddingBottom: 8,
42
+ },
43
+ }),
44
+ { name: 'InlineAccount' },
45
+ )
46
+
47
+ export type InlineAccountProps = {
48
+ title?: React.ReactNode
49
+ description?: React.ReactNode
50
+ accountHref: string
51
+ } & UseStyles<typeof useStyles>
52
+
53
+ export default function InlineAccount(props: InlineAccountProps) {
54
+ const { title, description, accountHref } = props
55
+ const classes = useStyles(props)
56
+
57
+ const [toggled, setToggled] = useState<boolean>(false)
58
+
59
+ const { loading, data } = useCartQuery(InlineAccountDocument)
60
+ const cart = data?.cart
61
+
62
+ const { data: customerTokenData } = useQuery(CustomerTokenDocument)
63
+ const { data: isEmailAvailableData } = useQuery(IsEmailAvailableDocument, {
64
+ variables: {
65
+ email: cart?.email ?? '',
66
+ },
67
+ })
68
+
69
+ const { firstname, lastname } = cart?.shipping_addresses?.[0] ?? {}
70
+ const signedIn = Boolean(
71
+ customerTokenData?.customerToken && customerTokenData?.customerToken.valid,
72
+ )
73
+ const canSignUp = isEmailAvailableData?.isEmailAvailable?.is_email_available === true
74
+
75
+ if (!canSignUp) return <></>
76
+
77
+ return (
78
+ <div>
79
+ <div key='signupaccount' className={classes.root}>
80
+ {!signedIn && canSignUp && (
81
+ <>
82
+ <div className={classes.innerContainer}>
83
+ <div>
84
+ <Typography variant='h4' className={classes.title}>
85
+ {title ?? 'No account yet?'}
86
+ </Typography>
87
+ {description ?? 'You can track your order status and much more!'}
88
+ </div>
89
+ <div>
90
+ {!toggled && (
91
+ <Button
92
+ variant='pill'
93
+ color='secondary'
94
+ text='bold'
95
+ loading={loading}
96
+ onClick={() => setToggled(!toggled)}
97
+ className={classes.button}
98
+ >
99
+ Create an account
100
+ </Button>
101
+ )}
102
+ </div>
103
+ </div>
104
+ {cart?.email && toggled && (
105
+ <div className={classes.form}>
106
+ <FormRow>
107
+ <TextField
108
+ variant='outlined'
109
+ type='email'
110
+ label='Email'
111
+ value={cart?.email}
112
+ InputProps={{
113
+ readOnly: true,
114
+ }}
115
+ />
116
+ </FormRow>
117
+ <SignUpFormInline
118
+ firstname={firstname ?? ''}
119
+ lastname={lastname}
120
+ email={cart?.email}
121
+ onSubmitted={() => setToggled(false)}
122
+ />
123
+ </div>
124
+ )}
125
+ </>
126
+ )}
127
+
128
+ {signedIn && (
129
+ <div className={classes.innerContainer}>
130
+ <div>
131
+ <Typography variant='h4' className={classes.title}>
132
+ {title ?? 'Have an account?'}
133
+ </Typography>
134
+ {description ?? 'You can find your order history in your account!'}
135
+ </div>
136
+ <div>
137
+ <Button
138
+ variant='pill'
139
+ color='secondary'
140
+ text='bold'
141
+ href={accountHref}
142
+ className={classes.button}
143
+ >
144
+ My account
145
+ </Button>
146
+ </div>
147
+ </div>
148
+ )}
149
+ </div>
150
+ </div>
151
+ )
152
+ }
@@ -9,8 +9,8 @@ export { default as CartTotals } from './CartTotals/CartTotals'
9
9
 
10
10
  export { default as EmptyCart } from './EmptyCart/EmptyCart'
11
11
 
12
- export { default as ApolloCartErrorAlert } from './ApolloCartError/ApolloCartErrorAlert'
13
12
  export * from './ApolloCartError/ApolloCartErrorAlert'
13
+ export { default as ApolloCartErrorAlert } from './ApolloCartError/ApolloCartErrorAlert'
14
14
 
15
15
  // export { default as ApolloCartErrorFullPage } from './ApolloCartError/ApolloCartErrorFullPage'
16
16
  // export * from './ApolloCartError/ApolloCartErrorFullPage'
@@ -19,3 +19,12 @@ export * from './CartSummary'
19
19
  export { default as CartSummary } from './CartSummary'
20
20
 
21
21
  export { default as CartItemSummary } from './CartItemSummary'
22
+
23
+ export * from './InlineAccount'
24
+ export { default as InlineAccount } from './InlineAccount'
25
+
26
+ export * from './CartAddressMultiLine'
27
+ export { default as CartAddressMultiLine } from './CartAddressMultiLine'
28
+
29
+ export * from './CartAddressSingleLine'
30
+ export { default as CartAddressSingleLine } from './CartAddressSingleLine'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphcommerce/magento-cart",
3
- "version": "3.0.8",
3
+ "version": "3.0.9",
4
4
  "sideEffects": false,
5
5
  "prettier": "@graphcommerce/prettier-config-pwa",
6
6
  "browserslist": [
@@ -24,8 +24,7 @@
24
24
  "@graphcommerce/framer-scroller": "^0.2.5",
25
25
  "@graphcommerce/graphql": "^2.103.4",
26
26
  "@graphcommerce/image": "^2.104.5",
27
- "@graphcommerce/magento-cart-address": "^2.103.8",
28
- "@graphcommerce/magento-customer": "^3.0.8",
27
+ "@graphcommerce/magento-customer": "^3.0.9",
29
28
  "@graphcommerce/magento-graphql": "^2.103.4",
30
29
  "@graphcommerce/magento-store": "^3.0.7",
31
30
  "@graphcommerce/next-ui": "^3.0.6",
@@ -39,5 +38,5 @@
39
38
  "react": "^17.0.2",
40
39
  "react-dom": "^17.0.2"
41
40
  },
42
- "gitHead": "5045f247ba0d84c53b16a1cc924677cfcd53b4b7"
41
+ "gitHead": "1cd56a50b55493aff392a0f08830754e9fdc7295"
43
42
  }