-
Notifications
You must be signed in to change notification settings - Fork 37
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
Improved: seperated partyname from util module by creating party module(#121) #401
Open
shanmukhdutt
wants to merge
4
commits into
hotwax:main
Choose a base branch
from
shanmukhdutt:fulfillment/#121
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { api } from '@/adapter'; | ||
|
||
const fetchPartyInformation = async (query: any): Promise <any> => { | ||
return api({ | ||
url: "performFind", | ||
method: "get", | ||
params: query | ||
}); | ||
} | ||
|
||
export const partyService = { | ||
fetchPartyInformation | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,5 @@ export default interface RootState { | |
user: any; | ||
product: any; | ||
util: UtilState; | ||
order: OrderState; | ||
order: OrderState | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove any unwanted change in the state |
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { partyService } from "@/services/PartyService" | ||
import { ActionTree } from "vuex" | ||
import partyState from "./partyState" | ||
import RootState from "@/store/RootState" | ||
import * as types from './mutation-type' | ||
import { hasError } from '@/adapter' | ||
import logger from "@/logger" | ||
|
||
const actions: ActionTree<partyState, RootState> = { | ||
async fetchPartyInformation({ commit, state }, partyIds) { | ||
let partyInformation = JSON.parse(JSON.stringify(state.partyNames)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Improve indentation in all the places. |
||
const cachedPartyIds = Object.keys(partyInformation); | ||
const ids = partyIds.filter((partyId: string) => !cachedPartyIds.includes(partyId)) | ||
|
||
if(!ids.length) return partyInformation; | ||
|
||
try { | ||
const payload = { | ||
"inputFields": { | ||
"partyId": ids, | ||
"partyId_op": "in" | ||
}, | ||
"fieldList": ["firstName", "middleName", "lastName", "groupName", "partyId"], | ||
"entityName": "PartyNameView", | ||
"viewSize": ids.length | ||
} | ||
|
||
const resp = await partyService.fetchPartyInformation(payload); | ||
|
||
if(!hasError(resp)) { | ||
const partyResp = {} as any | ||
resp.data.docs.map((partyInformation: any) => { | ||
|
||
let partyName = '' | ||
if(partyInformation.groupName) { | ||
partyName = partyInformation.groupName | ||
} else { | ||
partyName = [partyInformation.firstName, partyInformation.lastName].join(' ') | ||
} | ||
|
||
partyResp[partyInformation.partyId] = partyName | ||
}) | ||
|
||
partyInformation = { | ||
...partyInformation, | ||
...partyResp | ||
} | ||
|
||
commit(types.PARTY_PARTY_NAMES_UPDATED, partyInformation) | ||
} else { | ||
throw resp.data | ||
} | ||
} catch(err) { | ||
logger.error('Error fetching party information', err) | ||
} | ||
|
||
return partyInformation; | ||
}, | ||
} | ||
export default actions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { GetterTree } from 'vuex' | ||
import partyState from './partyState' | ||
import RootState from '@/store/RootState'; | ||
|
||
const getters: GetterTree <partyState, RootState> ={ | ||
getPartyName: (state) => (partyId: string) => { | ||
return state.partyNames[partyId] ? state.partyNames[partyId] : '' | ||
}, | ||
} | ||
export default getters; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import actions from './actions' | ||
import getters from './getters' | ||
import mutations from './mutations' | ||
import { Module } from 'vuex' | ||
import RootState from '@/store/RootState' | ||
import partyState from './partyState' | ||
|
||
const partyModule: Module<partyState, RootState> = { | ||
namespaced: true, | ||
state: { | ||
partyNames: {}, | ||
}, | ||
getters, | ||
actions, | ||
mutations | ||
} | ||
export default partyModule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const SN_PARTY = 'party' | ||
export const PARTY_PARTY_NAMES_UPDATED = SN_PARTY + '/PARTY_NAMES_UPDATED' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { MutationTree } from 'vuex' | ||
import * as types from './mutation-type' | ||
import partyState from './partyState' | ||
|
||
const mutations: MutationTree <partyState> = { | ||
[types.PARTY_PARTY_NAMES_UPDATED] (state, payload) { | ||
state.partyNames = payload | ||
}, | ||
} | ||
export default mutations; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default interface partyState { | ||
partyNames: any; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 indentation.