Refactor components and modals
This commit is contained in:
@@ -1,353 +0,0 @@
|
||||
// frontend/src/utils/enumHelpers.ts
|
||||
/**
|
||||
* Utilities for working with enums and translations
|
||||
*/
|
||||
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import type { SelectOption } from '../components/ui/Select';
|
||||
import {
|
||||
SupplierType,
|
||||
SupplierStatus,
|
||||
PaymentTerms,
|
||||
PurchaseOrderStatus,
|
||||
DeliveryStatus,
|
||||
QualityRating,
|
||||
DeliveryRating,
|
||||
InvoiceStatus
|
||||
} from '../api/types/suppliers';
|
||||
|
||||
import {
|
||||
CustomerType,
|
||||
DeliveryMethod,
|
||||
PaymentTerms as OrderPaymentTerms,
|
||||
PaymentMethod,
|
||||
PaymentStatus,
|
||||
CustomerSegment,
|
||||
PriorityLevel,
|
||||
OrderType,
|
||||
OrderStatus,
|
||||
OrderSource,
|
||||
SalesChannel
|
||||
} from '../api/types/orders';
|
||||
|
||||
import {
|
||||
ProductionStatusEnum,
|
||||
ProductionPriorityEnum,
|
||||
ProductionBatchStatus,
|
||||
QualityCheckStatus
|
||||
} from '../api/types/production';
|
||||
|
||||
/**
|
||||
* Generic function to convert enum to select options with i18n translations
|
||||
*/
|
||||
export function enumToSelectOptions<T extends Record<string, string | number>>(
|
||||
enumObject: T,
|
||||
translationKey: string,
|
||||
t: (key: string) => string,
|
||||
options?: {
|
||||
includeDescription?: boolean;
|
||||
descriptionKey?: string;
|
||||
sortAlphabetically?: boolean;
|
||||
}
|
||||
): SelectOption[] {
|
||||
const selectOptions = Object.entries(enumObject).map(([_, value]) => ({
|
||||
value,
|
||||
label: t(`${translationKey}.${value}`),
|
||||
...(options?.includeDescription && options?.descriptionKey && {
|
||||
description: t(`${options.descriptionKey}.${value}`)
|
||||
})
|
||||
}));
|
||||
|
||||
if (options?.sortAlphabetically) {
|
||||
selectOptions.sort((a, b) => a.label.localeCompare(b.label));
|
||||
}
|
||||
|
||||
return selectOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook for supplier enum utilities
|
||||
*/
|
||||
export function useSupplierEnums() {
|
||||
const { t } = useTranslation('suppliers');
|
||||
|
||||
return {
|
||||
// Supplier Type
|
||||
getSupplierTypeOptions: (): SelectOption[] =>
|
||||
enumToSelectOptions(SupplierType, 'types', t, {
|
||||
includeDescription: true,
|
||||
descriptionKey: 'descriptions'
|
||||
}),
|
||||
|
||||
getSupplierTypeLabel: (type: SupplierType): string => {
|
||||
if (!type) return t('common:status.undefined', 'Type not defined');
|
||||
return t(`types.${type}`, type);
|
||||
},
|
||||
|
||||
// Supplier Status
|
||||
getSupplierStatusOptions: (): SelectOption[] =>
|
||||
enumToSelectOptions(SupplierStatus, 'status', t),
|
||||
|
||||
getSupplierStatusLabel: (status: SupplierStatus): string => {
|
||||
if (!status) return t('common:status.undefined', 'Status not defined');
|
||||
return t(`status.${status}`, status);
|
||||
},
|
||||
|
||||
// Payment Terms
|
||||
getPaymentTermsOptions: (): SelectOption[] =>
|
||||
enumToSelectOptions(PaymentTerms, 'payment_terms', t, {
|
||||
includeDescription: true,
|
||||
descriptionKey: 'descriptions'
|
||||
}),
|
||||
|
||||
getPaymentTermsLabel: (terms: PaymentTerms): string => {
|
||||
if (!terms) return t('common:forms.no_terms', 'No terms defined');
|
||||
return t(`payment_terms.${terms}`, terms);
|
||||
},
|
||||
|
||||
// Purchase Order Status
|
||||
getPurchaseOrderStatusOptions: (): SelectOption[] =>
|
||||
enumToSelectOptions(PurchaseOrderStatus, 'purchase_order_status', t),
|
||||
|
||||
getPurchaseOrderStatusLabel: (status: PurchaseOrderStatus): string => {
|
||||
if (!status) return t('common:status.undefined', 'Status not defined');
|
||||
return t(`purchase_order_status.${status}`, status);
|
||||
},
|
||||
|
||||
// Delivery Status
|
||||
getDeliveryStatusOptions: (): SelectOption[] =>
|
||||
enumToSelectOptions(DeliveryStatus, 'delivery_status', t),
|
||||
|
||||
getDeliveryStatusLabel: (status: DeliveryStatus): string => {
|
||||
if (!status) return t('common:status.undefined', 'Status not defined');
|
||||
return t(`delivery_status.${status}`, status);
|
||||
},
|
||||
|
||||
// Quality Rating
|
||||
getQualityRatingOptions: (): SelectOption[] =>
|
||||
enumToSelectOptions(QualityRating, 'quality_rating', t, {
|
||||
includeDescription: true,
|
||||
descriptionKey: 'descriptions'
|
||||
}),
|
||||
|
||||
getQualityRatingLabel: (rating: QualityRating): string => {
|
||||
if (rating === undefined || rating === null) return t('common:status.no_rating', 'No rating');
|
||||
return t(`quality_rating.${rating}`, rating.toString());
|
||||
},
|
||||
|
||||
// Delivery Rating
|
||||
getDeliveryRatingOptions: (): SelectOption[] =>
|
||||
enumToSelectOptions(DeliveryRating, 'delivery_rating', t, {
|
||||
includeDescription: true,
|
||||
descriptionKey: 'descriptions'
|
||||
}),
|
||||
|
||||
getDeliveryRatingLabel: (rating: DeliveryRating): string => {
|
||||
if (rating === undefined || rating === null) return t('common:status.no_rating', 'No rating');
|
||||
return t(`delivery_rating.${rating}`, rating.toString());
|
||||
},
|
||||
|
||||
// Invoice Status
|
||||
getInvoiceStatusOptions: (): SelectOption[] =>
|
||||
enumToSelectOptions(InvoiceStatus, 'invoice_status', t),
|
||||
|
||||
getInvoiceStatusLabel: (status: InvoiceStatus): string => {
|
||||
if (!status) return t('common:status.undefined', 'Status not defined');
|
||||
return t(`invoice_status.${status}`, status);
|
||||
},
|
||||
|
||||
// Field Labels
|
||||
getFieldLabel: (field: string): string =>
|
||||
t(`labels.${field}`),
|
||||
|
||||
getFieldDescription: (field: string): string =>
|
||||
t(`descriptions.${field}`)
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility to get enum value from select option value
|
||||
*/
|
||||
export function getEnumFromValue<T>(
|
||||
enumObject: Record<string, T>,
|
||||
value: string | number
|
||||
): T | undefined {
|
||||
return Object.values(enumObject).find(enumValue => enumValue === value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility to validate enum value
|
||||
*/
|
||||
export function isValidEnumValue<T>(
|
||||
enumObject: Record<string, T>,
|
||||
value: unknown
|
||||
): value is T {
|
||||
return Object.values(enumObject).includes(value as T);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook for orders enum utilities
|
||||
*/
|
||||
export function useOrderEnums() {
|
||||
const { t } = useTranslation('orders');
|
||||
|
||||
return {
|
||||
// Customer Type
|
||||
getCustomerTypeOptions: (): SelectOption[] =>
|
||||
enumToSelectOptions(CustomerType, 'customer_types', t),
|
||||
|
||||
getCustomerTypeLabel: (type: CustomerType): string => {
|
||||
if (!type) return t('common:status.undefined', 'Type not defined');
|
||||
return t(`customer_types.${type}`, type.charAt(0).toUpperCase() + type.slice(1));
|
||||
},
|
||||
|
||||
// Delivery Method
|
||||
getDeliveryMethodOptions: (): SelectOption[] =>
|
||||
enumToSelectOptions(DeliveryMethod, 'delivery_methods', t),
|
||||
|
||||
getDeliveryMethodLabel: (method: DeliveryMethod): string => {
|
||||
if (!method) return t('common:status.undefined', 'Method not defined');
|
||||
return t(`delivery_methods.${method}`, method.charAt(0).toUpperCase() + method.slice(1));
|
||||
},
|
||||
|
||||
// Payment Terms
|
||||
getPaymentTermsOptions: (): SelectOption[] =>
|
||||
enumToSelectOptions(OrderPaymentTerms, 'payment_terms', t),
|
||||
|
||||
getPaymentTermsLabel: (terms: OrderPaymentTerms): string => {
|
||||
if (!terms) return t('common:forms.no_terms', 'Terms not defined');
|
||||
return t(`payment_terms.${terms}`, terms);
|
||||
},
|
||||
|
||||
// Payment Method
|
||||
getPaymentMethodOptions: (): SelectOption[] =>
|
||||
enumToSelectOptions(PaymentMethod, 'payment_methods', t),
|
||||
|
||||
getPaymentMethodLabel: (method: PaymentMethod): string => {
|
||||
if (!method) return t('common:status.undefined', 'Method not defined');
|
||||
return t(`payment_methods.${method}`, method);
|
||||
},
|
||||
|
||||
// Payment Status
|
||||
getPaymentStatusOptions: (): SelectOption[] =>
|
||||
enumToSelectOptions(PaymentStatus, 'payment_status', t),
|
||||
|
||||
getPaymentStatusLabel: (status: PaymentStatus): string => {
|
||||
if (!status) return t('common:status.undefined', 'Status not defined');
|
||||
return t(`payment_status.${status}`, status);
|
||||
},
|
||||
|
||||
// Customer Segment
|
||||
getCustomerSegmentOptions: (): SelectOption[] =>
|
||||
enumToSelectOptions(CustomerSegment, 'customer_segments', t),
|
||||
|
||||
getCustomerSegmentLabel: (segment: CustomerSegment): string => {
|
||||
if (!segment) return t('common:status.undefined', 'Segment not defined');
|
||||
return t(`customer_segments.${segment}`, segment);
|
||||
},
|
||||
|
||||
// Priority Level
|
||||
getPriorityLevelOptions: (): SelectOption[] =>
|
||||
enumToSelectOptions(PriorityLevel, 'priority_levels', t),
|
||||
|
||||
getPriorityLevelLabel: (level: PriorityLevel): string => {
|
||||
if (!level) return t('common:priority.undefined', 'Priority not defined');
|
||||
return t(`priority_levels.${level}`, level);
|
||||
},
|
||||
|
||||
// Order Type
|
||||
getOrderTypeOptions: (): SelectOption[] =>
|
||||
enumToSelectOptions(OrderType, 'order_types', t),
|
||||
|
||||
getOrderTypeLabel: (type: OrderType): string => {
|
||||
if (!type) return t('common:status.undefined', 'Type not defined');
|
||||
return t(`order_types.${type}`, type.charAt(0).toUpperCase() + type.slice(1));
|
||||
},
|
||||
|
||||
// Order Status
|
||||
getOrderStatusOptions: (): SelectOption[] =>
|
||||
enumToSelectOptions(OrderStatus, 'order_status', t),
|
||||
|
||||
getOrderStatusLabel: (status: OrderStatus): string => {
|
||||
if (!status) return t('common:status.undefined', 'Status not defined');
|
||||
return t(`order_status.${status}`, status);
|
||||
},
|
||||
|
||||
// Order Source
|
||||
getOrderSourceOptions: (): SelectOption[] =>
|
||||
enumToSelectOptions(OrderSource, 'order_sources', t),
|
||||
|
||||
getOrderSourceLabel: (source: OrderSource): string => {
|
||||
if (!source) return t('common:status.undefined', 'Source not defined');
|
||||
return t(`order_sources.${source}`, source);
|
||||
},
|
||||
|
||||
// Sales Channel
|
||||
getSalesChannelOptions: (): SelectOption[] =>
|
||||
enumToSelectOptions(SalesChannel, 'sales_channels', t),
|
||||
|
||||
getSalesChannelLabel: (channel: SalesChannel): string => {
|
||||
if (!channel) return t('common:status.undefined', 'Channel not defined');
|
||||
return t(`sales_channels.${channel}`, channel);
|
||||
},
|
||||
|
||||
// Field Labels
|
||||
getFieldLabel: (field: string): string =>
|
||||
t(`labels.${field}`),
|
||||
|
||||
getFieldDescription: (field: string): string =>
|
||||
t(`descriptions.${field}`)
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook for production enum utilities
|
||||
*/
|
||||
export function useProductionEnums() {
|
||||
const { t } = useTranslation('production');
|
||||
|
||||
return {
|
||||
// Production Status
|
||||
getProductionStatusOptions: (): SelectOption[] =>
|
||||
enumToSelectOptions(ProductionStatusEnum, 'production_status', t),
|
||||
|
||||
getProductionStatusLabel: (status: ProductionStatusEnum): string => {
|
||||
if (!status) return t('common:status.undefined', 'Status not defined');
|
||||
return t(`production_status.${status}`, status);
|
||||
},
|
||||
|
||||
// Production Priority
|
||||
getProductionPriorityOptions: (): SelectOption[] =>
|
||||
enumToSelectOptions(ProductionPriorityEnum, 'production_priority', t),
|
||||
|
||||
getProductionPriorityLabel: (priority: ProductionPriorityEnum): string => {
|
||||
if (!priority) return t('common:priority.undefined', 'Priority not defined');
|
||||
return t(`production_priority.${priority}`, priority);
|
||||
},
|
||||
|
||||
// Production Batch Status
|
||||
getProductionBatchStatusOptions: (): SelectOption[] =>
|
||||
enumToSelectOptions(ProductionBatchStatus, 'batch_status', t),
|
||||
|
||||
getProductionBatchStatusLabel: (status: ProductionBatchStatus): string => {
|
||||
if (!status) return t('common:status.undefined', 'Status not defined');
|
||||
return t(`batch_status.${status}`, status);
|
||||
},
|
||||
|
||||
// Quality Check Status
|
||||
getQualityCheckStatusOptions: (): SelectOption[] =>
|
||||
enumToSelectOptions(QualityCheckStatus, 'quality_check_status', t),
|
||||
|
||||
getQualityCheckStatusLabel: (status: QualityCheckStatus): string => {
|
||||
if (!status) return t('common:status.undefined', 'Status not defined');
|
||||
return t(`quality_check_status.${status}`, status);
|
||||
},
|
||||
|
||||
// Field Labels
|
||||
getFieldLabel: (field: string): string =>
|
||||
t(`labels.${field}`),
|
||||
|
||||
getFieldDescription: (field: string): string =>
|
||||
t(`descriptions.${field}`)
|
||||
};
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
// frontend/src/utils/foodSafetyEnumHelpers.ts
|
||||
/**
|
||||
* Utilities for working with food safety enums and translations
|
||||
*/
|
||||
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import type { SelectOption } from '../components/ui/Select';
|
||||
import {
|
||||
FoodSafetyStandard,
|
||||
ComplianceStatus,
|
||||
FoodSafetyAlertType,
|
||||
type EnumOption
|
||||
} from '../api/types/foodSafety';
|
||||
|
||||
/**
|
||||
* Generic function to convert enum to select options with i18n translations
|
||||
*/
|
||||
export function enumToSelectOptions<T extends Record<string, string | number>>(
|
||||
enumObject: T,
|
||||
translationKey: string,
|
||||
t: (key: string) => string,
|
||||
options?: {
|
||||
includeDescription?: boolean;
|
||||
descriptionKey?: string;
|
||||
sortAlphabetically?: boolean;
|
||||
}
|
||||
): SelectOption[] {
|
||||
const selectOptions = Object.entries(enumObject).map(([, value]) => ({
|
||||
value,
|
||||
label: t(`${translationKey}.${value}`),
|
||||
...(options?.includeDescription && options?.descriptionKey && {
|
||||
description: t(`${options.descriptionKey}.${value}`)
|
||||
})
|
||||
}));
|
||||
|
||||
if (options?.sortAlphabetically) {
|
||||
selectOptions.sort((a, b) => a.label.localeCompare(b.label));
|
||||
}
|
||||
|
||||
return selectOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook for food safety enum utilities
|
||||
*/
|
||||
export function useFoodSafetyEnums() {
|
||||
const { t } = useTranslation('foodSafety');
|
||||
|
||||
return {
|
||||
// Food Safety Standard
|
||||
getFoodSafetyStandardOptions: (): SelectOption[] =>
|
||||
enumToSelectOptions(FoodSafetyStandard, 'enums.food_safety_standard', t, {
|
||||
includeDescription: true,
|
||||
descriptionKey: 'descriptions',
|
||||
sortAlphabetically: true
|
||||
}),
|
||||
|
||||
getFoodSafetyStandardLabel: (standard: FoodSafetyStandard): string =>
|
||||
t(`enums.food_safety_standard.${standard}`),
|
||||
|
||||
// Compliance Status
|
||||
getComplianceStatusOptions: (): SelectOption[] =>
|
||||
enumToSelectOptions(ComplianceStatus, 'enums.compliance_status', t, {
|
||||
includeDescription: true,
|
||||
descriptionKey: 'descriptions'
|
||||
}),
|
||||
|
||||
getComplianceStatusLabel: (status: ComplianceStatus): string =>
|
||||
t(`enums.compliance_status.${status}`),
|
||||
|
||||
// Food Safety Alert Type
|
||||
getFoodSafetyAlertTypeOptions: (): SelectOption[] =>
|
||||
enumToSelectOptions(FoodSafetyAlertType, 'enums.food_safety_alert_type', t, {
|
||||
includeDescription: true,
|
||||
descriptionKey: 'descriptions',
|
||||
sortAlphabetically: true
|
||||
}),
|
||||
|
||||
getFoodSafetyAlertTypeLabel: (type: FoodSafetyAlertType): string =>
|
||||
t(`enums.food_safety_alert_type.${type}`),
|
||||
|
||||
// Field Labels
|
||||
getFieldLabel: (field: string): string =>
|
||||
t(`labels.${field}`),
|
||||
|
||||
getFieldDescription: (field: string): string =>
|
||||
t(`descriptions.${field}`)
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility to get enum value from select option value
|
||||
*/
|
||||
export function getEnumFromValue<T>(
|
||||
enumObject: Record<string, T>,
|
||||
value: string | number
|
||||
): T | undefined {
|
||||
return Object.values(enumObject).find(enumValue => enumValue === value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility to validate enum value
|
||||
*/
|
||||
export function isValidEnumValue<T>(
|
||||
enumObject: Record<string, T>,
|
||||
value: unknown
|
||||
): value is T {
|
||||
return Object.values(enumObject).includes(value as T);
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
// frontend/src/utils/inventoryEnumHelpers.ts
|
||||
/**
|
||||
* Utilities for working with inventory enums and translations
|
||||
*/
|
||||
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import type { SelectOption } from '../components/ui/Select';
|
||||
import {
|
||||
ProductType,
|
||||
ProductionStage,
|
||||
UnitOfMeasure,
|
||||
IngredientCategory,
|
||||
ProductCategory,
|
||||
StockMovementType,
|
||||
type EnumOption
|
||||
} from '../api/types/inventory';
|
||||
|
||||
/**
|
||||
* Generic function to convert enum to select options with i18n translations
|
||||
*/
|
||||
export function enumToSelectOptions<T extends Record<string, string | number>>(
|
||||
enumObject: T,
|
||||
translationKey: string,
|
||||
t: (key: string) => string,
|
||||
options?: {
|
||||
includeDescription?: boolean;
|
||||
descriptionKey?: string;
|
||||
sortAlphabetically?: boolean;
|
||||
}
|
||||
): SelectOption[] {
|
||||
const selectOptions = Object.entries(enumObject).map(([, value]) => ({
|
||||
value,
|
||||
label: t(`${translationKey}.${value}`),
|
||||
...(options?.includeDescription && options?.descriptionKey && {
|
||||
description: t(`${options.descriptionKey}.${value}`)
|
||||
})
|
||||
}));
|
||||
|
||||
if (options?.sortAlphabetically) {
|
||||
selectOptions.sort((a, b) => a.label.localeCompare(b.label));
|
||||
}
|
||||
|
||||
return selectOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook for inventory enum utilities
|
||||
*/
|
||||
export function useInventoryEnums() {
|
||||
const { t } = useTranslation('inventory');
|
||||
|
||||
return {
|
||||
// Product Type
|
||||
getProductTypeOptions: (): SelectOption[] =>
|
||||
enumToSelectOptions(ProductType, 'enums.product_type', t, {
|
||||
includeDescription: true,
|
||||
descriptionKey: 'descriptions'
|
||||
}),
|
||||
|
||||
getProductTypeLabel: (type: ProductType): string =>
|
||||
t(`enums.product_type.${type}`),
|
||||
|
||||
// Production Stage
|
||||
getProductionStageOptions: (): SelectOption[] =>
|
||||
enumToSelectOptions(ProductionStage, 'enums.production_stage', t, {
|
||||
includeDescription: true,
|
||||
descriptionKey: 'descriptions'
|
||||
}),
|
||||
|
||||
getProductionStageLabel: (stage: ProductionStage): string =>
|
||||
t(`enums.production_stage.${stage}`),
|
||||
|
||||
// Unit of Measure
|
||||
getUnitOfMeasureOptions: (): SelectOption[] =>
|
||||
enumToSelectOptions(UnitOfMeasure, 'enums.unit_of_measure', t, {
|
||||
includeDescription: true,
|
||||
descriptionKey: 'descriptions'
|
||||
}),
|
||||
|
||||
getUnitOfMeasureLabel: (unit: UnitOfMeasure): string =>
|
||||
t(`enums.unit_of_measure.${unit}`),
|
||||
|
||||
// Ingredient Category
|
||||
getIngredientCategoryOptions: (): SelectOption[] =>
|
||||
enumToSelectOptions(IngredientCategory, 'enums.ingredient_category', t, {
|
||||
includeDescription: true,
|
||||
descriptionKey: 'descriptions',
|
||||
sortAlphabetically: true
|
||||
}),
|
||||
|
||||
getIngredientCategoryLabel: (category: IngredientCategory): string =>
|
||||
t(`enums.ingredient_category.${category}`),
|
||||
|
||||
// Product Category
|
||||
getProductCategoryOptions: (): SelectOption[] =>
|
||||
enumToSelectOptions(ProductCategory, 'enums.product_category', t, {
|
||||
sortAlphabetically: true
|
||||
}),
|
||||
|
||||
getProductCategoryLabel: (category: ProductCategory): string =>
|
||||
t(`enums.product_category.${category}`),
|
||||
|
||||
// Stock Movement Type
|
||||
getStockMovementTypeOptions: (): SelectOption[] =>
|
||||
enumToSelectOptions(StockMovementType, 'enums.stock_movement_type', t, {
|
||||
includeDescription: true,
|
||||
descriptionKey: 'descriptions'
|
||||
}),
|
||||
|
||||
getStockMovementTypeLabel: (type: StockMovementType): string =>
|
||||
t(`enums.stock_movement_type.${type}`),
|
||||
|
||||
// Field Labels
|
||||
getFieldLabel: (field: string): string =>
|
||||
t(`labels.${field}`),
|
||||
|
||||
getFieldDescription: (field: string): string =>
|
||||
t(`descriptions.${field}`)
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility to get enum value from select option value
|
||||
*/
|
||||
export function getEnumFromValue<T>(
|
||||
enumObject: Record<string, T>,
|
||||
value: string | number
|
||||
): T | undefined {
|
||||
return Object.values(enumObject).find(enumValue => enumValue === value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility to validate enum value
|
||||
*/
|
||||
export function isValidEnumValue<T>(
|
||||
enumObject: Record<string, T>,
|
||||
value: unknown
|
||||
): value is T {
|
||||
return Object.values(enumObject).includes(value as T);
|
||||
}
|
||||
Reference in New Issue
Block a user