Skip to content

Commit da9a4cb

Browse files
committed
Refactor getAllAvailableStates and getCustomStates methods: streamline state retrieval and update return types to IdentityLifecycleState
1 parent 7024157 commit da9a4cb

File tree

1 file changed

+7
-22
lines changed

1 file changed

+7
-22
lines changed

src/management/lifecycle/lifecycle.service.ts

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { Identities } from '../identities/_schemas/identities.schema';
1414
import { IdentitiesCrudService } from '../identities/identities-crud.service';
1515
import { ConfigRulesObjectIdentitiesDTO, ConfigRulesObjectSchemaDTO } from './_dto/config-rules.dto';
1616
import { ConfigStatesDTO, LifecycleStateDTO } from './_dto/config-states.dto';
17-
import { IdentityLifecycleDefault, IdentityLifecycleDefaultList } from '../identities/_enums/lifecycle.enum';
17+
import { IdentityLifecycleDefault, IdentityLifecycleDefaultList, IdentityLifecycleState } from '../identities/_enums/lifecycle.enum';
1818
import { Lifecycle, LifecycleRefId } from './_schemas/lifecycle.schema';
1919
import { ConfigService } from '@nestjs/config';
2020
import dayjs from 'dayjs';
@@ -313,26 +313,11 @@ export class LifecycleService extends AbstractServiceSchema implements OnApplica
313313
*
314314
* @returns An array containing all available lifecycle states
315315
*/
316-
public getAllAvailableStates(): Array<{ key: string; label: string; description: string }> {
317-
const allStates: Array<{ key: string; label: string; description: string, icon: string }> = [];
318-
319-
IdentityLifecycleDefaultList.forEach(state => {
320-
allStates.push({
321-
key: state.key,
322-
label: state.label,
323-
description: state.description,
324-
icon: state.icon,
325-
});
326-
});
327-
328-
this.customStates.forEach(customState => {
329-
allStates.push({
330-
key: customState.key,
331-
label: customState.label,
332-
description: customState.description,
333-
icon: customState.icon || 'mdi-help-rhombus-outline',
334-
});
335-
});
316+
public getAllAvailableStates(): Array<IdentityLifecycleState> {
317+
const allStates: Array<IdentityLifecycleState> = [
318+
...IdentityLifecycleDefaultList,
319+
...this.customStates,
320+
];
336321

337322
return allStates;
338323
}
@@ -359,7 +344,7 @@ export class LifecycleService extends AbstractServiceSchema implements OnApplica
359344
*
360345
* @returns An array of custom lifecycle states with their details
361346
*/
362-
public getCustomStates(): LifecycleStateDTO[] {
347+
public getCustomStates(): IdentityLifecycleState[] {
363348
return [...this.customStates];
364349
}
365350

0 commit comments

Comments
 (0)