mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
use enum for refs
This commit is contained in:
parent
13a25644aa
commit
6cafba9778
@ -15,6 +15,19 @@ import SaleHistoryPanel from './pricing/SaleHistoryPanel';
|
|||||||
import SupplierPricingPanel from './pricing/SupplierPricingPanel';
|
import SupplierPricingPanel from './pricing/SupplierPricingPanel';
|
||||||
import VariantPricingPanel from './pricing/VariantPricingPanel';
|
import VariantPricingPanel from './pricing/VariantPricingPanel';
|
||||||
|
|
||||||
|
export enum panelOptions {
|
||||||
|
overview = 'overview',
|
||||||
|
purchase = 'purchase',
|
||||||
|
internal = 'internal',
|
||||||
|
supplier = 'supplier',
|
||||||
|
bom = 'bom',
|
||||||
|
variant = 'variant',
|
||||||
|
sale_pricing = 'sale-pricing',
|
||||||
|
sale_history = 'sale-history',
|
||||||
|
override = 'override',
|
||||||
|
overall = 'overall'
|
||||||
|
}
|
||||||
|
|
||||||
export default function PartPricingPanel({ part }: { part: any }) {
|
export default function PartPricingPanel({ part }: { part: any }) {
|
||||||
const user = useUserState();
|
const user = useUserState();
|
||||||
|
|
||||||
@ -52,13 +65,13 @@ export default function PartPricingPanel({ part }: { part: any }) {
|
|||||||
<Accordion multiple defaultValue={['overview']}>
|
<Accordion multiple defaultValue={['overview']}>
|
||||||
<PricingPanel
|
<PricingPanel
|
||||||
content={<PricingOverviewPanel part={part} pricing={pricing} />}
|
content={<PricingOverviewPanel part={part} pricing={pricing} />}
|
||||||
label="overview"
|
label={panelOptions.overview}
|
||||||
title={t`Pricing Overview`}
|
title={t`Pricing Overview`}
|
||||||
visible={true}
|
visible={true}
|
||||||
/>
|
/>
|
||||||
<PricingPanel
|
<PricingPanel
|
||||||
content={<PurchaseHistoryPanel part={part} />}
|
content={<PurchaseHistoryPanel part={part} />}
|
||||||
label="purchase"
|
label={panelOptions.purchase}
|
||||||
title={t`Purchase History`}
|
title={t`Purchase History`}
|
||||||
visible={purchaseOrderPricing}
|
visible={purchaseOrderPricing}
|
||||||
disabled={
|
disabled={
|
||||||
@ -72,7 +85,7 @@ export default function PartPricingPanel({ part }: { part: any }) {
|
|||||||
endpoint={ApiEndpoints.part_pricing_internal}
|
endpoint={ApiEndpoints.part_pricing_internal}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
label="internal"
|
label={panelOptions.internal}
|
||||||
title={t`Internal Pricing`}
|
title={t`Internal Pricing`}
|
||||||
visible={internalPricing}
|
visible={internalPricing}
|
||||||
disabled={
|
disabled={
|
||||||
@ -81,7 +94,7 @@ export default function PartPricingPanel({ part }: { part: any }) {
|
|||||||
/>
|
/>
|
||||||
<PricingPanel
|
<PricingPanel
|
||||||
content={<SupplierPricingPanel part={part} />}
|
content={<SupplierPricingPanel part={part} />}
|
||||||
label="supplier"
|
label={panelOptions.supplier}
|
||||||
title={t`Supplier Pricing`}
|
title={t`Supplier Pricing`}
|
||||||
visible={purchaseOrderPricing}
|
visible={purchaseOrderPricing}
|
||||||
disabled={
|
disabled={
|
||||||
@ -90,14 +103,14 @@ export default function PartPricingPanel({ part }: { part: any }) {
|
|||||||
/>
|
/>
|
||||||
<PricingPanel
|
<PricingPanel
|
||||||
content={<BomPricingPanel part={part} pricing={pricing} />}
|
content={<BomPricingPanel part={part} pricing={pricing} />}
|
||||||
label="bom"
|
label={panelOptions.bom}
|
||||||
title={t`BOM Pricing`}
|
title={t`BOM Pricing`}
|
||||||
visible={part?.assembly}
|
visible={part?.assembly}
|
||||||
disabled={!pricing?.bom_cost_min || !pricing?.bom_cost_max}
|
disabled={!pricing?.bom_cost_min || !pricing?.bom_cost_max}
|
||||||
/>
|
/>
|
||||||
<PricingPanel
|
<PricingPanel
|
||||||
content={<VariantPricingPanel part={part} pricing={pricing} />}
|
content={<VariantPricingPanel part={part} pricing={pricing} />}
|
||||||
label="variant"
|
label={panelOptions.variant}
|
||||||
title={t`Variant Pricing`}
|
title={t`Variant Pricing`}
|
||||||
visible={part?.is_template}
|
visible={part?.is_template}
|
||||||
disabled={!pricing?.variant_cost_min || !pricing?.variant_cost_max}
|
disabled={!pricing?.variant_cost_min || !pricing?.variant_cost_max}
|
||||||
@ -109,14 +122,14 @@ export default function PartPricingPanel({ part }: { part: any }) {
|
|||||||
endpoint={ApiEndpoints.part_pricing_sale}
|
endpoint={ApiEndpoints.part_pricing_sale}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
label="sale-pricing"
|
label={panelOptions.sale_pricing}
|
||||||
title={t`Sale Pricing`}
|
title={t`Sale Pricing`}
|
||||||
visible={salesOrderPricing}
|
visible={salesOrderPricing}
|
||||||
disabled={!pricing?.sale_price_min || !pricing?.sale_price_max}
|
disabled={!pricing?.sale_price_min || !pricing?.sale_price_max}
|
||||||
/>
|
/>
|
||||||
<PricingPanel
|
<PricingPanel
|
||||||
content={<SaleHistoryPanel part={part} />}
|
content={<SaleHistoryPanel part={part} />}
|
||||||
label="sale-history"
|
label={panelOptions.sale_history}
|
||||||
title={t`Sale History`}
|
title={t`Sale History`}
|
||||||
visible={salesOrderPricing}
|
visible={salesOrderPricing}
|
||||||
disabled={!pricing?.sale_history_min || !pricing?.sale_history_max}
|
disabled={!pricing?.sale_history_min || !pricing?.sale_history_max}
|
||||||
|
@ -23,10 +23,11 @@ import {
|
|||||||
|
|
||||||
import { CHART_COLORS } from '../../../components/charts/colors';
|
import { CHART_COLORS } from '../../../components/charts/colors';
|
||||||
import { formatCurrency, renderDate } from '../../../defaults/formatters';
|
import { formatCurrency, renderDate } from '../../../defaults/formatters';
|
||||||
|
import { panelOptions } from '../PartPricingPanel';
|
||||||
|
|
||||||
interface PricingOverviewEntry {
|
interface PricingOverviewEntry {
|
||||||
icon: ReactNode;
|
icon: ReactNode;
|
||||||
name: string;
|
name: panelOptions;
|
||||||
title: string;
|
title: string;
|
||||||
min_value: number | null | undefined;
|
min_value: number | null | undefined;
|
||||||
max_value: number | null | undefined;
|
max_value: number | null | undefined;
|
||||||
@ -86,63 +87,63 @@ export default function PricingOverviewPanel({
|
|||||||
const overviewData: PricingOverviewEntry[] = useMemo(() => {
|
const overviewData: PricingOverviewEntry[] = useMemo(() => {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
name: 'internal',
|
name: panelOptions.internal,
|
||||||
title: t`Internal Pricing`,
|
title: t`Internal Pricing`,
|
||||||
icon: <IconList />,
|
icon: <IconList />,
|
||||||
min_value: pricing?.internal_cost_min,
|
min_value: pricing?.internal_cost_min,
|
||||||
max_value: pricing?.internal_cost_max
|
max_value: pricing?.internal_cost_max
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'bom',
|
name: panelOptions.bom,
|
||||||
title: t`BOM Pricing`,
|
title: t`BOM Pricing`,
|
||||||
icon: <IconChartDonut />,
|
icon: <IconChartDonut />,
|
||||||
min_value: pricing?.bom_cost_min,
|
min_value: pricing?.bom_cost_min,
|
||||||
max_value: pricing?.bom_cost_max
|
max_value: pricing?.bom_cost_max
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'purchase',
|
name: panelOptions.purchase,
|
||||||
title: t`Purchase Pricing`,
|
title: t`Purchase Pricing`,
|
||||||
icon: <IconShoppingCart />,
|
icon: <IconShoppingCart />,
|
||||||
min_value: pricing?.purchase_cost_min,
|
min_value: pricing?.purchase_cost_min,
|
||||||
max_value: pricing?.purchase_cost_max
|
max_value: pricing?.purchase_cost_max
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'supplier',
|
name: panelOptions.supplier,
|
||||||
title: t`Supplier Pricing`,
|
title: t`Supplier Pricing`,
|
||||||
icon: <IconBuildingWarehouse />,
|
icon: <IconBuildingWarehouse />,
|
||||||
min_value: pricing?.supplier_price_min,
|
min_value: pricing?.supplier_price_min,
|
||||||
max_value: pricing?.supplier_price_max
|
max_value: pricing?.supplier_price_max
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'variants',
|
name: panelOptions.variant,
|
||||||
title: t`Variant Pricing`,
|
title: t`Variant Pricing`,
|
||||||
icon: <IconTriangleSquareCircle />,
|
icon: <IconTriangleSquareCircle />,
|
||||||
min_value: pricing?.variant_cost_min,
|
min_value: pricing?.variant_cost_min,
|
||||||
max_value: pricing?.variant_cost_max
|
max_value: pricing?.variant_cost_max
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'sale',
|
name: panelOptions.sale_pricing,
|
||||||
title: t`Sale Pricing`,
|
title: t`Sale Pricing`,
|
||||||
icon: <IconTriangleSquareCircle />,
|
icon: <IconTriangleSquareCircle />,
|
||||||
min_value: pricing?.sale_price_min,
|
min_value: pricing?.sale_price_min,
|
||||||
max_value: pricing?.sale_price_max
|
max_value: pricing?.sale_price_max
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'sale-history',
|
name: panelOptions.sale_history,
|
||||||
title: t`Sale History`,
|
title: t`Sale History`,
|
||||||
icon: <IconTriangleSquareCircle />,
|
icon: <IconTriangleSquareCircle />,
|
||||||
min_value: pricing?.sale_history_min,
|
min_value: pricing?.sale_history_min,
|
||||||
max_value: pricing?.sale_history_max
|
max_value: pricing?.sale_history_max
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'override',
|
name: panelOptions.override,
|
||||||
title: t`Override Pricing`,
|
title: t`Override Pricing`,
|
||||||
icon: <IconExclamationCircle />,
|
icon: <IconExclamationCircle />,
|
||||||
min_value: pricing?.override_min,
|
min_value: pricing?.override_min,
|
||||||
max_value: pricing?.override_max
|
max_value: pricing?.override_max
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'overall',
|
name: panelOptions.overall,
|
||||||
title: t`Overall Pricing`,
|
title: t`Overall Pricing`,
|
||||||
icon: <IconReportAnalytics />,
|
icon: <IconReportAnalytics />,
|
||||||
min_value: pricing?.overall_min,
|
min_value: pricing?.overall_min,
|
||||||
|
@ -13,6 +13,7 @@ import { IconAlertCircle, IconExclamationCircle } from '@tabler/icons-react';
|
|||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
|
|
||||||
import { StylishText } from '../../../components/items/StylishText';
|
import { StylishText } from '../../../components/items/StylishText';
|
||||||
|
import { panelOptions } from '../PartPricingPanel';
|
||||||
|
|
||||||
function AccordionControl(props: AccordionControlProps) {
|
function AccordionControl(props: AccordionControlProps) {
|
||||||
return (
|
return (
|
||||||
@ -39,7 +40,7 @@ export default function PricingPanel({
|
|||||||
disabled = undefined
|
disabled = undefined
|
||||||
}: {
|
}: {
|
||||||
content: ReactNode;
|
content: ReactNode;
|
||||||
label: string;
|
label: panelOptions;
|
||||||
title: string;
|
title: string;
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
disabled?: boolean | undefined;
|
disabled?: boolean | undefined;
|
||||||
|
Loading…
Reference in New Issue
Block a user