Skip to content

Commit

Permalink
Fix some issues for free listing (#212)
Browse files Browse the repository at this point in the history
* fix multiple

* remove log

* add content type in Post

* remove comments

* fix some issues

Co-authored-by: Elise Griset <eGriset@PRESTAMAC-094.local>
  • Loading branch information
elisegriset92 and Elise Griset committed Jul 13, 2021
1 parent 99e6d7f commit e088de5
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 36 deletions.
2 changes: 1 addition & 1 deletion _dev/src/components/google-account/google-account-card.vue
Expand Up @@ -140,7 +140,7 @@
class="mb-0 mt-3"
>
<p class="mb-0">
{{ $t(`googleAccountCard.alert${error}`)}}
{{ $t(`googleAccountCard.alert${error}`) }}
</p>
<div
v-if="error === 'CantConnect'"
Expand Down
4 changes: 3 additions & 1 deletion _dev/src/components/product-feed/product-feed-card.vue
Expand Up @@ -350,7 +350,9 @@ export default {
day: this.$options.filters.timeConverterToDate(
this.getProductFeedStatus?.jobEndedAt,
),
time: '1am',
time: this.$options.filters.timeConverterToHour(
this.getProductFeedStatus?.jobEndedAt,
),
totalProducts: this.getProductFeedSettings.productsPerBatchSync,
};
},
Expand Down
Expand Up @@ -25,7 +25,7 @@
<product-feed-card-next-sync-card
icon="schedule"
:title="$t('productFeedSettings.summary.time')"
description="1am"
:description="nextSyncDate | timeConverterToHour"
/>
</b-row>
</b-container>
Expand Down
66 changes: 35 additions & 31 deletions _dev/src/store/modules/free-listing/actions.ts
Expand Up @@ -21,38 +21,41 @@ import ActionsTypes from './actions-types';
import HttpClientError from '../../../utils/HttpClientError';

export default {
async [ActionsTypes.GET_VALIDATION_LIST]({commit, rootState}) {
try {
const response = await fetch(`${rootState.app.psGoogleShoppingApiUrl}/...`);
if (!response.ok) {
throw new HttpClientError(response.statusText, response.status);
}
const json = await response.json();
commit(MutationsTypes.SET_VALIDATION_LIST_STATEMENT, json);
} catch (error) {
console.error(error);
}
},
// async [ActionsTypes.GET_VALIDATION_LIST]({commit, rootState}) {
// try {
// const response = await fetch(`${rootState.app.psGoogleShoppingApiUrl}/...`);
// if (!response.ok) {
// throw new HttpClientError(response.statusText, response.status);
// }
// const json = await response.json();
// commit(MutationsTypes.SET_VALIDATION_LIST_STATEMENT, json);
// } catch (error) {
// console.error(error);
// }
// },

async [ActionsTypes.GET_SUMMARY_VALIDATION]({commit, rootState}) {
try {
const response = await fetch(`${rootState.app.psGoogleShoppingApiUrl}/...`);
if (!response.ok) {
throw new HttpClientError(response.statusText, response.status);
}
const json = await response.json();
commit(MutationsTypes.SET_SUMMARY_VALIDATION, json);
} catch (error) {
console.error(error);
}
},
// async [ActionsTypes.GET_SUMMARY_VALIDATION]({commit, rootState}) {
// try {
// const response = await fetch(`${rootState.app.psGoogleShoppingApiUrl}/...`);
// if (!response.ok) {
// throw new HttpClientError(response.statusText, response.status);
// }
// const json = await response.json();
// commit(MutationsTypes.SET_SUMMARY_VALIDATION, json);
// } catch (error) {
// console.error(error);
// }
// },

async [ActionsTypes.GET_FREE_LISTING_STATUS]({commit, rootState}, enabled: boolean) {
async [ActionsTypes.GET_FREE_LISTING_STATUS]({commit, rootState}) {
try {
const resp = await fetch(`${rootState.app.psGoogleShoppingApiUrl}/free-listings/settings`,
{
method: 'GET',
headers: {'Content-Type': 'application/json', Accept: 'application/json'},
headers: {
Accept: 'application/json',
Authorization: `Bearer ${rootState.accounts.tokenPsAccounts}`,
},
});
if (!resp.ok) {
throw new HttpClientError(resp.statusText, resp.status);
Expand All @@ -68,7 +71,11 @@ export default {
const resp = await fetch(`${rootState.app.psGoogleShoppingApiUrl}/free-listings/toggle`,
{
method: 'POST',
headers: {'Content-Type': 'application/json', Accept: 'application/json'},
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
Authorization: `Bearer ${rootState.accounts.tokenPsAccounts}`,
},
body: JSON.stringify({
enabled,
}),
Expand All @@ -77,12 +84,9 @@ export default {
commit(MutationsTypes.SET_ERROR_API, true);
throw new HttpClientError(resp.statusText, resp.status);
}

const json = await resp.json();
commit(MutationsTypes.SET_ERROR_API, false);
// ! It looks like the API always sends back "true"
// ! So i don't use its response
commit(MutationsTypes.SET_FREE_LISTING_STATUS, enabled);
commit(MutationsTypes.SET_FREE_LISTING_STATUS, json.enabled);
} catch (error) {
console.error(error);
}
Expand Down
4 changes: 2 additions & 2 deletions _dev/src/utils/Filters.ts
Expand Up @@ -5,7 +5,7 @@ Vue.filter(
if (timestamp) {
const a = new Date(timestamp);
const year = a.getFullYear();
const month = a.getMonth();
const month = a.getMonth() + 1;
const finalMonth = month < 10 ? `0${month}` : month;
const day = a.getDate();
const finalDay = day < 10 ? `0${day}` : day;
Expand All @@ -17,7 +17,7 @@ Vue.filter(

Vue.filter(
'timeConverterToHour', (timestamp : string) => {
if (!timestamp) {
if (timestamp) {
const a = new Date(timestamp);
const hour = a.getHours();
const min = a.getMinutes();
Expand Down
1 change: 1 addition & 0 deletions _dev/src/views/tunnel-product-feed.vue
Expand Up @@ -35,6 +35,7 @@ export default {
},
beforeCreate() {
this.$store.dispatch('productFeed/GET_PRODUCT_FEED_SETTINGS');
this.$store.dispatch('productFeed/GET_PRODUCT_FEED_SYNC_STATUS');
this.$store.dispatch('productFeed/GET_TOTAL_PRODUCTS');
},
Expand Down

0 comments on commit e088de5

Please sign in to comment.