Skip to content

Commit

Permalink
fetch offer before showing modal
Browse files Browse the repository at this point in the history
  • Loading branch information
jrlarano committed Sep 12, 2024
1 parent be7785a commit 61a8c17
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 25 deletions.
8 changes: 5 additions & 3 deletions lib/kits/core-ui/components/common/offer-overview.styl
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
overflow-y auto
box-shadow rgba(0, 0, 0, 0.7) 0px 20px 55px, rgba(0, 0, 0, 0.3) 0px 0px 1px
text-align left
max-width 80vw
width 100%
max-width 1450px
width 96%
max-height 80vh
height 650px
background #ffffff
Expand Down Expand Up @@ -214,13 +214,15 @@
overflow hidden

.sgn-product-title
white-space nowrap
overflow hidden
text-overflow ellipsis
max-width 476px
font-weight 600
font-size 1.2rem
padding-bottom 0.2rem
display -webkit-box
-webkit-box-orient vertical
-webkit-line-clamp 2

> a
color inherit
Expand Down
28 changes: 10 additions & 18 deletions lib/kits/core-ui/components/common/offer-overview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,22 +131,6 @@ const OfferOverview = ({
};

const render = async () => {
container = document.createElement('div');
container.className = 'sgn-offer-overview-container';

createModal(container);

container.innerHTML = Mustache.render(template, {
translations,
label: '',
disableShoppingList: document.querySelector('.sgn__offer-shopping')
? false
: true,
offer: {},
loader: true,
layoutWidth: sgnData?.incito?.root_view?.layout_width
});

try {
const transformedOffer =
type === 'paged'
Expand All @@ -158,6 +142,11 @@ const OfferOverview = ({
? false
: true;

container = document.createElement('div');
container.className = 'sgn-offer-overview-container';

createModal(container);

container.innerHTML = Mustache.render(template, {
translations,
label: sgnData?.details?.label,
Expand All @@ -171,10 +160,13 @@ const OfferOverview = ({
dispatchOfferClickEvent(transformedOffer);
addEventListeners();
} catch (error) {
destroyModal();
displayOfferMessage(offer.viewId, "Couldn't fetch offer data");
displayOfferMessage(
offer.viewId,
translate('publication_viewer_no_product_message')
);
}
};

const transformProducts = (offer, products) => {
const {localeCode, currency} = translations;
const storedPublicationOffers =
Expand Down
3 changes: 2 additions & 1 deletion locales/da_DK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ export default {
publication_viewer_visit_webshop_link: 'Besøg webshoplink',
publication_viewer_upcoming: 'Kommende',
publication_viewer_offer_price_from: 'Fra',
publication_viewer_offer_valid_from: 'Gælder kun fra d. '
publication_viewer_offer_valid_from: 'Gælder kun fra d. ',
publication_viewer_no_product_message: 'Ingen produkt detaljer'
};
3 changes: 2 additions & 1 deletion locales/en_US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ export default {
publication_viewer_visit_webshop_link: 'Visit Webshop Link',
publication_viewer_upcoming: 'Upcoming',
publication_viewer_offer_price_from: 'From',
publication_viewer_offer_valid_from: 'Valid from '
publication_viewer_offer_valid_from: 'Valid from ',
publication_viewer_no_product_message: 'No product details'
};
3 changes: 2 additions & 1 deletion locales/nb_NO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ export default {
publication_viewer_visit_webshop_link: 'Besøk nettbutikklink',
publication_viewer_upcoming: 'Påkommende',
publication_viewer_offer_price_from: 'Fra',
publication_viewer_offer_valid_from: 'Gjelder kun fra '
publication_viewer_offer_valid_from: 'Gjelder kun fra ',
publication_viewer_no_product_message: 'Ingen produktdetalje'
};
3 changes: 2 additions & 1 deletion locales/sv_SE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ export default {
publication_viewer_visit_webshop_link: 'Besök webbshoplänk',
publication_viewer_upcoming: 'Kommende',
publication_viewer_offer_price_from: 'Från',
publication_viewer_offer_valid_from: 'Gäller endast fr.o.m '
publication_viewer_offer_valid_from: 'Gäller endast fr.o.m ',
publication_viewer_no_product_message: 'Inga produktdetaljer'
};

0 comments on commit 61a8c17

Please sign in to comment.