Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5137.4 #5322

Merged
merged 12 commits into from
Nov 10, 2024
3 changes: 2 additions & 1 deletion client/packages/common/src/intl/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,6 @@
"label.age-months-count_other": "{{count}} months",
"label.age-years_one": "{{count}} year",
"label.age-years_other": "{{count}} years",
"label.all-requested-quantity": "Other requested",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed cause it's other-requested

"label.allocated": "Allocated",
"label.already-issued": "Issued",
"label.amc": "AMC",
Expand Down Expand Up @@ -840,7 +839,9 @@
"label.order-quantity": "Requested quantity",
"label.order-type": "Order Type",
"label.other-facility": "Other facility",
"label.other-requested-quantity": "Other requested",
"label.our-soh": "Our SOH",
"label.our-stock": "Our Stock",
"label.out-of-stock": "Out of stock",
"label.outbound-shipment": "Outbound shipment",
"label.outer-pack-size": "Outer pack size",
Expand Down
2 changes: 1 addition & 1 deletion client/packages/common/src/intl/locales/es/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@
"label.age-months-and_other": "months {{count}}, ",
"label.age-months-count_one": "{{count}} mes",
"label.age-months-count_other": "{{count}} meses",
"label.all-requested-quantity": "Otro solicitado",
"label.other-requested-quantity": "Otro solicitado",
"label.allocated": "Asignado",
"label.already-issued": "Enviado",
"label.amc": "AMC",
Expand Down
2 changes: 1 addition & 1 deletion client/packages/common/src/intl/locales/fr/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@
"label.age-months-and_other": "{{count}} mois, ",
"label.age-months-count_one": "{{count}} mois",
"label.age-months-count_other": "{{count}} mois",
"label.all-requested-quantity": "Autres",
"label.other-requested-quantity": "Autres",
"label.allocated": "AllouΓ©(e)",
"label.already-issued": "LivrΓ©s",
"label.amc": "CMM",
Expand Down
2 changes: 1 addition & 1 deletion client/packages/common/src/intl/locales/pt/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@
"label.age-months-count_other": "{{count}} meses",
"label.age-months-from": "Idade a partir de (meses)",
"label.age-months-to": "Idade em (meses)",
"label.all-requested-quantity": "Outro requisitado",
"label.other-requested-quantity": "Outro requisitado",
"label.allocated": "Alocado",
"label.already-issued": "Emitido",
"label.amc": "CMM",
Expand Down
2 changes: 1 addition & 1 deletion client/packages/common/src/intl/locales/ru/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@
"label.age-days_other": "{{count}} Π΄Π½Π΅ΠΉ",
"label.age-months-and_one": "{{count}} мСсяц, ",
"label.age-months-and_other": "{{count}} мСсяцСв, ",
"label.all-requested-quantity": "Π”Ρ€ΡƒΠ³ΠΈΠ΅ Π·Π°ΠΏΡ€Π°ΡˆΠΈΠ²Π°Π΅ΠΌΡ‹Π΅",
"label.other-requested-quantity": "Π”Ρ€ΡƒΠ³ΠΈΠ΅ Π·Π°ΠΏΡ€Π°ΡˆΠΈΠ²Π°Π΅ΠΌΡ‹Π΅",
"label.allocated": "Π’Ρ‹Π΄Π΅Π»Π΅Π½ΠΎ",
"label.already-issued": "Π’Ρ‹Π΄Π°Π½ΠΎ",
"label.amc": "Π‘Ρ€Π΅Π΄Π½Π΅Π΅ ΠœΠ΅ΡΡΡ‡Π½ΠΎΠ΅ ΠŸΠΎΡ‚Ρ€Π΅Π±Π»Π΅Π½ΠΈΠ΅",
Expand Down
2 changes: 1 addition & 1 deletion client/packages/common/src/intl/locales/tet/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@
"label.add-charges": "Aumenta Cobrancas",
"label.add-new-line": "Aumenta lina foun",
"label.address": "Enderesu",
"label.all-requested-quantity": "Pedidu seluk",
"label.other-requested-quantity": "Pedidu seluk",
"label.allocated": "Aloka Ona",
"label.amc": "AMC",
"label.amount": "Montante",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React from 'react';
import { Box } from '@mui/material';
import { StoryFn, Meta } from '@storybook/react';
import { NewValueBar } from './NewValueBar';

