Skip to content

Commit 1fff87b

Browse files
authored
Merge pull request #37 from ymaheshwari1/#36
Improved: ui by adding back button, loading the stores on opening pickup modal and dispalying all the stores irrespective of the inventory available(#36)
2 parents 7ecd49e + a480def commit 1fff87b

File tree

4 files changed

+77
-19
lines changed

4 files changed

+77
-19
lines changed

src/locales/en.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@
1212
"Delivery method": "Delivery method",
1313
"Enter keyword to search stores": "Enter keyword to search stores",
1414
"Enter zip code to search stores nearby": "Enter zip code to search stores nearby",
15-
"Fetching stores.": "Fetching stores.",
15+
"Fetching stores": "Fetching stores",
1616
"Install": "Install",
1717
"in stock": "in stock",
1818
"Login": "Login",
1919
"Logout": "Logout",
2020
"mi": "mi",
2121
"Nearby stores": "Nearby stores",
22+
"No customer": "No customer",
23+
"No inventory": "No inventory",
2224
"No shipping estimates": "No shipping estimates",
2325
"No stores found. Please search another store.": "No stores found. Please search another store.",
2426
"No stores found. Please search another zip code.": "No stores found. Please search another zip code.",

src/theme/variables.css

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,23 @@ http://ionicframework.com/docs/theming/ */
235235
}
236236
}
237237

