fix ui issues and upload image for guild good
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import { Maybe } from '@/core';
|
||||
import { apiEnumTranslates } from '@/shared/apiEnum/constants';
|
||||
|
||||
const translates = {
|
||||
COUNT: 'تعداد',
|
||||
GRAM: 'گرم',
|
||||
KILOGRAM: 'کیلوگرم',
|
||||
METER: 'متر',
|
||||
MILLILITER: 'میلیلیتر',
|
||||
LITER: 'لیتر',
|
||||
HOUR: 'ساعت',
|
||||
};
|
||||
|
||||
export function enumTranslator(key: Maybe<string>): string {
|
||||
if (!key) {
|
||||
return '';
|
||||
}
|
||||
// @ts-ignore
|
||||
return apiEnumTranslates[key] || translates[key] || key;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
export function buildFormData(
|
||||
formGroup: any,
|
||||
fileProperties: { [key: string]: File | null } = {},
|
||||
): FormData {
|
||||
const formData = new FormData();
|
||||
|
||||
console.log(formGroup);
|
||||
console.log(formGroup.controls);
|
||||
|
||||
Object.keys(formGroup.controls).forEach((key) => {
|
||||
const control = formGroup.get(key);
|
||||
if (control && control.value !== null && control.value !== undefined) {
|
||||
formData.append(key, control.value);
|
||||
}
|
||||
});
|
||||
|
||||
Object.keys(fileProperties).forEach((key) => {
|
||||
const file = fileProperties[key];
|
||||
if (file) {
|
||||
formData.append(key, file, file.name);
|
||||
}
|
||||
});
|
||||
|
||||
return formData;
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
export * from './currency';
|
||||
export * from './date-formatter.utils';
|
||||
export * from './enum-translator.utils';
|
||||
export * from './form-data.util';
|
||||
export * from './good-unit-types.utils';
|
||||
export * from './license-status.utils';
|
||||
export * from './name';
|
||||
export * from './page-params.utils';
|
||||
export * from './price-mask.utils';
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Maybe } from '@/core';
|
||||
import { licenseStatus } from '@/shared/localEnum/constants/licenseStatus';
|
||||
|
||||
export function getLicenseStatus(licenseExpiresAt?: Maybe<string>) {
|
||||
if (!licenseExpiresAt) {
|
||||
return null;
|
||||
}
|
||||
if (new Date().getTime() > new Date(licenseExpiresAt || '').getTime()) {
|
||||
return licenseStatus.EXPIRED;
|
||||
}
|
||||
return licenseStatus.ACTIVE;
|
||||
}
|
||||
Reference in New Issue
Block a user