Skip to content

Commit

Permalink
feat(com-pwa): order storage context provider director
Browse files Browse the repository at this point in the history
  • Loading branch information
njfamirm authored and AliMD committed Feb 11, 2023
1 parent 27e352e commit cf363a2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions uniquely/com-pwa/src/director/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ import '@alwatr/pwa-helper/director.js';
import './l18e-loader.js';
import './content-provider.js';
import './product-storage-context-provider.js';
import './order-storage-context-provider.js';
32 changes: 32 additions & 0 deletions uniquely/com-pwa/src/director/order-storage-context-provider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import {fetchContext} from '@alwatr/fetch';
import {message} from '@alwatr/i18n';
import {snackbarSignalTrigger} from '@alwatr/ui-kit/src/snackbar/show-snackbar.js';

import {logger} from './logger.js';
import {config} from '../config.js';

const provideOrderStorageContext = async (): Promise<void> => {
logger.logMethod('provideOrderStorageContext');

try {
await fetchContext('order-storage-context', {
method: 'GET',
url: config.api + '/order/',
token: config.token,
});
}
catch (err) {
logger.error('provideOrderStorageContext', 'fetch_failed', err);

const response = await snackbarSignalTrigger.requestWithResponse({
message: message('fetch_failed'),
actionLabel: message('retry'),
duration: -1,
});
if (response.actionButton) {
provideOrderStorageContext();
}
}
};

provideOrderStorageContext();

0 comments on commit cf363a2

Please sign in to comment.