update pos consumer
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
export const CustomerType = {
|
||||
INDIVIDUAL: 'INDIVIDUAL',
|
||||
LEGAL: 'LEGAL',
|
||||
UNKNOWN: 'UNKNOWN',
|
||||
} as const;
|
||||
|
||||
export type CustomerType = (typeof CustomerType)[keyof typeof CustomerType];
|
||||
@@ -0,0 +1,21 @@
|
||||
import { ISelectItem } from '@/shared/abstractClasses';
|
||||
|
||||
export const goldKarat = {
|
||||
KARAT_18: 'KARAT_18',
|
||||
KARAT_21: 'KARAT_21',
|
||||
KARAT_24: 'KARAT_24',
|
||||
} as const;
|
||||
export type TGoldKarat = (typeof goldKarat)[keyof typeof goldKarat];
|
||||
|
||||
const translates: Record<string, string> = {
|
||||
KARAT_18: '18',
|
||||
KARAT_21: '21',
|
||||
KARAT_24: '24',
|
||||
};
|
||||
|
||||
export const goldKaratSelect: ISelectItem[] = Object.keys(goldKarat).map((key) => ({
|
||||
id: key,
|
||||
name: translates[key],
|
||||
}));
|
||||
|
||||
export const goldKaratLabel = 'عیار';
|
||||
@@ -0,0 +1,8 @@
|
||||
import { goldKaratLabel, goldKaratSelect } from './goldKarat';
|
||||
|
||||
export const LOCAL_ENUMS = {
|
||||
gold: {
|
||||
label: goldKaratLabel,
|
||||
items: goldKaratSelect,
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './io';
|
||||
export * from './types';
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
export interface IEnumResponse {
|
||||
name: string;
|
||||
value: string;
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import { LOCAL_ENUMS } from '../constants';
|
||||
|
||||
export type TLocalEnum = keyof typeof LOCAL_ENUMS;
|
||||
@@ -0,0 +1,12 @@
|
||||
<uikit-field [label]="label()" [control]="control" [showLabel]="showLabel" [showErrors]="showErrors">
|
||||
<p-select
|
||||
[loading]="loading()"
|
||||
[options]="items()"
|
||||
optionLabel="name"
|
||||
optionValue="value"
|
||||
[formControl]="control"
|
||||
[showClear]="showClear"
|
||||
[filter]="true"
|
||||
appendTo="body"
|
||||
/>
|
||||
</uikit-field>
|
||||
@@ -0,0 +1,30 @@
|
||||
import { UikitFieldComponent } from '@/uikit';
|
||||
import { Component, computed, Input } from '@angular/core';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { Select } from 'primeng/select';
|
||||
import { Observable } from 'rxjs';
|
||||
import { AbstractSelectComponent, ISelectItem } from '../abstractClasses';
|
||||
import { LOCAL_ENUMS } from './constants';
|
||||
import { TLocalEnum } from './models';
|
||||
|
||||
@Component({
|
||||
selector: 'app-enum-select',
|
||||
templateUrl: './select.component.html',
|
||||
imports: [UikitFieldComponent, Select, ReactiveFormsModule],
|
||||
})
|
||||
export class EnumSelectComponent extends AbstractSelectComponent<ISelectItem, ISelectItem[]> {
|
||||
@Input() type!: TLocalEnum;
|
||||
@Input() customLabel?: string;
|
||||
|
||||
label = computed(() => this.customLabel ?? LOCAL_ENUMS[this.type].label);
|
||||
|
||||
override getDataService() {
|
||||
return new Observable<ISelectItem[]>((observer) => {
|
||||
return observer.next(LOCAL_ENUMS[this.type].items);
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.getData();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user