Skip to content

Commit

Permalink
Merge branch 'develop' into PWA-3155
Browse files Browse the repository at this point in the history
  • Loading branch information
glo42707 authored May 25, 2023
2 parents cccfbdd + defc0c8 commit 4dd3177
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"license": "(OSL-3.0 OR AFL-3.0)",
"dependencies": {
"@adobe/magento-storefront-event-collector": "~1.3.1",
"@adobe/magento-storefront-events-sdk": "~1.1.19"
"@adobe/magento-storefront-events-sdk": "~1.3.1"
},
"devDependencies": {},
"peerDependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const canHandle = event => event.type === 'USER_SIGN_OUT';

const handle = sdk => {
sdk.context.setShopper({
shopperId: 'guest'
});

const accountContext = {
firstName: '',
lastName: '',
emailAddress: ''
};

const cartContext = {
id,
prices: {},
items: {},
possibleOnepageCheckout: false,
giftMessageSelected: false,
giftWrappingSelected: false
};

sdk.context.setShoppingCart(cartContext);
sdk.context.setAccount(accountContext);

sdk.publish.signOut();
};

export default {
canHandle,
handle
};
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ test('it returns the proper shape', () => {
errorLoadingGiftCards: expect.any(Boolean),
errorRemovingCard: expect.any(Boolean),
giftCardsData: expect.any(Array),
handleEnterKeyPress: expect.any(Function),
isLoadingGiftCards: expect.any(Boolean),
isApplyingCard: expect.any(Boolean),
isCheckingBalance: expect.any(Boolean),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@ export const useGiftCards = props => {
removeCardLoading,
setIsCartUpdating
]);
const handleEnterKeyPress = useCallback(() => {
event => {
if (event.key === 'Enter') {
applyGiftCard();
}
};
}, [applyGiftCard]);

const shouldDisplayCardBalance =
mostRecentAction === actions.CHECK_BALANCE &&
Expand All @@ -178,6 +185,7 @@ export const useGiftCards = props => {
(appliedCardsResult.data &&
appliedCardsResult.data.cart.applied_gift_cards) ||
[],
handleEnterKeyPress,
isLoadingGiftCards: appliedCardsResult.loading,
isApplyingCard: applyCardLoading,
isCheckingBalance: balanceResult.loading,
Expand Down
2 changes: 1 addition & 1 deletion packages/peregrine/lib/talons/FilterModal/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export const stripHtml = html => html.replace(/(<([^>]+)>)/gi, '');

/** GetFilterInput helpers below. */
const getValueFromFilterString = keyValueString =>
keyValueString.split(DELIMITER)[1];
keyValueString.split(DELIMITER).pop();

/**
* Converts a set of values to a range filter
Expand Down
6 changes: 3 additions & 3 deletions packages/peregrine/lib/talons/Link/__tests__/useLink.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const givenEmptyProps = () => {

const givenValidProps = () => {
props = {
prefetchType: true,
shouldPrefetch: true,
innerRef: { current: 'foo' },
to: '/bar.html'
};
Expand All @@ -86,7 +86,7 @@ const givenFalsePrefetch = () => {
givenValidProps();
props = {
...props,
prefetchType: false
shouldPrefetch: false
};
};

Expand Down Expand Up @@ -175,7 +175,7 @@ describe('#useLink does not run query when', () => {
expect(mockRunQuery).not.toHaveBeenCalled();
});

test('should prefetch is false', async () => {
test('prefetch flag is false', async () => {
givenFalsePrefetch();

await act(() => {
Expand Down
4 changes: 1 addition & 3 deletions packages/peregrine/lib/talons/Link/useLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import DEFAULT_OPERATIONS from '../MagentoRoute/magentoRoute.gql';
export const useLink = (props, passedOperations = {}) => {
const { innerRef: originalRef, to } = props;
const shouldPrefetch = props.prefetchType || props.shouldPrefetch;
const operations = shouldPrefetch
? mergeOperations(DEFAULT_OPERATIONS, passedOperations)
: {};
const operations = mergeOperations(DEFAULT_OPERATIONS, passedOperations);

const intersectionObserver = useIntersectionObserver();
const { resolveUrlQuery } = operations;
Expand Down
10 changes: 10 additions & 0 deletions packages/peregrine/lib/talons/MagentoRoute/useMagentoRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ export const useMagentoRoute = (props = {}) => {
const { data, error, loading } = queryResult;
const { route } = data || {};

// redirect to external url
useEffect(() => {
if (route) {
const external_URL = route.relative_url;
if (external_URL && external_URL.startsWith('http')) {
window.location.replace(external_URL);
}
}
}, [route]);

useEffect(() => {
if (initialized.current || !getInlinedPageData()) {
runQuery({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ exports[`it renders correctly when it has cards 1`] = `
disabled={false}
onClick={[MockFunction]}
onDragStart={[Function]}
onKeyDown={[Function]}
onKeyUp={[Function]}
onMouseDown={[Function]}
onMouseEnter={[Function]}
Expand Down Expand Up @@ -337,7 +336,6 @@ exports[`it renders correctly with no cards 1`] = `
disabled={false}
onClick={[MockFunction]}
onDragStart={[Function]}
onKeyDown={[Function]}
onKeyUp={[Function]}
onMouseDown={[Function]}
onMouseEnter={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const GiftCards = props => {
errorLoadingGiftCards,
errorRemovingCard,
giftCardsData,
handleEnterKeyPress,
isLoadingGiftCards,
isApplyingCard,
isCheckingBalance,
Expand Down Expand Up @@ -198,6 +199,7 @@ const GiftCards = props => {
data-cy="GiftCards-apply"
disabled={isApplyingCard}
onClick={applyGiftCard}
onKeyDown={handleEnterKeyPress}
>
<FormattedMessage
id={'giftCards.apply'}
Expand Down
14 changes: 7 additions & 7 deletions packages/venia-ui/lib/components/SearchBar/searchBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,6 @@ const SearchBar = React.forwardRef((props, ref) => {
initialValues={initialValues}
onSubmit={handleSubmit}
>
<div className={classes.autocomplete}>
<Autocomplete
setVisible={setIsAutoCompleteOpen}
valid={valid}
visible={isAutoCompleteOpen}
/>
</div>
<div className={classes.search}>
<SearchField
addLabel={formatMessage({
Expand All @@ -52,6 +45,13 @@ const SearchBar = React.forwardRef((props, ref) => {
onChange={handleChange}
onFocus={handleFocus}
/>
<div className={classes.autocomplete}>
<Autocomplete
setVisible={setIsAutoCompleteOpen}
valid={valid}
visible={isAutoCompleteOpen}
/>
</div>
</div>
</Form>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@

.autocomplete {
composes: grid from global;
composes: relative from global;
/* composes: relative from global; */
composes: z-menu from global;
}
9 changes: 8 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,20 @@
"@snowplow/browser-plugin-performance-timing" "^3.0.1"
"@snowplow/browser-tracker" "^3.0.1"

"@adobe/magento-storefront-events-sdk@*", "@adobe/magento-storefront-events-sdk@~1.1.19":
"@adobe/magento-storefront-events-sdk@*":
version "1.1.19"
resolved "https://registry.yarnpkg.com/@adobe/magento-storefront-events-sdk/-/magento-storefront-events-sdk-1.1.19.tgz#7632b873c4e913505d6176384618017315999a77"
integrity sha512-N/FEN5kEUvLvrjVf+xjZkkOKIP+dD9D++CBwBVbpwpRwsMzVhDAJA0txfquesa/bVQIPf8MlJ43jdEoyH9/RJg==
dependencies:
"@adobe/adobe-client-data-layer" "^2.0.2"

"@adobe/magento-storefront-events-sdk@~1.3.1":
version "1.3.1"
resolved "https://registry.yarnpkg.com/@adobe/magento-storefront-events-sdk/-/magento-storefront-events-sdk-1.3.1.tgz#efe9e5898462ef8d6b360af483919566dfadf69e"
integrity sha512-Ky8iovqTpaCnMPcm7ZMZAPlGsLhOnbUCNiWX13JeFKqo+T+kRoipHfDzlNiWaYmRdys1QOODn7xpoROynwUVRg==
dependencies:
"@adobe/adobe-client-data-layer" "^2.0.2"

"@adobe/reactor-cookie@^1.0.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@adobe/reactor-cookie/-/reactor-cookie-1.1.0.tgz#9c13201fc4dd41b7600aa911e587539b7b9e4216"
Expand Down

0 comments on commit 4dd3177

Please sign in to comment.