mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
use navigation function instaed
This commit is contained in:
parent
f8cdf9c19d
commit
2f4d74a180
@ -1,6 +1,6 @@
|
|||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { Accordion, Alert, LoadingOverlay, Stack, Text } from '@mantine/core';
|
import { Accordion, Alert, LoadingOverlay, Stack, Text } from '@mantine/core';
|
||||||
import { ReactNode, useMemo } from 'react';
|
import { useMemo, useState } from 'react';
|
||||||
|
|
||||||
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
||||||
import { UserRoles } from '../../enums/Roles';
|
import { UserRoles } from '../../enums/Roles';
|
||||||
@ -53,6 +53,17 @@ export default function PartPricingPanel({ part }: { part: any }) {
|
|||||||
return user.hasViewRole(UserRoles.sales_order) && part?.salable;
|
return user.hasViewRole(UserRoles.sales_order) && part?.salable;
|
||||||
}, [user, part]);
|
}, [user, part]);
|
||||||
|
|
||||||
|
const [value, setValue] = useState<string[]>([panelOptions.overview]);
|
||||||
|
function doNavigation(panel: panelOptions) {
|
||||||
|
if (!value.includes(panel)) {
|
||||||
|
setValue([...value, panel]);
|
||||||
|
}
|
||||||
|
const element = document.getElementById(panel);
|
||||||
|
if (element) {
|
||||||
|
element.scrollIntoView();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack spacing="xs">
|
<Stack spacing="xs">
|
||||||
<LoadingOverlay visible={instanceQuery.isLoading} />
|
<LoadingOverlay visible={instanceQuery.isLoading} />
|
||||||
@ -62,9 +73,15 @@ export default function PartPricingPanel({ part }: { part: any }) {
|
|||||||
</Alert>
|
</Alert>
|
||||||
)}
|
)}
|
||||||
{pricing && (
|
{pricing && (
|
||||||
<Accordion multiple defaultValue={['overview']}>
|
<Accordion multiple value={value} onChange={setValue}>
|
||||||
<PricingPanel
|
<PricingPanel
|
||||||
content={<PricingOverviewPanel part={part} pricing={pricing} />}
|
content={
|
||||||
|
<PricingOverviewPanel
|
||||||
|
part={part}
|
||||||
|
pricing={pricing}
|
||||||
|
doNavigation={doNavigation}
|
||||||
|
/>
|
||||||
|
}
|
||||||
label={panelOptions.overview}
|
label={panelOptions.overview}
|
||||||
title={t`Pricing Overview`}
|
title={t`Pricing Overview`}
|
||||||
visible={true}
|
visible={true}
|
||||||
|
@ -1,13 +1,5 @@
|
|||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import {
|
import { Alert, Group, Paper, SimpleGrid, Stack, Text } from '@mantine/core';
|
||||||
Alert,
|
|
||||||
Anchor,
|
|
||||||
Group,
|
|
||||||
Paper,
|
|
||||||
SimpleGrid,
|
|
||||||
Stack,
|
|
||||||
Text
|
|
||||||
} from '@mantine/core';
|
|
||||||
import {
|
import {
|
||||||
IconBuildingWarehouse,
|
IconBuildingWarehouse,
|
||||||
IconChartDonut,
|
IconChartDonut,
|
||||||
@ -45,10 +37,12 @@ interface PricingOverviewEntry {
|
|||||||
|
|
||||||
export default function PricingOverviewPanel({
|
export default function PricingOverviewPanel({
|
||||||
part,
|
part,
|
||||||
pricing
|
pricing,
|
||||||
|
doNavigation
|
||||||
}: {
|
}: {
|
||||||
part: any;
|
part: any;
|
||||||
pricing: any;
|
pricing: any;
|
||||||
|
doNavigation: (panel: panelOptions) => void;
|
||||||
}): ReactNode {
|
}): ReactNode {
|
||||||
const columns: DataTableColumn<any>[] = useMemo(() => {
|
const columns: DataTableColumn<any>[] = useMemo(() => {
|
||||||
return [
|
return [
|
||||||
@ -59,14 +53,9 @@ export default function PricingOverviewPanel({
|
|||||||
return (
|
return (
|
||||||
<Group position="left" spacing="xs">
|
<Group position="left" spacing="xs">
|
||||||
{record.icon}
|
{record.icon}
|
||||||
{record.name !== panelOptions.overall &&
|
<Text weight={700} onClick={() => doNavigation(record.name)}>
|
||||||
record.name !== panelOptions.override ? (
|
|
||||||
<Anchor href={`#${record.name}`} weight={700}>
|
|
||||||
{record.title}
|
{record.title}
|
||||||
</Anchor>
|
</Text>
|
||||||
) : (
|
|
||||||
<Text weight={700}>{record.title}</Text>
|
|
||||||
)}
|
|
||||||
</Group>
|
</Group>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user