2026-03-07 11:25:11 +03:30
|
|
|
import translates from '@/common/constants/translates/translates'
|
|
|
|
|
import {
|
|
|
|
|
AccountRole,
|
|
|
|
|
AccountStatus,
|
|
|
|
|
BusinessRole,
|
2026-04-11 14:47:05 +03:30
|
|
|
ConsumerRole,
|
2026-03-07 11:25:11 +03:30
|
|
|
GoodPricingModel,
|
|
|
|
|
LicenseStatus,
|
|
|
|
|
LicenseType,
|
|
|
|
|
PartnerRole,
|
|
|
|
|
POSRole,
|
|
|
|
|
POSStatus,
|
|
|
|
|
POSType,
|
|
|
|
|
ProviderRole,
|
|
|
|
|
UnitType,
|
|
|
|
|
UserStatus,
|
|
|
|
|
UserType,
|
|
|
|
|
} from '@/generated/prisma/enums'
|
2026-02-16 20:51:34 +03:30
|
|
|
import { Injectable } from '@nestjs/common'
|
2026-03-07 11:25:11 +03:30
|
|
|
import { AccountType, GoldKarat, TokenType } from 'common/enums/enums'
|
|
|
|
|
import { ResponseMapper } from 'common/response/response-mapper'
|
2026-02-16 20:51:34 +03:30
|
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
|
export class EnumsService {
|
2026-03-07 11:25:11 +03:30
|
|
|
private prepareData(items: Record<string, string>) {
|
|
|
|
|
return Object.values(items).map(item => ({
|
|
|
|
|
name: translates.enums[item] || item,
|
|
|
|
|
value: item,
|
|
|
|
|
}))
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-16 20:51:34 +03:30
|
|
|
getAllEnums() {
|
|
|
|
|
return {
|
2026-03-07 11:25:11 +03:30
|
|
|
GoldKarat: this.prepareData(GoldKarat),
|
|
|
|
|
UserStatus: this.prepareData(UserStatus),
|
|
|
|
|
AccountRole: this.prepareData(AccountRole),
|
|
|
|
|
AccountStatus: this.prepareData(AccountStatus),
|
|
|
|
|
POSStatus: this.prepareData(POSStatus),
|
|
|
|
|
POSRole: this.prepareData(POSRole),
|
|
|
|
|
LicenseType: this.prepareData(LicenseType),
|
|
|
|
|
LicenseStatus: this.prepareData(LicenseStatus),
|
|
|
|
|
POSType: this.prepareData(POSType),
|
|
|
|
|
UserType: this.prepareData(UserType),
|
|
|
|
|
AccountType: this.prepareData(AccountType),
|
|
|
|
|
PartnerRole: this.prepareData(PartnerRole),
|
|
|
|
|
BusinessRole: this.prepareData(BusinessRole),
|
|
|
|
|
ProviderRole: this.prepareData(ProviderRole),
|
|
|
|
|
TokenType: this.prepareData(TokenType),
|
|
|
|
|
UnitType: this.prepareData(UnitType),
|
|
|
|
|
GoodPricingModel: this.prepareData(GoodPricingModel),
|
2026-04-11 14:47:05 +03:30
|
|
|
ConsumerRole: this.prepareData(ConsumerRole),
|
2026-02-16 20:51:34 +03:30
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getEnumValues(enumName: string) {
|
|
|
|
|
const enums = this.getAllEnums()
|
|
|
|
|
return ResponseMapper.list(enums[enumName] || [])
|
|
|
|
|
}
|
|
|
|
|
}
|