const Template: StoryFn<typeof NewValueBar> = ({ value, total, colour }) => (
<Box display="flex" width="25%">
<NewValueBar value={value} total={total} colour={colour} />
</Box>
);

export const Default = Template.bind({});
export const NoDividers = Template.bind({});
export const BothDividers = Template.bind({});

Default.args = {
value: 10,
total: 20,
colour: 'gray.main',
};

NoDividers.args = {
value: 10,
total: 20,
colour: 'gray.main',
};

BothDividers.args = {
value: 10,
total: 20,
colour: 'gray.main',
};

export default {
title: 'Charts/ValueBar',
component: NewValueBar,
} as Meta<typeof NewValueBar>;
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from 'react';
import { Box, Typography } from '@openmsupply-client/common';
import { useFormatNumber } from '@common/intl';

const MIN_FLEX_BASIS_TO_SHOW_VALUE = 5;

interface ValueBarProps {
value: number;
total: number;
colour: string;
}

export const NewValueBar = ({ value, total, colour }: ValueBarProps) => {
const formatNumber = useFormatNumber();
if (value === 0) return null;

const flexBasis = Math.min(Math.round((100 * value) / total), 100);

return (
<>
<Box display="flex" flexDirection="column" width="100%">
<Box flexBasis={`${flexBasis}%`} flexGrow={1}>
<Box sx={{ backgroundColor: colour, height: '20px' }}>
{flexBasis > MIN_FLEX_BASIS_TO_SHOW_VALUE ? (
<Typography
fontSize={12}
sx={{
color: 'primary.contrastText',
flex: 1,
justifyContent: 'center',
display: 'flex',
fontWeight: 'bold',
}}
component="div"
>
{formatNumber.round(value)}
</Typography>
) : null}
</Box>
</Box>
</Box>
</>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './NewValueBar';
1 change: 1 addition & 0 deletions client/packages/common/src/ui/components/charts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ export {
};

export * from './ValueBar';
export * from './NewValueBar';
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import {
Typography,
ValueBar,
} from '@openmsupply-client/common';
import { ItemRowFragment } from 'packages/system/src';

export interface RequestStoreStatsProps {
item?: ItemRowFragment;
maxMonthsOfStock: number;
suggestedQuantity: number;
availableStockOnHand: number;
Expand Down Expand Up @@ -104,6 +106,7 @@ const CalculationError = ({
};

export const RequestStoreStats: React.FC<RequestStoreStatsProps> = ({
item,
maxMonthsOfStock,
suggestedQuantity,
availableStockOnHand,
Expand All @@ -123,7 +126,29 @@ export const RequestStoreStats: React.FC<RequestStoreStatsProps> = ({
: 100;

return (
<>
<Box sx={{ height: 400, width: 500 }}>
<Box display="flex" flexDirection="column" paddingTop={2} paddingLeft={4}>
<Box display="flex">
<Typography fontSize={12} fontWeight={700}>
{t('label.name')}:&nbsp;
</Typography>
<Typography fontSize={12}>{item?.name ?? ''}</Typography>
</Box>
<Box display="flex" gap={5}>
<Box display="flex">
<Typography fontSize={12} fontWeight={700}>
{t('label.code')}:&nbsp;
</Typography>
<Typography fontSize={12}>{item?.code ?? ''}</Typography>
</Box>
<Box display="flex">
<Typography fontSize={12} fontWeight={700}>
{t('label.unit')}:&nbsp;
</Typography>
<Typography fontSize={12}>{item?.unitName ?? ''}</Typography>
</Box>
</Box>
</Box>
<Box
sx={{
paddingLeft: 4,
Expand Down Expand Up @@ -178,6 +203,6 @@ export const RequestStoreStats: React.FC<RequestStoreStatsProps> = ({
</Box>
</>
</Box>
</>
</Box>
);
};
Loading
Loading