238+
.empty-state {
239+
max-width: 100%;
240+
display: flex;
241+
flex-direction: column;
242+
align-items: center;
243+
justify-content: center;
244+
padding: 10px;
245+
}
246+
247+
.empty-state > img {
248+
object-fit: contain;
249+
}
250+
251+
.empty-state > p {
252+
text-align: center;
253+
}
254+
238255
@media (prefers-color-scheme: dark) {
239256
ion-chip > ion-icon {
240257
color: var(--ion-color-dark);

src/views/OrderDetail.vue

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<ion-page>
33
<ion-header>
44
<ion-toolbar>
5+
<ion-back-button default-href="/" slot="start" @click="back($event)" />
56
<ion-title>{{ $t("Order Details") }}</ion-title>
67
</ion-toolbar>
78
</ion-header>
@@ -11,11 +12,14 @@
1112
<ion-card>
1213
<ion-list>
1314
<ion-item lines="none">
14-
<ion-label>
15-
<h2>{{ order.customer?.first_name }} {{ order.customer?.last_name }}</h2>
15+
<ion-label v-if="order.customer">
16+
<h2>{{ order.customer.first_name }} {{ order.customer.last_name }}</h2>
1617
<!-- TODO: Uncomment this when we'll get CRS information -->
1718
<!-- <p>CSR name</p> -->
1819
</ion-label>
20+
<ion-label v-else>
21+
<h2>{{ $t("No customer") }}</h2>
22+
</ion-label>
1923
<ion-note slot="end">{{ timeFromNow(order?.created_at) }}</ion-note>
2024
</ion-item>
2125
</ion-list>
@@ -68,6 +72,7 @@
6872
<script lang="ts">
6973
import {
7074
alertController,
75+
IonBackButton,
7176
IonButton,
7277
IonCard,
7378
IonContent,
@@ -100,6 +105,7 @@ import { showToast } from "@/utils";
100105
export default defineComponent({
101106
name: 'OrderDetail',
102107
components: {
108+
IonBackButton,
103109
IonButton,
104110
IonCard,
105111
IonContent,
@@ -148,6 +154,10 @@ export default defineComponent({
148154
this.initialOrder = JSON.parse(JSON.stringify(this.order));
149155
},
150156
methods: {
157+
back(event: any) {
158+
event?.preventDefault();
159+
history.back()
160+
},
151161
isPreorderOrBackorderProduct(item: any, label: string){
152162
const product = this.getPreorderItemAvailability(item.sku);
153163
return !(product.label === label);

src/views/PickupLocationModal.vue

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,26 @@
1313
</ion-toolbar>
1414
</ion-header>
1515
<ion-content>
16-
<div v-if="!queryString.length" class="ion-text-center">
17-
<p>{{ searchPriority == 'zipCode' ? $t("Enter zip code to search stores nearby") : $t('Enter keyword to search stores') }}</p>
18-
</div>
16+
<div v-if="isloading" class="empty-state">
17+
<ion-spinner name="crescent" />
18+
<p>{{ $t("Fetching stores") }}</p>
19+
</div>
1920

2021
<div v-else-if="!nearbyStores.length" class="ion-text-center">
2122
<p>{{ searchPriority == 'zipCode' ? $t("No stores found. Please search another zip code.") : $t("No stores found. Please search another store.") }}</p>
2223
</div>
2324

24-
<ion-list v-else >
25+
<ion-list v-else>
2526
<ion-list-header v-if="searchPriority == 'zipCode'" lines="full" color="light">
2627
<ion-label>{{ $t("Nearby stores") }}</ion-label>
2728
</ion-list-header>
2829
<ion-radio-group v-model="selectedFacility">
2930
<ion-item v-for="store of nearbyStores" :key="store.facilityId">
30-
<ion-radio :value="store" slot="start" />
31+
<ion-radio :disabled="!store.atp" :value="store" slot="start" />
3132
<ion-label>
32-
<h2>{{ store.facilityName }}</h2>
33-
<p>{{ store.atp }} {{ $t("in stock") }}</p>
33+
<h2>{{ store.facilityName || store.storeName }}</h2>
34+
<p v-if="store.atp">{{ store.atp }} {{ $t("in stock") }}</p>
35+
<p v-else>{{ $t("No inventory") }}</p>
3436
</ion-label>
3537
<ion-label v-if="store.distance" slot="end">{{ store.distance }} {{ $t("mi") }}</ion-label>
3638
</ion-item>
@@ -57,6 +59,7 @@ import {
5759
IonRadio,
5860
IonRadioGroup,
5961
IonSearchbar,
62+
IonSpinner,
6063
IonTitle,
6164
IonToolbar,
6265
loadingController,
@@ -86,6 +89,7 @@ export default defineComponent({
8689
IonRadio,
8790
IonRadioGroup,
8891
IonSearchbar,
92+
IonSpinner,
8993
IonTitle,
9094
IonToolbar
9195
},
@@ -96,7 +100,8 @@ export default defineComponent({
96100
nearbyStores: [] as any,
97101
selectedFacility: {} as any,
98102
searchPriority: 'zipCode',
99-
filters: process.env.VUE_APP_DEFAULT_STORETYPE
103+
filters: process.env.VUE_APP_DEFAULT_STORETYPE,
104+
isloading: false
100105
}
101106
},
102107
props: ["item", "facilityId"],
@@ -106,20 +111,43 @@ export default defineComponent({
106111
shop: 'shop/getShop'
107112
})
108113
},
109-
mounted() {
114+
async mounted() {
115+
this.isloading = true
110116
const shopifyShops = JSON.parse(process.env.VUE_APP_DEFAULT_SHOP_CONFIG)
111117
const shopConfiguration = shopifyShops[this.shop]
112118
113119
if(shopConfiguration) {
114120
this.searchPriority = shopConfiguration.search
115121
this.filters = shopConfiguration.filters
116122
}
123+
124+
try {
125+
const stores = await this.getStores("")
126+
if (!stores?.length) return;
127+
128+
const facilityIds = stores.map((store: any) => store.storeCode)
129+
const storesWithInventory = await this.checkInventory(facilityIds)
130+
131+
stores.map((storeData: any) => {
132+
const inventoryDetails = storesWithInventory.find((store: any) => store.facilityId === storeData.storeCode);
133+
// only add stores information in array when having inventory for that store
134+
if(inventoryDetails) {
135+
this.nearbyStores.push({ ...storeData, ...inventoryDetails, distance: storeData.dist });
136+
} else {
137+
this.nearbyStores.push({ ...storeData, atp: 0 });
138+
}
139+
});
140+
} catch(err) {
141+
console.error(err)
142+
} finally {
143+
this.isloading = false
144+
}
117145
},
118146
methods: {
119147
async presentLoader() {
120148
this.loader = await loadingController
121149
.create({
122-
message: this.$t("Fetching stores."),
150+
message: this.$t("Fetching stores"),
123151
translucent: true,
124152
});
125153
await this.loader.present();
@@ -134,7 +162,7 @@ export default defineComponent({
134162
135163
async getStores(location: string) {
136164
const payload = {
137-
"viewSize": 50,
165+
"viewSize": 10,
138166
"filters": this.filters,
139167
"keyword": this.queryString
140168
} as any
@@ -180,7 +208,7 @@ export default defineComponent({
180208
});
181209
182210
if (hasError(productInventoryResp) || !productInventoryResp.data.count) return [];
183-
return productInventoryResp.data.docs.filter((store: any) => store.atp > 0)
211+
return productInventoryResp.data.docs;
184212
} catch (error) {
185213
console.error(error)
186214
}
@@ -190,7 +218,7 @@ export default defineComponent({
190218
this.queryString = event.target.value.trim();
191219
if(!this.queryString) return
192220
this.nearbyStores = [];
193-
await this.presentLoader()
221+
this.isloading = true;
194222
try {
195223
let location = ''
196224
@@ -205,19 +233,20 @@ export default defineComponent({
205233
206234
const facilityIds = stores.map((store: any) => store.storeCode)
207235
const storesWithInventory = await this.checkInventory(facilityIds)
208-
if (!storesWithInventory?.length) return;
209236
210237
stores.map((storeData: any) => {
211238
const inventoryDetails = storesWithInventory.find((store: any) => store.facilityId === storeData.storeCode);
212239
// only add stores information in array when having inventory for that store
213240
if(inventoryDetails) {
214241
this.nearbyStores.push({ ...storeData, ...inventoryDetails, distance: storeData.dist });
215-
}
242+
} else {
243+
this.nearbyStores.push({ ...storeData, atp: 0 });
244+
}
216245
});
217246
} catch (error) {
218247
console.error(error)
219248
} finally {
220-
this.dismissLoader()
249+
this.isloading = false
221250
}
222251
},
223252

0 commit comments

Comments
 (0)