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

Conversation

disha1202
Copy link
Contributor

No description provided.

@disha1202 disha1202 changed the title Implemented: logic to edit data #22c8vgh [WIP] Implemented: logic to edit data #22c8vgh Mar 1, 2022
@disha1202 disha1202 changed the title [WIP] Implemented: logic to edit data #22c8vgh Implemented: logic to edit data #22c8vgh Mar 2, 2022
@@ -0,0 +1,7 @@
export default interface OrderState {
order: {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the order state

modifyCsv ({ commit }, payload) {
commit(types.MODIFY_CSV, payload);
},
async groupProducts ({commit}, csv: any) {
Copy link
Contributor

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

Copy link
Contributor Author

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?

updateOrderList ({ commit }, payload) {
commit(types.ORDER_LIST_UPDATED, payload );
},
modifyCsv ({ commit }, payload) {
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the code.

const productIds = csv.map((item: any) => {
return item.shopifyproductSKU
})
const viewSize = process.env.VUE_APP_VIEW_SIZE;
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 value should be productIds length

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made the requested change.

if(item.shopifyproductSKU == product.internalName)
return product;
})
console.log(product);
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

return product;
})
console.log(product);
item.groupId = product.groupId;
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
item.groupId = product.groupId;
item.parentProductId = product.groupId;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made the requested change

item.isNewProduct = false;
return item;
})
await store.dispatch('order/updateOrderList', csv);
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Improved variable name

const mutations: MutationTree <OrderState> = {
[types.ORDER_LIST_UPDATED] (state, payload) {
state.order.originalCsv = payload;
console.log(payload);
Copy link
Contributor

Choose a reason for hiding this comment

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

console log missed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed

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);
Copy link
Contributor

Choose a reason for hiding this comment

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

Missed console log

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

mapFields() {
// console.log(this.csvParsed);

this.csvParsed = this.content.map(item => {
Copy link
Contributor

Choose a reason for hiding this comment

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

order item list

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

return item;
})
await store.dispatch('order/orderListOriginal', orderItems);
router.push({
Copy link
Contributor

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

Copy link
Contributor Author

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.



const actions: ActionTree<OrderState, RootState> = {
orderListOriginal ({ commit }, payload) {
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 needed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes Sir, removed.

const productModule: Module<OrderState, RootState> = {
namespaced: true,
state: {
order: {
Copy link
Contributor

Choose a reason for hiding this comment

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

      list: {
        items: [],
        original: []
      }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated order state

data() {
return {
numberOfDays: 0,
numberOfpieces: 0,
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
numberOfpieces: 0,
numberOfPieces: 0,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made the requested change.

numberOfpieces: 0,
catalog: "",
listOfCheckedProducts: [] as any,
originalCsv: {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Improve variable name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Improved.

const orderItem = {
orderId: [],
shopifyproductSKU: [],
shopifyproductUPC: [],
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
shopifyproductUPC: [],
shopifyProductUPC: [],

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made the requested change.

orderListOriginal ({ commit }, payload) {
commit(types.ORDER_LIST_ORIGINAL, payload );
},
async groupProducts ({commit}, orderItems: any) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Improve method name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Improved method name.

orderItems = orderItems.map((item: any) => {
const product = resp.data.response.docs.find((product: any) => {
if(item.shopifyproductSKU == product.internalName)
return product;
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 if is not needed

Suggested change
return product;
return item.shopifyproductSKU == product.internalName;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made the requested change.

<div class="filters">
<ion-item>
<ion-label>{{ $t("Buffer days") }}</ion-label>
<ion-input v-model="numberOfDays" type="text" placeholder="all items" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Placeholder should be internationalised

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Internationalised placeholder text.

<div v-for="item in getGroupItems(id, orderItems)" :key="item">
<div class="list-header" >
<ion-label>{{ item.parentProductName }}</ion-label>
<ion-chip >
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Used self closing

for empty space.



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) {

@@ -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

apply() {
this.ordersList.items.map((item: any) => {
if (this.listOfCheckedProducts.includes(item.shopifyProductSKU)) {
item.quantityOrdered -= this.numberOfPieces;
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 here we should only updates values changed

getGroupItems(parentProductId: any, items: any) {
return items.filter((item: any) => item.parentProductId == parentProductId)
},
checkAllProducts() {
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
checkAllProducts() {
selectAllItems() {

this.checkProducts(item.shopifyProductSKU);
})
},
checkGroupedProducts(parentProductId: any){
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
checkGroupedProducts(parentProductId: any){
selectParentProduct(parentProductId: any){

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){

<ion-content :fullscreen="true">
<div class="header">
<div class="search">
<ion-searchbar> </ion-searchbar>
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
<ion-searchbar> </ion-searchbar>
<ion-searchbar />

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
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
if (this.catalog == "Preorder") item.isNewProduct = true
item.isNewProduct = this.catalog == "Preorder"

},
checkAllProducts() {
this.ordersList.items.forEach((item: any) => {
this.checkProducts(item.shopifyProductSKU);
Copy link
Contributor

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

return item;
})
const original = JSON.parse(JSON.stringify(items))
commit(types.ORDER_LIST_UPDATED, { items: items, original: original });
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
commit(types.ORDER_LIST_UPDATED, { items: items, original: original });
commit(types.ORDER_LIST_UPDATED, { items, original });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants