-
Notifications
You must be signed in to change notification settings - Fork 685
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into tommy/checkout-signin
- Loading branch information
Showing
62 changed files
with
4,280 additions
and
1,172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
packages/peregrine/lib/talons/AddressBookPage/addressBookFragments.gql.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { gql } from '@apollo/client'; | ||
|
||
export const CustomerAddressBookAddressFragment = gql` | ||
fragment CustomerAddressBookAddressFragment on CustomerAddress { | ||
__typename | ||
id | ||
city | ||
country_code | ||
default_billing | ||
default_shipping | ||
firstname | ||
lastname | ||
middlename | ||
postcode | ||
region { | ||
region | ||
region_code | ||
region_id | ||
} | ||
street | ||
telephone | ||
} | ||
`; |
55 changes: 39 additions & 16 deletions
55
packages/peregrine/lib/talons/AddressBookPage/addressBookPage.gql.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,58 @@ | ||
import { gql } from '@apollo/client'; | ||
|
||
import { CustomerAddressBookAddressFragment } from './addressBookFragments.gql'; | ||
|
||
export const GET_CUSTOMER_ADDRESSES = gql` | ||
query GetCustomerAddressesForAddressBook { | ||
customer { | ||
id | ||
addresses { | ||
id | ||
city | ||
country_code | ||
default_billing | ||
default_shipping | ||
firstname | ||
lastname | ||
postcode | ||
region { | ||
region | ||
region_code | ||
region_id | ||
} | ||
street | ||
telephone | ||
...CustomerAddressBookAddressFragment | ||
} | ||
} | ||
countries { | ||
id | ||
full_name_locale | ||
} | ||
} | ||
${CustomerAddressBookAddressFragment} | ||
`; | ||
|
||
/** | ||
* We use the connection key directive here because Apollo will save | ||
* this customer's PII in localStorage if not. | ||
*/ | ||
export const ADD_NEW_CUSTOMER_ADDRESS = gql` | ||
mutation AddNewCustomerAddressToAddressBook( | ||
$address: CustomerAddressInput! | ||
) { | ||
createCustomerAddress(input: $address) | ||
@connection(key: "createCustomerAddress") { | ||
# We don't manually write to the cache to update the collection | ||
# after adding a new address so there's no need to query for a bunch | ||
# of address fields here. We use refetchQueries to refresh the list. | ||
id | ||
} | ||
} | ||
`; | ||
|
||
export const UPDATE_CUSTOMER_ADDRESS = gql` | ||
mutation UpdateCustomerAddressInAddressBook( | ||
$addressId: Int! | ||
$updated_address: CustomerAddressInput! | ||
) { | ||
updateCustomerAddress(id: $addressId, input: $updated_address) | ||
@connection(key: "updateCustomerAddress") { | ||
id | ||
...CustomerAddressBookAddressFragment | ||
} | ||
} | ||
${CustomerAddressBookAddressFragment} | ||
`; | ||
|
||
export default { | ||
getCustomerAddressesQuery: GET_CUSTOMER_ADDRESSES | ||
createCustomerAddressMutation: ADD_NEW_CUSTOMER_ADDRESS, | ||
getCustomerAddressesQuery: GET_CUSTOMER_ADDRESSES, | ||
updateCustomerAddressMutation: UPDATE_CUSTOMER_ADDRESS | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.