-
Notifications
You must be signed in to change notification settings - Fork 1
89 edit and delete customres #157
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
Conversation
0a5ff9a to
4e1bc8f
Compare
| import { CustomerState, CreateCustomer } from 'src/app/modules/customer-management/store'; | ||
| import * as models from 'src/app/modules/shared/models/index'; | ||
| import { LoadCustomers } from './../../../../store/customer-management.actions'; | ||
| import * as models from 'src/app/modules/shared/models/index'; |
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.
import should be
import { Customer } from 'src/app/modules/shared/models';
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.
done
| import { CustomerState, CreateCustomer, LoadCustomers } from 'src/app/modules/customer-management/store'; | ||
| import { getStatusMessage } from './../../../../store/customer-management.selectors'; | ||
| import { getStatusMessage, getCustomerById } from './../../../../store/customer-management.selectors'; | ||
| import { Customer } from 'src/app/modules/shared/models/index'; |
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.
import should be
import { Customer } from 'src/app/modules/shared/models';
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.
done
| if (this.customerToEdit) { | ||
| const customer = { | ||
| ...customerData, | ||
| id: this.customerToEdit[key], |
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 a better solution would be this.
const customer = { ...this.customerToEdit, ...customerData }; o const customer = { ...customerData, id: this.customerToEdit.id };
with this we would eliminate line 57
const key = 'id';
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.
done
| action: CustomerManagementActions | ||
| ): CustomerState { | ||
| const customersList = [...state.data]; | ||
| const key = 'id'; |
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.
Please, let's apply the previous comment here too
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.
done
| customerIdToEdit: '', | ||
| }; | ||
|
|
||
| export function customerManagementReducer( |
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 must use arrow functions
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.
done
| export const getCustomerById = createSelector(allCustomers, customerIdtoEdit, (customers, customerId) => { | ||
| const key = 'id'; | ||
| return customers.find((customer) => { | ||
| return customer[key] === customerId; |
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 you should add an "id" in the Customer interface to avoid this.
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.
done
src/app/modules/customer-management/store/customer-management.actions.ts
Show resolved
Hide resolved
src/app/modules/customer-management/store/customer-management.reducers.ts
Show resolved
Hide resolved
| const url = `${this.baseUrl}/${customerData.id}`; | ||
| const body = { | ||
| ...customerData, | ||
| }; |
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.
body object it's not necessary, please remove it and send directly customerData.
Please remove it also remove in createCustomer method, and remove the tenantId.
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.
done
| }); | ||
|
|
||
| export const getCustomerById = createSelector(allCustomers, customerIdtoEdit, (customers, customerId) => { | ||
| return customers.find((customer) => { |
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.
could add the validation for (customers, customerId)
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.
done.
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.
All changes were applied. @enriquezrene when you have a free time, please, check it.
Issue realted to #89.