Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Commit

Permalink
refactor: update the change password from api client (#329)
Browse files Browse the repository at this point in the history
* feat: multi currency

* feat: multi-currency feature

* feat: added multicurrency feature (static)

* feat: pdp: multi currency

* feat: muti-currency refactor

* chore: version upgrade

* feat: added feature to update userfields

* fix: fixed selected variantby options

* fix: cartgetters item price

* refactor: getproducts api method

* fix: login modal popup error

* feat: display discount on cart drawer

* chore: updated shopify version

* chore: remove wishlist function for now (#213)

Co-authored-by: Jeff Paltera <[email protected]>

* fix: incosistent footer (#214)

* chore: update the misaligned margin of components (#215)

* chore: update home padding

* chore: updated margin on whole

* chore: updated margin on whole

* feat: display discount on cart drawer (#230)

* feat: multi currency

* feat: multi-currency feature

* feat: added multicurrency feature (static)

* feat: pdp: multi currency

* feat: muti-currency refactor

* chore: version upgrade

* feat: added feature to update userfields

* fix: fixed selected variantby options

* fix: cartgetters item price

* refactor: getproducts api method

* chore: remove wishlist function for now (#213)

Co-authored-by: Jeff Paltera <[email protected]>

* fix: incosistent footer (#214)

* chore: update the misaligned margin of components (#215)

* chore: update home padding

* chore: updated margin on whole

* chore: updated margin on whole

* fix: login modal popup error

* feat: display discount on cart drawer

* chore: updated shopify version

Co-authored-by: Jeff Paltera <[email protected]>
Co-authored-by: Jeff Paltera <[email protected]>

* fix: ssr for crawlers for multilingual

* fix: version upgraded

* refactor: added function for detect country

* fix: ssr for crawlers for multilingual (#231)

* feat: multi currency

* feat: multi-currency feature

* feat: added multicurrency feature (static)

* feat: pdp: multi currency

* feat: muti-currency refactor

* chore: version upgrade

* feat: added feature to update userfields

* fix: fixed selected variantby options

* fix: cartgetters item price

* refactor: getproducts api method

* chore: remove wishlist function for now (#213)

Co-authored-by: Jeff Paltera <[email protected]>

* fix: incosistent footer (#214)

* chore: update the misaligned margin of components (#215)

* chore: update home padding

* chore: updated margin on whole

* chore: updated margin on whole

* fix: login modal popup error

* feat: display discount on cart drawer

* chore: updated shopify version

* fix: ssr for crawlers for multilingual

* fix: version upgraded

* refactor: added function for detect country

Co-authored-by: Jeff Paltera <[email protected]>
Co-authored-by: Jeff Paltera <[email protected]>

* chore: add #TechForUkraine

* Update README.md

* feat(cartdrawer): coupon add/remove feature

* feat(cartdrawer): coupon add/remove feature

* fix: suggested changes

* refactor: remove shopify buy deps from createcart & checkout

* refactor: removed shopify buy deps from updatecart

* fix: resolved linter error

* refactor: suggeted changes

* refactor: suggeted changes

* refactor: refactored get country method for getproduct

* refactor: implemented suggested changes

* refactor: implemented suggested changes

* refactor: pdp: related products- disabled add to cart for out of stock products

* refactor: removed any from default query

* fix(PDP): add to cart not working on match with it section

* chore: updated sfui to 0.12.x

* refactor: removed context as param from setup method

* chore: upgraded SFUI to 0.12.3

* fix: updated yarn.lock

* fix: updated currency to EUR in nuxt.config.js

* refactor: added observer for section rendering

* refactor(sign in): removed shopify buy deps from signin api

* refactor(sign out): removed shopify buy deps from sign out api

* fix: resolved conflicts

* refactor: removed shopify buy sdk deps from signup

* refactor: removed shopify buy sdk deps from forgotpassword api method

* refactor: removed shopify buy sdk deps from change password api method

Co-authored-by: Jeff Paltera <[email protected]>
Co-authored-by: Jeff Paltera <[email protected]>
Co-authored-by: Heitor Ramon Ribeiro <[email protected]>
  • Loading branch information
4 people authored Apr 12, 2022
1 parent 5406521 commit f7b5ced
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 39 deletions.
26 changes: 17 additions & 9 deletions packages/api-client/src/api/changePassword/index.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { gql } from '@apollo/client/core';
import { changePasswordMutation as mutation } from './../customerMutations/buildMutations';

// eslint-disable-next-line @typescript-eslint/no-unused-vars
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export default async function changePassword(context, params) {
export async function changePassword(context, params) {
const { token, newPassword } = params;
const data = {

const payload = {
customerAccessToken: token,
customer: {
password: newPassword
}
};

// Remove customer access token
return await context.client.graphQLClient.send(mutation(context), data).then(({model}) => {
return model;
});
const { customerUpdate } = context.extendQuery({
customerUpdate: {
mutation,
variables: payload
}
})

return await context.client.apolloClient.mutate({
mutation: gql(customerUpdate.mutation) as any,
variables: customerUpdate.payload
}).then((result) => {
return result.data.customerUpdate;
});
}
49 changes: 22 additions & 27 deletions packages/api-client/src/api/customerMutations/buildMutations.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,4 @@
/* TODO: Fetch custom client directly, may be using context */
const changePasswordMutation: (context) => any = (context): any => {
const customerAccessToken = context.client.graphQLClient.variable('customerAccessToken', 'String!');
const customer = context.client.graphQLClient.variable('customer', 'CustomerUpdateInput!');

return context.client.graphQLClient.mutation('customerUpdate', [customerAccessToken, customer], (root) => {
root.add('customerUpdate', {args: {customerAccessToken, customer}}, (customer) => {
customer.add('customer', (fields) => {
fields.add('id');
fields.add('displayName');
fields.add('email');
fields.add('firstName');
fields.add('lastName');
fields.add('phone');
});
customer.add('customerAccessToken', (token) => {
token.add('accessToken');
token.add('expiresAt');
});
customer.add('customerUserErrors', (error) => {
error.add('code');
error.add('field');
error.add('message');
});
});
});
};

const resetPasswordByUrlMutation: (context) => any = (context): any => {

const resetUrl = context.client.graphQLClient.variable('resetUrl', 'URL!');
Expand Down Expand Up @@ -172,6 +145,28 @@ const forgotPasswordMutation = `mutation RESET_PASSWORD($email: String!){
}
}`;

const changePasswordMutation = `mutation CHANGE_PASSWORD($customerAccessToken: String!, $customer: CustomerUpdateInput!){
customerUpdate(customerAccessToken: $customerAccessToken, customer: $customer) {
customerAccessToken {
accessToken
expiresAt
}
customer {
id
firstName
lastName
email
displayName
acceptsMarketing
}
customerUserErrors {
code
field
message
}
}
}`;

export {
changePasswordMutation,
forgotPasswordMutation,
Expand Down
2 changes: 1 addition & 1 deletion packages/api-client/src/index.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { removeCoupon } from './api/removeCartCoupon';
import { signUp } from './api/signUp';
import { signIn } from './api/signIn';
import { signOut } from './api/signOut';
import changePassword from './api/changePassword';
import { changePassword } from './api/changePassword';
import { forgotPassword } from './api/forgotPassword';
import { fetchCustomer } from './api/fetchCustomer';
import fetchOrders from './api/fetchOrders';
Expand Down
2 changes: 1 addition & 1 deletion packages/theme/components/MyAccount/BillingAddressForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
</div> -->
<div class="my-account-bottom-action-wrap">
<div class="form__button_wrap">
<SfButton data-cy="billing-details-btn_update" class="form__button" @click.native="scrollToTop()">
<SfButton data-cy="billing-details-btn_update" type="submit" class="form__button" @click.native="scrollToTop()">
{{ isNew ? "Add To My Address Book" : "Update My Address Book" }}
</SfButton>
</div>
Expand Down
3 changes: 2 additions & 1 deletion packages/theme/pages/MyAccount/MyProfile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
</ValidationProvider>
<div class="my-account-bottom-action-wrap">
<div class="form__button_wrap">
<SfButton data-cy="my-profile-btn_update" class="form__button"
<SfButton data-cy="my-profile-btn_update" class="form__button" type="submit"
>Update Profile</SfButton
>
</div>
Expand Down Expand Up @@ -125,6 +125,7 @@
<SfButton
data-cy="my-profile-btn_update-password"
class="form__button"
type="submit"
>Change password</SfButton
>
</div>
Expand Down

0 comments on commit f7b5ced

Please sign in to comment.