-
Notifications
You must be signed in to change notification settings - Fork 27
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
Conversation
…to map parsed Csv and implemented order state(#22c8vf8)
@@ -0,0 +1,7 @@ | |||
export default interface OrderState { | |||
order: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the order state
src/store/modules/order/actions.ts
Outdated
modifyCsv ({ commit }, payload) { | ||
commit(types.MODIFY_CSV, payload); | ||
}, | ||
async groupProducts ({commit}, csv: any) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I this should a getter instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this action we are fetching product information and storing in order state.
Can we still add it in getters?
src/store/modules/order/actions.ts
Outdated
updateOrderList ({ commit }, payload) { | ||
commit(types.ORDER_LIST_UPDATED, payload ); | ||
}, | ||
modifyCsv ({ commit }, payload) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will be performing updates on order item list only. The state will not update any CSV, but order list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the code.
src/store/modules/order/actions.ts
Outdated
const productIds = csv.map((item: any) => { | ||
return item.shopifyproductSKU | ||
}) | ||
const viewSize = process.env.VUE_APP_VIEW_SIZE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think value should be productIds length
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made the requested change.
src/store/modules/order/actions.ts
Outdated
if(item.shopifyproductSKU == product.internalName) | ||
return product; | ||
}) | ||
console.log(product); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems we missed a console log
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
src/store/modules/order/actions.ts
Outdated
return product; | ||
}) | ||
console.log(product); | ||
item.groupId = product.groupId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
item.groupId = product.groupId; | |
item.parentProductId = product.groupId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made the requested change
src/store/modules/order/actions.ts
Outdated
item.isNewProduct = false; | ||
return item; | ||
}) | ||
await store.dispatch('order/updateOrderList', csv); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve variable name: csv
We will only deal with order list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improved variable name
src/store/modules/order/mutations.ts
Outdated
const mutations: MutationTree <OrderState> = { | ||
[types.ORDER_LIST_UPDATED] (state, payload) { | ||
state.order.originalCsv = payload; | ||
console.log(payload); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console log missed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
src/views/PurchaseOrder.vue
Outdated
this.file = event.target.files[0]; | ||
this.parseFile(); | ||
}, | ||
async parseFile(){ | ||
await parseCsv(this.file).then(res => { | ||
this.content = res; | ||
console.log(res); | ||
// console.log(res); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed console log
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
src/views/PurchaseOrder.vue
Outdated
mapFields() { | ||
// console.log(this.csvParsed); | ||
|
||
this.csvParsed = this.content.map(item => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
order item list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
src/store/modules/order/actions.ts
Outdated
return item; | ||
}) | ||
await store.dispatch('order/orderListOriginal', orderItems); | ||
router.push({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this to specific component
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to the specific component.
src/store/modules/order/actions.ts
Outdated
|
||
|
||
const actions: ActionTree<OrderState, RootState> = { | ||
orderListOriginal ({ commit }, payload) { |
There was a problem hiding this comment.
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 needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes Sir, removed.
src/store/modules/order/index.ts
Outdated
const productModule: Module<OrderState, RootState> = { | ||
namespaced: true, | ||
state: { | ||
order: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
list: {
items: [],
original: []
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated order state
src/views/OrderDetail.vue
Outdated
data() { | ||
return { | ||
numberOfDays: 0, | ||
numberOfpieces: 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
numberOfpieces: 0, | |
numberOfPieces: 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made the requested change.
src/views/OrderDetail.vue
Outdated
numberOfpieces: 0, | ||
catalog: "", | ||
listOfCheckedProducts: [] as any, | ||
originalCsv: {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve variable name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improved.
src/views/PurchaseOrder.vue
Outdated
const orderItem = { | ||
orderId: [], | ||
shopifyproductSKU: [], | ||
shopifyproductUPC: [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shopifyproductUPC: [], | |
shopifyProductUPC: [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made the requested change.
src/store/modules/order/actions.ts
Outdated
orderListOriginal ({ commit }, payload) { | ||
commit(types.ORDER_LIST_ORIGINAL, payload ); | ||
}, | ||
async groupProducts ({commit}, orderItems: any) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve method name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improved method name.
src/store/modules/order/actions.ts
Outdated
orderItems = orderItems.map((item: any) => { | ||
const product = resp.data.response.docs.find((product: any) => { | ||
if(item.shopifyproductSKU == product.internalName) | ||
return product; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if is not needed
return product; | |
return item.shopifyproductSKU == product.internalName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made the requested change.
src/views/OrderDetail.vue
Outdated
<div class="filters"> | ||
<ion-item> | ||
<ion-label>{{ $t("Buffer days") }}</ion-label> | ||
<ion-input v-model="numberOfDays" type="text" placeholder="all items" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Placeholder should be internationalised
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Internationalised placeholder text.
src/views/OrderDetail.vue
Outdated
<div v-for="item in getGroupItems(id, orderItems)" :key="item"> | ||
<div class="list-header" > | ||
<ion-label>{{ item.parentProductName }}</ion-label> | ||
<ion-chip > |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use self closing <div />
for empty space
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used self closing
src/store/modules/order/actions.ts
Outdated
|
||
|
||
const actions: ActionTree<OrderState, RootState> = { | ||
async orderListUpdated ({commit}, orderItems) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async orderListUpdated ({commit}, orderItems) { | |
async updatedOrderList ({commit}, orderItems) { |
@@ -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' |
There was a problem hiding this comment.
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
src/views/OrderDetail.vue
Outdated
apply() { | ||
this.ordersList.items.map((item: any) => { | ||
if (this.listOfCheckedProducts.includes(item.shopifyProductSKU)) { | ||
item.quantityOrdered -= this.numberOfPieces; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think here we should only updates values changed
src/views/OrderDetail.vue
Outdated
getGroupItems(parentProductId: any, items: any) { | ||
return items.filter((item: any) => item.parentProductId == parentProductId) | ||
}, | ||
checkAllProducts() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checkAllProducts() { | |
selectAllItems() { |
src/views/OrderDetail.vue
Outdated
this.checkProducts(item.shopifyProductSKU); | ||
}) | ||
}, | ||
checkGroupedProducts(parentProductId: any){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checkGroupedProducts(parentProductId: any){ | |
selectParentProduct(parentProductId: any){ |
src/store/modules/order/getters.ts
Outdated
import RootState from "../../RootState"; | ||
|
||
const getters: GetterTree<OrderState, RootState> = { | ||
getOrdersList(state){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getOrdersList(state){ | |
getOrder(state){ |
src/views/OrderDetail.vue
Outdated
<ion-content :fullscreen="true"> | ||
<div class="header"> | ||
<div class="search"> | ||
<ion-searchbar> </ion-searchbar> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<ion-searchbar> </ion-searchbar> | |
<ion-searchbar /> |
src/views/OrderDetail.vue
Outdated
if (this.listOfCheckedProducts.includes(item.shopifyProductSKU)) { | ||
item.quantityOrdered -= this.numberOfPieces; | ||
item.arrivalDate = DateTime.fromFormat(item.arrivalDate, "D").plus({ days: this.numberOfDays }).toFormat('MM/dd/yyyy'); | ||
if (this.catalog == "Preorder") item.isNewProduct = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (this.catalog == "Preorder") item.isNewProduct = true | |
item.isNewProduct = this.catalog == "Preorder" |
src/views/OrderDetail.vue
Outdated
}, | ||
checkAllProducts() { | ||
this.ordersList.items.forEach((item: any) => { | ||
this.checkProducts(item.shopifyProductSKU); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If one of them is already selected this will unselect it, but it should select all
src/store/modules/order/actions.ts
Outdated
return item; | ||
}) | ||
const original = JSON.parse(JSON.stringify(items)) | ||
commit(types.ORDER_LIST_UPDATED, { items: items, original: original }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commit(types.ORDER_LIST_UPDATED, { items: items, original: original }); | |
commit(types.ORDER_LIST_UPDATED, { items, original }); |
No description provided.