Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented: logic to edit data #22c8vgh #8

Merged
merged 23 commits into from
Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
4b96fb4
Implemeted Static UI for displaying parsed csv and Implemented logic …
disha1202 Feb 23, 2022
e39d275
Improved spacing(#22c8vf8)
disha1202 Feb 24, 2022
85cf50f
Rendered data on purchase order detail page(#22c8vf8)
disha1202 Feb 24, 2022
a9b1146
Added changelog entry(#22c8vf8)
disha1202 Feb 24, 2022
30ce3d5
Improved code to render data on order detail page(#22c8vf8)
disha1202 Feb 24, 2022
b8bde2d
Removed unwanted code(#22c8vf8)
disha1202 Feb 24, 2022
0919210
Implemented logic to get product information(#22c8vf8)
disha1202 Feb 24, 2022
83da67d
Improved spacing and removed console statements(#22c8vf8)
disha1202 Feb 24, 2022
0eca8be
Implemented logic to render data(#22c8vgh)
disha1202 Mar 1, 2022
af887f2
Improved logic to render products(#22c8vgh)
disha1202 Mar 2, 2022
29a5de0
Merge branch 'main' of https://github.com/hotwax/import into #22c8vgh
disha1202 Mar 2, 2022
21b1b04
Updated code(#22c8vgh)
disha1202 Mar 2, 2022
4529e82
Updated code (#22c8vgh)
disha1202 Mar 2, 2022
85bd3b0
Updated order getters(#22c8vgh)
disha1202 Mar 2, 2022
6181616
Improved code(#22c8vgh)
disha1202 Mar 2, 2022
80255ff
Improved code and updated method name and valiables name(#22c8vgh)
disha1202 Mar 3, 2022
7f1a888
Improved order state and logic to select products(#22c8vgh)
disha1202 Mar 3, 2022
dc7df79
Updated order state and logic to select products(#22c8vgh)
disha1202 Mar 3, 2022
831de85
Added changelog entry(#22c8vgh)
disha1202 Mar 4, 2022
57e9549
Improved indentation and removed unwanted changes(#22c8vgh)
disha1202 Mar 4, 2022
5bb2d03
Updated the code to use correct variable(#22c8vgh)
disha1202 Mar 4, 2022
116c7d0
Updated component name(#22c8vgh)
disha1202 Mar 4, 2022
b796b47
Improved order actions(#22c8vgh)
disha1202 Mar 4, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelogs/unreleased/-22c8vf8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: Implemented logic to render data on order detail page
ticket_id: "#22c8vf8"
merge_request: 5
author: Disha Talreja
type: added
4 changes: 4 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"all items": "all items",
"Apply": "Apply",
"Are you sure you want to change the time zone to?": "Are you sure you want to change the time zone to?",
"Arrival date": "Arrival date",
"Backorder": "Backorder",
"Blank": "Blank",
"Cancel": "Cancel",
"Change": "Change",
Expand All @@ -17,6 +20,7 @@
"Order ID": "Order ID",
"Ordered quantity": "Ordered quantity",
"Password": "Password",
"Preorder": "Preorder",
"Purchase order": "Purchase order",
"Purchase orders": "Purchase orders",
"Ready to create an app?": "Ready to create an app?",
Expand Down
7 changes: 7 additions & 0 deletions src/router/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createRouter, createWebHistory } from '@ionic/vue-router';
import { RouteRecordRaw } from 'vue-router';
import PurchaseOrder from '@/views/PurchaseOrder.vue'
import OrderDetail from '@/views/OrderDetail.vue'
import Login from '@/views/Login.vue'
import Settings from "@/views/Settings.vue"
import store from '@/store'
Expand Down Expand Up @@ -32,6 +33,12 @@ const routes: Array<RouteRecordRaw> = [
component: PurchaseOrder,
beforeEnter: authGuard
},
{
path: '/purchase-order-detail',
name: 'Purchase Order Detail',
component: OrderDetail,
beforeEnter: authGuard
},
{
path: '/login',
name: 'Login',
Expand Down
1 change: 1 addition & 0 deletions src/store/RootState.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default interface RootState {
user: any;
product: any;
order: any;
}
4 changes: 3 additions & 1 deletion src/store/actions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { ActionTree } from 'vuex'
import RootState from './RootState'

const actions: ActionTree<RootState, RootState> = {}
const actions: ActionTree<RootState, RootState> = {

}

export default actions
4 changes: 3 additions & 1 deletion src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import RootState from './RootState'
import createPersistedState from "vuex-persistedstate";
import userModule from './modules/user';
import productModule from "./modules/product";
import orderModule from "./modules/order";
import SecureLS from "secure-ls";

// We will be using secure-ls for secure localStorage data with high level of encryption and data compression.
Expand Down Expand Up @@ -60,7 +61,8 @@ const store = createStore<RootState>({
plugins: [ persistState ],
modules: {
'user': userModule,
'product': productModule
'product': productModule,
'order': orderModule
},
})

Expand Down
6 changes: 6 additions & 0 deletions src/store/modules/order/OrderState.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default interface OrderState {
list: {
items: any,
original: any
}
}
37 changes: 37 additions & 0 deletions src/store/modules/order/actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { ActionTree } from 'vuex'
import store from '@/store'
import RootState from '@/store/RootState'
import OrderState from './OrderState'
import * as types from './mutation-types'
import router from '@/router'


const actions: ActionTree<OrderState, RootState> = {
async orderListUpdated ({commit}, orderItems) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
async orderListUpdated ({commit}, orderItems) {
async updatedOrderList ({commit}, orderItems) {

const productIds = orderItems.map((item: any) => {
return item.shopifyProductSKU
})
const viewSize = productIds.length;
const viewIndex = 0;
const payload = {
viewSize,
viewIndex,
productIds
}
const resp = await store.dispatch("product/fetchProducts", payload);
orderItems = orderItems.map((item: any) => {
const product = resp.data.response.docs.find((product: any) => {
return item.shopifyProductSKU == product.internalName;
})
item.parentProductId = product.groupId;
item.internalName = product.internalName;
item.parentProductName = product.parentProductName;
item.imageUrl = product.mainImageUrl;
item.isNewProduct = false;
return item;
})
const original = JSON.parse(JSON.stringify(orderItems))
commit(types.ORDER_LIST_UPDATED, { orderItems: orderItems, original: original });
}
}
export default actions;
10 changes: 10 additions & 0 deletions src/store/modules/order/getters.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { GetterTree } from "vuex";
import OrderState from "./OrderState";
import RootState from "../../RootState";

const getters: GetterTree<OrderState, RootState> = {
getOrdersList(state){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
getOrdersList(state){
getOrder(state){

return state.list;
}
};
export default getters;
21 changes: 21 additions & 0 deletions src/store/modules/order/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import getters from './getters'
import { Module } from 'vuex'
import actions from './actions'
import mutations from './mutations'
import OrderState from './OrderState'
import RootState from '../../RootState'

const orderModule: Module<OrderState, RootState> = {
namespaced: true,
state: {
list: {
items: [],
original: []
},
},
actions,
getters,
mutations
}

export default orderModule;
3 changes: 3 additions & 0 deletions src/store/modules/order/mutation-types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const SN_ORDER = 'order'
export const ORDER_LIST_UPDATED = SN_ORDER + '/LIST_UPDATED'
export const ORDER_ITEMS_UPDATED = SN_ORDER + '/ITEMS_UPDATED'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not used anywhere. We could remove

15 changes: 15 additions & 0 deletions src/store/modules/order/mutations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { MutationTree } from 'vuex'
import OrderState from './OrderState'
import * as types from './mutation-types'

const mutations: MutationTree <OrderState> = {
[types.ORDER_LIST_UPDATED] (state, payload) {
state.list.items = payload.orderItems;
state.list.original = payload.original;
},
[types.ORDER_ITEMS_UPDATED] (state, payload) {
state.list.items = payload;
},

}
export default mutations;
1 change: 1 addition & 0 deletions src/store/modules/product/ProductState.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default interface ProductState {
cached: any;
products: {
list: any;
total: number;
Expand Down
28 changes: 28 additions & 0 deletions src/store/modules/product/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,34 @@ import emitter from '@/event-bus'

const actions: ActionTree<ProductState, RootState> = {

async fetchProducts ( { commit, state }, { productIds }) {
const cachedProductIds = Object.keys(state.cached);
const productIdFilter= productIds.reduce((filter: string, productId: any) => {
// If product already exist in cached products skip
if (cachedProductIds.includes(productId)) {
return filter;
} else {
// checking condition that if the filter is not empty then adding 'OR' to the filter
if (filter !== '') filter += ' OR '
return filter += productId;
}
}, '');

// If there are no products skip the API call
if (productIdFilter === '') return;

const resp = await ProductService.fetchProducts({
"filters": ['internalName: (' + productIdFilter + ')']
})
if (resp.status === 200 && !hasError(resp)) {
const products = resp.data.response.docs;
// Handled empty response in case of failed query
if (resp.data) commit(types.PRODUCT_ADD_TO_CACHED_MULTIPLE, { products });
}
// TODO Handle specific error
return resp;
},

// Find Product
async findProduct ({ commit, state }, payload) {

Expand Down
4 changes: 4 additions & 0 deletions src/store/modules/product/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import ProductState from "./ProductState";
import RootState from "../../RootState";

const getters: GetterTree<ProductState, RootState> = {
getProduct: (state) => (productId: string) => {
// Returning empty object so that it doesn't breaks the UI
return state.cached[productId] ? state.cached[productId] : {};
},
getSearchProducts(state) {
return state.products.list;
},
Expand Down
1 change: 1 addition & 0 deletions src/store/modules/product/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import RootState from '../../RootState'
const productModule: Module<ProductState, RootState> = {
namespaced: true,
state: {
cached: {},
products: {
list: {},
total: 0
Expand Down
1 change: 1 addition & 0 deletions src/store/modules/product/mutation-types.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export const SN_PRODUCT = 'product'
export const PRODUCT_SEARCH_UPDATED = SN_PRODUCT + '/SEARCH_UPDATED'
export const PRODUCT_ADD_TO_CACHED_MULTIPLE = SN_PRODUCT + '/ADD_TO_CACHED_MULTIPLE'
10 changes: 9 additions & 1 deletion src/store/modules/product/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ const mutations: MutationTree <ProductState> = {
[types.PRODUCT_SEARCH_UPDATED] (state, payload) {
state.products.list = payload.products;
state.products.total = payload.totalProductsCount;
}
},
[types.PRODUCT_ADD_TO_CACHED_MULTIPLE] (state, payload) {
// TODO
if (payload.products) {
payload.products.forEach((product: any) => {
state.cached[product.internalName] = product
});
}
},
}
export default mutations;
Loading