Skip to content

Commit

Permalink
feat(shopify): add & implement user functionality (#99)
Browse files Browse the repository at this point in the history
* feat: (shopify-adapter): BEU-1065 fetch order history with user and add update user function

* feat: (shopify-adapter): BEU-1065 add possibility to create user with first and lastname

* feat: (shopify-adapter): BEU-1065 add user activate function

* feat: (shopify-adapter): BEU-1065 add password update function

* feat: (shopify-adapter): BEU-1065 add update address function
  • Loading branch information
fkilz authored Aug 10, 2023
1 parent 89f22b8 commit bbfe232
Show file tree
Hide file tree
Showing 4 changed files with 653 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export const CustomerFragment = `
firstName
lastName
email
phone
defaultAddress {
id
}
}
`

Expand All @@ -16,6 +20,10 @@ export type CustomerFragmentData = {
firstName?: string
lastName?: string
email?: string
phone?: string
defaultAddress?: {
id: string
}
}

//#endregion
Expand Down Expand Up @@ -146,7 +154,12 @@ export const CustomerCreateMutation = ({
`

export type CustomerCreateMutationVariables = {
input: { email: string; password: string }
input: {
firstName: string
lastName: string
email: string
password: string
}
}

export type CustomerCreateMutationData = {
Expand All @@ -168,6 +181,94 @@ export const CustomerQuery = ({
query customer($customerAccessToken: String!){
customer(customerAccessToken: $customerAccessToken) {
...CustomerFragment
addresses(first:5){
edges{
node{
id
firstName
lastName
company
address1
address2
city
zip
}
}
}
orders(first: 50, sortKey: PROCESSED_AT, reverse: true) {
edges {
node {
id
name
processedAt
orderNumber
cancelReason
fulfillmentStatus
totalShippingPriceV2{
amount
currencyCode
}
successfulFulfillments{
trackingCompany
trackingInfo{
number
url
}
}
shippingAddress{
city
name
zip
address1
}
totalPriceV2 {
amount
currencyCode
}
financialStatus
lineItems(first: 50) {
edges {
node {
title
quantity
originalTotalPrice{
amount
currencyCode
}
variant {
title
id
priceV2 {
amount
currencyCode
}
sku
compareAtPriceV2 {
amount
currencyCode
}
product {
id
images(first: 1) {
edges {
node {
url
}
}
}
}
}
customAttributes {
key
value
}
}
}
}
}
}
}
}
}
${customerFragment}
Expand Down Expand Up @@ -211,3 +312,167 @@ export type CustomerRecoverMutationData = {
}

//#endregion
//#region update
export const CustomerUpdateMutation = ({
customerFragment,
customerUserErrorFragment,
}: {
customerFragment: string
customerUserErrorFragment: string
}) => `
mutation customerUpdate($input: CustomerUpdateInput!,$customerAccessToken: String!){
customerUpdate(customer: $input,customerAccessToken: $customerAccessToken) {
customer {
...CustomerFragment
}
customerUserErrors {
...CustomerUserErrorFragment
}
}
}
${customerUserErrorFragment}
${customerFragment}
`

export type CustomerUpdateMutationVariables = {
input: { firstName: string; lastName: string; phone: string; email: string }
customerAccessToken: string
}

export type CustomerUpdateMutationData = {
customerUpdate: {
customer: StorefrontShopifyFragments['customerFragment']
customerUserErrors: StorefrontShopifyFragments['customerUserErrorFragment'][]
}
}
//#endregion

//#region activateCustomer

export const CustomerActivateMutation = ({
customerFragment,
customerUserErrorFragment,
}: {
customerFragment: string
customerUserErrorFragment: string
}) => `
mutation customerActivate($activationUrl: URL!, $password:String!){
customerActivateByUrl(activationUrl: $activationUrl, password:$password){
customer {
...CustomerFragment
}
customerUserErrors{
...CustomerUserErrorFragment
}
}
}
${customerUserErrorFragment}
${customerFragment}
`
export type CustomerActivateMutationVariables = {
activationUrl: string
password: string
}

export type CustomerActivateMutationData = {
customerActivate: {
customer: StorefrontShopifyFragments['customerFragment']
customerUserErrors: StorefrontShopifyFragments['customerUserErrorFragment'][]
}
}

//#endregion

//#region updatePassword

export const PasswordUpdateMutation = ({
customerFragment,
customerUserErrorFragment,
}: {
customerFragment: string
customerUserErrorFragment: string
}) => `
mutation customerUpdate($input: CustomerUpdateInput!,$customerAccessToken: String!){
customerUpdate(customer: $input,customerAccessToken: $customerAccessToken) {
customer {
...CustomerFragment
}
customerUserErrors {
...CustomerUserErrorFragment
}
}
}
${customerUserErrorFragment}
${customerFragment}
`

export type PasswordUpdateMutationVariables = {
input: { password: string }
customerAccessToken: string
}

export type PasswordUpdateMutationData = {
passwordUpdate: {
customer: StorefrontShopifyFragments['customerFragment']
customerUserErrors: StorefrontShopifyFragments['customerUserErrorFragment'][]
}
}

//#endregion

//#region updatePassword

export const AddressUpdateMutation = ({
customerUserErrorFragment,
}: {
customerUserErrorFragment: string
}) => `
mutation customerAddressUpdate(
$address: MailingAddressInput!
$customerAccessToken: String!
$id: ID!
) {
customerAddressUpdate(
address: $address
customerAccessToken: $customerAccessToken
id: $id
) {
customerAddress {
id
firstName
lastName
company
address1
address2
city
zip
}
customerUserErrors {
...CustomerUserErrorFragment
}
}
}
${customerUserErrorFragment}
`

export type AddressUpdateMutationVariables = {
address: {
firstName: string
lastName: string
company: string
address1: string
address2: string
city: string
zip: string
}
customerAccessToken: string
id: string
}

export type AddressUpdateMutationData = {
addressUpdate: {
customerUserErrors: StorefrontShopifyFragments['customerUserErrorFragment'][]
}
}

//#endregion
Loading

0 comments on commit bbfe232

Please sign in to comment.