-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: revert organization management store movement (#96422)
- Loading branch information
1 parent
fd539ad
commit 150a252
Showing
79 changed files
with
529 additions
and
170 deletions.
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
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
3 changes: 2 additions & 1 deletion
3
projects/organization-management/src/app/components/user-budget/user-budget.component.ts
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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions
6
projects/organization-management/src/app/models/b2b-user/b2b-user.interface.ts
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,6 @@ | ||
import { Link } from 'ish-core/models/link/link.model'; | ||
import { UserData } from 'ish-core/models/user/user.interface'; | ||
|
||
export type B2bUserData = UserData & { active: boolean }; | ||
|
||
export type B2bUserDataLink = Link & { login: string }; |
104 changes: 104 additions & 0 deletions
104
projects/organization-management/src/app/models/b2b-user/b2b-user.mapper.spec.ts
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,104 @@ | ||
import { Address } from 'ish-core/models/address/address.model'; | ||
import { PaymentInstrument } from 'ish-core/models/payment-instrument/payment-instrument.model'; | ||
import { BasketMockData } from 'ish-core/utils/dev/basket-mock-data'; | ||
|
||
import { B2bUserData, B2bUserDataLink } from './b2b-user.interface'; | ||
import { B2bUserMapper } from './b2b-user.mapper'; | ||
|
||
describe('B2b User Mapper', () => { | ||
describe('fromData', () => { | ||
it(`should return User when getting UserData`, () => { | ||
const userData = { | ||
firstName: 'Patricia', | ||
lastName: 'Miller', | ||
preferredInvoiceToAddress: BasketMockData.getAddress(), | ||
preferredShipToAddress: { urn: 'urn:1234' } as Address, | ||
preferredPaymentInstrument: { id: '1234' } as PaymentInstrument, | ||
preferredLanguage: 'en_US', | ||
active: true, | ||
} as B2bUserData; | ||
const user = B2bUserMapper.fromData(userData); | ||
|
||
expect(user).toMatchInlineSnapshot(` | ||
{ | ||
"active": true, | ||
"birthday": undefined, | ||
"businessPartnerNo": undefined, | ||
"department": undefined, | ||
"email": undefined, | ||
"fax": undefined, | ||
"firstName": "Patricia", | ||
"lastName": "Miller", | ||
"login": undefined, | ||
"phoneBusiness": undefined, | ||
"phoneHome": undefined, | ||
"phoneMobile": undefined, | ||
"preferredInvoiceToAddressUrn": "urn:address:customer:JgEKAE8BA50AAAFgDtAd1LZU:ilMKAE8BlIUAAAFgEdAd1LZU", | ||
"preferredLanguage": "en_US", | ||
"preferredPaymentInstrumentId": "1234", | ||
"preferredShipToAddressUrn": "urn:1234", | ||
"title": undefined, | ||
} | ||
`); | ||
}); | ||
}); | ||
|
||
describe('fromListData', () => { | ||
it(`should return User when getting UserListData`, () => { | ||
const userListData = [ | ||
{ | ||
login: 'pmiller@test.intershop.de', | ||
attributes: [ | ||
{ | ||
name: 'roleIDs', | ||
value: ['APP_B2B_COSTCENTER_OWNER', 'APP_B2B_BUYER'], | ||
}, | ||
{ name: 'firstName', value: 'Patricia' }, | ||
{ name: 'lastName', value: 'Miller' }, | ||
{ name: 'active', value: true }, | ||
{ name: 'budgetPeriod', type: 'String', value: 'monthly' }, | ||
{ name: 'orderSpentLimit', type: 'MoneyRO', value: { currency: 'USD', value: 500 } }, | ||
{ name: 'budget', type: 'MoneyRO', value: { currency: 'USD', value: 10000 } }, | ||
{ name: 'remainingBudget', type: 'MoneyRO', value: { currency: 'USD', value: 8000 } }, | ||
{ name: 'spentBudget', type: 'MoneyRO', value: { currency: 'USD', value: 2000 } }, | ||
], | ||
} as B2bUserDataLink, | ||
]; | ||
const users = B2bUserMapper.fromListData(userListData); | ||
|
||
expect(users).toMatchInlineSnapshot(` | ||
[ | ||
{ | ||
"active": true, | ||
"firstName": "Patricia", | ||
"lastName": "Miller", | ||
"login": "pmiller@test.intershop.de", | ||
"roleIDs": [ | ||
"APP_B2B_COSTCENTER_OWNER", | ||
"APP_B2B_BUYER", | ||
], | ||
"userBudget": { | ||
"budget": { | ||
"currency": "USD", | ||
"value": 10000, | ||
}, | ||
"budgetPeriod": "monthly", | ||
"orderSpentLimit": { | ||
"currency": "USD", | ||
"value": 500, | ||
}, | ||
"remainingBudget": { | ||
"currency": "USD", | ||
"value": 8000, | ||
}, | ||
"spentBudget": { | ||
"currency": "USD", | ||
"value": 2000, | ||
}, | ||
}, | ||
}, | ||
] | ||
`); | ||
}); | ||
}); | ||
}); |
35 changes: 35 additions & 0 deletions
35
projects/organization-management/src/app/models/b2b-user/b2b-user.mapper.ts
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,35 @@ | ||
import { AttributeHelper } from 'ish-core/models/attribute/attribute.helper'; | ||
import { UserMapper } from 'ish-core/models/user/user.mapper'; | ||
|
||
import { B2bUserData, B2bUserDataLink } from './b2b-user.interface'; | ||
import { B2bUser } from './b2b-user.model'; | ||
|
||
export class B2bUserMapper { | ||
static fromData(user: B2bUserData): B2bUser { | ||
return { ...UserMapper.fromData(user), active: user.active }; | ||
} | ||
|
||
static fromListData(data: B2bUserDataLink[]): B2bUser[] { | ||
if (data) { | ||
return data.map(e => ({ | ||
login: e.login, | ||
firstName: AttributeHelper.getAttributeValueByAttributeName(e.attributes, 'firstName'), | ||
lastName: AttributeHelper.getAttributeValueByAttributeName(e.attributes, 'lastName'), | ||
roleIDs: AttributeHelper.getAttributeValueByAttributeName(e.attributes, 'roleIDs'), | ||
active: AttributeHelper.getAttributeValueByAttributeName(e.attributes, 'active'), | ||
userBudget: { | ||
orderSpentLimit: AttributeHelper.getAttributeValueByAttributeName(e.attributes, 'orderSpentLimit'), | ||
budget: AttributeHelper.getAttributeValueByAttributeName(e.attributes, 'budget'), | ||
remainingBudget: AttributeHelper.getAttributeValueByAttributeName(e.attributes, 'remainingBudget'), | ||
budgetPeriod: AttributeHelper.getAttributeValueByAttributeName(e.attributes, 'budgetPeriod'), | ||
spentBudget: AttributeHelper.getAttributeValueByAttributeName(e.attributes, 'spentBudget') || { | ||
...AttributeHelper.getAttributeValueByAttributeName(e.attributes, 'budget'), | ||
value: 0, | ||
}, | ||
}, | ||
})); | ||
} else { | ||
throw new Error('data is required'); | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
projects/organization-management/src/app/models/b2b-user/b2b-user.model.ts
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,9 @@ | ||
import { User } from 'ish-core/models/user/user.model'; | ||
|
||
import { UserBudget } from '../user-budget/user-budget.model'; | ||
|
||
export interface B2bUser extends Partial<User> { | ||
roleIDs?: string[]; | ||
active?: boolean; | ||
userBudget?: UserBudget; | ||
} |
File renamed without changes.
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
2 changes: 1 addition & 1 deletion
2
...n-management/src/app/pages/user-detail/user-detail-budget/user-detail-budget.component.ts
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
4 changes: 2 additions & 2 deletions
4
projects/organization-management/src/app/pages/user-detail/user-detail-page.component.ts
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.