Skip to content

Commit

Permalink
Merge branch 'main' into fix/guest-with-shipping-as-billing
Browse files Browse the repository at this point in the history
  • Loading branch information
csandru-plenty committed Nov 6, 2024
2 parents fb0438c + 7786f44 commit c0f1360
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 9 deletions.
2 changes: 2 additions & 0 deletions apps/web/composables/useNewsletterConfirmation/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './useNewsletterConfirmation';
export * from './types';
9 changes: 9 additions & 0 deletions apps/web/composables/useNewsletterConfirmation/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Data } from '@plentymarkets/shop-api';

export type EmailConfirmationOptin = (newsletterEmailId: string, authString: string) => Promise<Data<boolean>>;

export interface UseNewsletterConfirmation {
confirmEmail: EmailConfirmationOptin;
}

export type UseNewsletterConfirmationReturn = () => UseNewsletterConfirmation;
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { EmailConfirmationOptin, UseNewsletterConfirmationReturn } from '~/composables/useNewsletterConfirmation/types';

const confirmEmail: EmailConfirmationOptin = async (newsletterEmailId, authString) => {
return await useSdk().plentysystems.doEmailConfirmation({
newsletterEmailId,
authString,
});
};

export const useNewsletterConfirmation: UseNewsletterConfirmationReturn = () => {
return {
confirmEmail,
};
};
6 changes: 5 additions & 1 deletion apps/web/lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,10 @@
"stopEdit": "Abbrechen"
},
"email": "E-Mail",
"emailConfirmation": {
"newsletterOptInMessage": "Ihre E-Mail-Adresse wurde bestätigt.",
"newsletterOptInMessageError": "Beim Bestätigen Ihrer E-Mail ist ein Fehler aufgetreten."
},
"emptyCart": "Ihr Warenkorb ist leer",
"emptyCartImgAlt": "Bild eines leeren Warenkorbs",
"emptyCartNotification": "Sie haben keine Artikel in Ihrem Warenkorb",
Expand Down Expand Up @@ -687,7 +691,7 @@
"lastName": "Nachname",
"policy": "Ich bestätige hiermit, dass ich die {privacyPolicy} gelesen habe. Ich kann meine Einwilligung jederzeit widerrufen.",
"subscribe": "Newsletter abonnieren",
"success": "Newsletter erfolgreich abonniert"
"success": "Vielen Dank für Ihre Anmeldung! Bitte prüfen Sie Ihr E-Mail-Postfach und klicken Sie auf den Bestätigungslink in unserer Nachricht, um den Newsletter zu abonnieren."
},
"next": "Nächste",
"nextAriaLabel": "Zur nächsten Seite navigieren",
Expand Down
6 changes: 5 additions & 1 deletion apps/web/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,10 @@
"stopEdit": "Cancel"
},
"email": "Email",
"emailConfirmation": {
"newsletterOptInMessage": "Your email address has been confirmed.",
"newsletterOptInMessageError": "An error occurred while confirming your email."
},
"emptyCart": "Your cart is empty",
"emptyCartImgAlt": "Image of an empty cart",
"emptyCartNotification": "You don't have any items in your cart",
Expand Down Expand Up @@ -687,7 +691,7 @@
"lastName": "Last Name",
"policy": "I hereby confirm that I have read the {privacyPolicy}. I can revoke my consent at any time.",
"subscribe": "Subscribe To Newsletter",
"success": "Newsletter successfully subscribed"
"success": "Thank you for signing up! Please check your email inbox and click on the confirmation link in our message to complete your newsletter subscription."
},
"next": "Next",
"nextAriaLabel": "Navigate to next page",
Expand Down
23 changes: 23 additions & 0 deletions apps/web/middleware/newsletter-confirmation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export default defineNuxtRouteMiddleware(async ({ query }) => {
if (query.ActionCall === 'WebActionConfirmNewsletter' && import.meta.client) {
const { confirmEmail } = useNewsletterConfirmation();
const { send } = useNotification();
const { $i18n } = useNuxtApp();

if (query.newsletterEmailId && query.authString) {
const response = await confirmEmail(query.newsletterEmailId.toString(), query.authString.toString());
if (response && response.data) {
send({
message: $i18n.t('emailConfirmation.newsletterOptInMessage'),
type: 'positive',
persist: true,
});
} else {
send({
message: $i18n.t('emailConfirmation.newsletterOptInMessageError'),
type: 'negative',
});
}
}
}
});
3 changes: 2 additions & 1 deletion apps/web/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
<script lang="ts" setup async>
const isEditing = useEditor();
const { formattedHeroItems, mediaData, recommendedProductsCategoryId } = await useHomepageData();
definePageMeta({ pageType: 'static' });
definePageMeta({ pageType: 'static', middleware: ['newsletter-confirmation'] });
const { showNewsletter } = useNewsletter();
const { t } = useI18n();
</script>
6 changes: 6 additions & 0 deletions docs/changelog/changelog_en.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog plentyshopPWA

## v1.x.x (yyyy-mm-dd)

### 👷 Changed

- Newsletter email confirmation

## v1.7.0 (2024-11-06) <a href="https://github.com/plentymarkets/plentyshop-pwa/compare/v1.6.0...v1.7.0" target="_blank" rel="noopener"><b>Overview of all changes</b></a>

### New
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"lhci:mobile": "lhci autorun"
},
"dependencies": {
"@plentymarkets/shop-api": "^0.72.2",
"@plentymarkets/shop-api": "^0.72.3",
"@types/applepayjs": "^14.0.8",
"@types/googlepay": "^0.7.6",
"@vee-validate/nuxt": "^4.13.2",
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4237,7 +4237,7 @@ __metadata:
"@nuxt/test-utils": ^3.13.1
"@nuxtjs/turnstile": ^0.8.0
"@paypal/paypal-js": 8.1.0
"@plentymarkets/shop-api": ^0.72.2
"@plentymarkets/shop-api": ^0.72.3
"@types/applepayjs": ^14.0.8
"@types/googlepay": ^0.7.6
"@types/uuid": ^9.0.8
Expand Down Expand Up @@ -4271,14 +4271,14 @@ __metadata:
languageName: unknown
linkType: soft

"@plentymarkets/shop-api@npm:^0.72.2":
version: 0.72.2
resolution: "@plentymarkets/shop-api@npm:0.72.2::__archiveUrl=https%3A%2F%2Fnpm.pkg.github.com%2Fdownload%2F%40plentymarkets%2Fshop-api%2F0.72.2%2F7371967a71ce02df820ea101fb9d994088eda326"
"@plentymarkets/shop-api@npm:^0.72.3":
version: 0.72.3
resolution: "@plentymarkets/shop-api@npm:0.72.3::__archiveUrl=https%3A%2F%2Fnpm.pkg.github.com%2Fdownload%2F%40plentymarkets%2Fshop-api%2F0.72.3%2F4ad974b92d73b1f72631858bfb033a8903024002"
dependencies:
"@vue-storefront/middleware": ^3.10.0
axios: ^1.7.7
consola: ^3.2.3
checksum: 8fe6d4bf487d9a6f2b8714a75d876c77fdd2009a1b4139cd436ea90f5233dca710ae019ffd31fd91ebc66239f0334dc062d7d3e1c7486c7959762b463a049c27
checksum: cde1b652b795987c68e938f301d80de123e1418ef7ef61522887e155e6ae48f6d496aae7d7733f4b6548486e53e102861066df7d252b5dd13929d772424041af
languageName: node
linkType: hard

Expand Down

0 comments on commit c0f1360

Please sign in to comment.