Merge branch 'dev' into 'main'
fix currency formatting See merge request frontend/admin!46
This commit is contained in:
commit
e7cbf749ac
@ -6,7 +6,7 @@
|
||||
"@date-io/dayjs": "^2.15.0",
|
||||
"@emotion/react": "^11.10.4",
|
||||
"@emotion/styled": "^11.10.4",
|
||||
"@frontend/kitui": "^1.0.52",
|
||||
"@frontend/kitui": "^1.0.54",
|
||||
"@material-ui/pickers": "^3.3.10",
|
||||
"@mui/icons-material": "^5.10.3",
|
||||
"@mui/material": "^5.10.5",
|
||||
|
||||
@ -35,8 +35,6 @@ export const createTariff = async (
|
||||
}
|
||||
);
|
||||
|
||||
debugger;
|
||||
|
||||
return [createdTariffResponse];
|
||||
} catch (nativeError) {
|
||||
const [error] = parseAxiosError(nativeError);
|
||||
|
||||
@ -4,6 +4,9 @@ import { Box, IconButton, TextField, Tooltip, Typography } from "@mui/material";
|
||||
import ModeEditOutlineOutlinedIcon from "@mui/icons-material/ModeEditOutlineOutlined";
|
||||
import { PrivilegeWithAmount } from "@frontend/kitui";
|
||||
import { putPrivilege } from "@root/api/privilegies";
|
||||
import SaveIcon from '@mui/icons-material/Save';
|
||||
import { currencyFormatter } from "@root/utils/currencyFormatter";
|
||||
|
||||
|
||||
interface CardPrivilege {
|
||||
privilege: PrivilegeWithAmount;
|
||||
@ -40,6 +43,8 @@ export const СardPrivilege = ({ privilege }: CardPrivilege) => {
|
||||
return;
|
||||
}
|
||||
|
||||
enqueueSnackbar("Изменения сохранены");
|
||||
|
||||
priceRef.current.innerText = "price: " + inputValue;
|
||||
setInputValue("");
|
||||
setInputOpen(false);
|
||||
@ -55,6 +60,13 @@ export const СardPrivilege = ({ privilege }: CardPrivilege) => {
|
||||
}
|
||||
};
|
||||
|
||||
function handleSavePrice() {
|
||||
setInputOpen(false);
|
||||
if (!inputValue) return;
|
||||
|
||||
putPrivileges();
|
||||
}
|
||||
|
||||
return (
|
||||
<Box
|
||||
key={privilege.type}
|
||||
@ -132,10 +144,17 @@ export const СardPrivilege = ({ privilege }: CardPrivilege) => {
|
||||
py: 0,
|
||||
},
|
||||
}}
|
||||
InputProps={{
|
||||
endAdornment: (
|
||||
<IconButton onClick={handleSavePrice}>
|
||||
<SaveIcon />
|
||||
</IconButton>
|
||||
)
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<div ref={priceRef} style={{ color: "white", marginRight: "5px" }}>
|
||||
price: {privilege.price / 100}
|
||||
price: {currencyFormatter.format(privilege.price / 100)}
|
||||
</div>
|
||||
)}
|
||||
<Typography sx={{ color: "white" }}>{translationType[privilege.type]}</Typography>
|
||||
|
||||
@ -20,6 +20,7 @@ import {
|
||||
findPrivilegeById,
|
||||
usePrivilegeStore,
|
||||
} from "@root/stores/privilegesStore";
|
||||
import { currencyFormatter } from "@root/utils/currencyFormatter";
|
||||
|
||||
export default function CreateTariff() {
|
||||
const theme = useTheme();
|
||||
@ -77,6 +78,8 @@ export default function CreateTariff() {
|
||||
return enqueueSnackbar(createdTariffError);
|
||||
}
|
||||
|
||||
enqueueSnackbar("Тариф создан");
|
||||
|
||||
requestTariffs();
|
||||
}
|
||||
};
|
||||
@ -177,7 +180,7 @@ export default function CreateTariff() {
|
||||
Единица: <span>{privilege.type}</span>
|
||||
</Typography>
|
||||
<Typography>
|
||||
Стандартная цена за единицу: <span>{privilege.price}</span>
|
||||
Стандартная цена за единицу: <span>{currencyFormatter.format(privilege.price / 100)}</span>
|
||||
</Typography>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
@ -9,6 +9,7 @@ import { devlog, getMessageFromFetchError } from "@frontend/kitui";
|
||||
import { closeEditTariffDialog, useTariffStore } from "@root/stores/tariffs";
|
||||
import { putTariff } from "@root/api/tariffs";
|
||||
import { requestTariffs } from "@root/services/tariffs.service";
|
||||
import { currencyFormatter } from "@root/utils/currencyFormatter";
|
||||
|
||||
export default function EditModal() {
|
||||
const [nameField, setNameField] = useState("");
|
||||
@ -93,7 +94,7 @@ export default function EditModal() {
|
||||
sx={{ marginBottom: "10px" }}
|
||||
/>
|
||||
<Typography>
|
||||
Цена за единицу: {tariff.privileges[0].price}
|
||||
Цена за единицу: {currencyFormatter.format(tariff.privileges[0].price / 100)}
|
||||
</Typography>
|
||||
<TextField
|
||||
type="number"
|
||||
|
||||
@ -4,6 +4,7 @@ import { Tooltip, IconButton } from "@mui/material";
|
||||
import { usePrivilegeStore } from "@root/stores/privilegesStore";
|
||||
import AutorenewIcon from "@mui/icons-material/Autorenew";
|
||||
import { requestPrivileges } from "@root/services/privilegies.service";
|
||||
import { currencyFormatter } from "@root/utils/currencyFormatter";
|
||||
|
||||
const columns: GridColDef[] = [
|
||||
{ field: "id", headerName: "id", width: 150 },
|
||||
@ -22,7 +23,7 @@ export default function Privileges() {
|
||||
name: privilege.name,
|
||||
description: privilege.description,
|
||||
type: privilege.type,
|
||||
price: privilege.price,
|
||||
price: currencyFormatter.format(privilege.price / 100),
|
||||
}));
|
||||
|
||||
return (
|
||||
|
||||
@ -10,6 +10,7 @@ import { requestTariffs } from "@root/services/tariffs.service";
|
||||
import { openDeleteTariffDialog, openEditTariffDialog, setSelectedTariffIds, useTariffStore } from "@root/stores/tariffs";
|
||||
import { Tariff } from "@frontend/kitui";
|
||||
import { getTariffPrice } from "@root/utils/tariffPrice";
|
||||
import { currencyFormatter } from "@root/utils/currencyFormatter";
|
||||
|
||||
|
||||
const columns: GridColDef<Tariff, string | number>[] = [
|
||||
@ -31,9 +32,9 @@ const columns: GridColDef<Tariff, string | number>[] = [
|
||||
{ field: "serviceName", headerName: "Сервис", width: 150, valueGetter: ({ row }) => row.privileges[0].serviceKey },
|
||||
{ field: "privilegeName", headerName: "Привилегия", width: 150, valueGetter: ({ row }) => row.privileges[0].name },
|
||||
{ field: "type", headerName: "Единица", width: 100, valueGetter: ({ row }) => row.privileges[0].type },
|
||||
{ field: "pricePerUnit", headerName: "Цена за ед.", width: 100, valueGetter: ({ row }) => row.privileges[0].price },
|
||||
{ field: "pricePerUnit", headerName: "Цена за ед.", width: 100, valueGetter: ({ row }) => currencyFormatter.format(row.privileges[0].price / 100) },
|
||||
{ field: "isCustom", headerName: "Кастомная цена", width: 130, valueGetter: ({ row }) => row.isCustom ? "Да" : "Нет" },
|
||||
{ field: "total", headerName: "Сумма", width: 60, valueGetter: ({ row }) => getTariffPrice(row) },
|
||||
{ field: "total", headerName: "Сумма", width: 60, valueGetter: ({ row }) => currencyFormatter.format(getTariffPrice(row) / 100) },
|
||||
{
|
||||
field: "delete",
|
||||
headerName: "Удаление",
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import { resetPrivilegeArray } from "@root/stores/privilegesStore";
|
||||
import { exampleCartValues } from "@stores/mocks/exampleCartValues";
|
||||
import { requestServicePrivileges } from "@root/api/privilegies";
|
||||
|
||||
import type { PrivilegeWithAmount } from "@frontend/kitui";
|
||||
@ -11,18 +10,7 @@ const mutatePrivileges = (privileges: PrivilegeWithAmount[]) => {
|
||||
extracted = extracted.concat(privileges[serviceKey]);
|
||||
}
|
||||
|
||||
let readyArray = extracted.map((privilege) => ({
|
||||
serviceKey: privilege.serviceKey,
|
||||
privilegeId: privilege.privilegeId,
|
||||
name: privilege.name,
|
||||
description: privilege.description,
|
||||
type: privilege.type,
|
||||
price: privilege.price,
|
||||
value: privilege.value,
|
||||
_id: privilege._id,
|
||||
}));
|
||||
|
||||
resetPrivilegeArray([...readyArray, ...exampleCartValues.privileges]);
|
||||
resetPrivilegeArray(extracted);
|
||||
};
|
||||
|
||||
export const requestPrivileges = async () => {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1433,10 +1433,10 @@
|
||||
lodash.isundefined "^3.0.1"
|
||||
lodash.uniq "^4.5.0"
|
||||
|
||||
"@frontend/kitui@^1.0.52":
|
||||
version "1.0.52"
|
||||
resolved "https://penahub.gitlab.yandexcloud.net/api/v4/projects/21/packages/npm/@frontend/kitui/-/@frontend/kitui-1.0.52.tgz#3b1c28f889da80ab325ab2b511108632fa925f1c"
|
||||
integrity sha1-Oxwo+InagKsyWrK1ERCGMvqSXxw=
|
||||
"@frontend/kitui@^1.0.54":
|
||||
version "1.0.54"
|
||||
resolved "https://penahub.gitlab.yandexcloud.net/api/v4/projects/21/packages/npm/@frontend/kitui/-/@frontend/kitui-1.0.54.tgz#0235d5a8effb9b92351471c3c7775f28cb2839f6"
|
||||
integrity sha1-AjXVqO/7m5I1FHHDx3dfKMsoOfY=
|
||||
dependencies:
|
||||
immer "^10.0.2"
|
||||
reconnecting-eventsource "^1.6.2"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user