Merge branch 'dev' into 'staging'
Dev See merge request frontend/squiz!262
This commit is contained in:
commit
0758d97297
@ -1,29 +1,29 @@
|
||||
import { Typography, Box } from "@mui/material";
|
||||
import { useUserStore } from "@root/user"
|
||||
import { useUserStore } from "@root/user";
|
||||
import { Link } from "react-router-dom";
|
||||
export const InfoPrivilege = () => {
|
||||
const user = useUserStore();
|
||||
console.log(user)
|
||||
return (
|
||||
<Box>
|
||||
<Link to="/list">К списку квизов</Link>
|
||||
{Object.values(user?.userAccount?.privileges || {}).map((privilege) => {
|
||||
console.log(privilege)
|
||||
return (
|
||||
<Box
|
||||
sx={{
|
||||
border: "1px solid",
|
||||
margin: "0 10px",
|
||||
display: "flex",
|
||||
justifyContent: "space-around",
|
||||
padding: "5px 0",
|
||||
}}
|
||||
>
|
||||
<Typography>{privilege?.privilege_name}</Typography>
|
||||
<Typography>{privilege?.amount}</Typography>
|
||||
</Box>
|
||||
)
|
||||
})}
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
const user = useUserStore();
|
||||
console.log(user);
|
||||
return (
|
||||
<Box>
|
||||
<Link to="/list">К списку квизов</Link>
|
||||
{Object.values(user?.userAccount?.privileges || {}).map((privilege) => {
|
||||
console.log(privilege);
|
||||
return (
|
||||
<Box
|
||||
sx={{
|
||||
border: "1px solid",
|
||||
margin: "0 10px",
|
||||
display: "flex",
|
||||
justifyContent: "space-around",
|
||||
padding: "5px 0",
|
||||
}}
|
||||
>
|
||||
<Typography>{privilege?.privilege_name}</Typography>
|
||||
<Typography>{privilege?.amount}</Typography>
|
||||
</Box>
|
||||
);
|
||||
})}
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
@ -121,35 +121,33 @@ function TariffPage() {
|
||||
url: process.env.REACT_APP_DOMAIN + `/customer/cart?id=${id}`,
|
||||
});
|
||||
//Если нам хватает денежек - покупаем тариф
|
||||
if (price * 100 <= cashCop) {
|
||||
try {
|
||||
const data = await makeRequest({
|
||||
method: "POST",
|
||||
url: process.env.REACT_APP_DOMAIN + "/customer/cart/pay",
|
||||
});
|
||||
console.log(data);
|
||||
setCash(
|
||||
currencyFormatter.format(Number(data.wallet.cash) / 100),
|
||||
Number(data.wallet.cash),
|
||||
Number(data.wallet.cash) / 100,
|
||||
);
|
||||
enqueueSnackbar("Тариф успешно приобретён");
|
||||
} catch (e) {
|
||||
enqueueSnackbar("Произошла ошибка. Попробуйте позже");
|
||||
}
|
||||
//Развращаем товары в корзину
|
||||
inCart();
|
||||
} else {
|
||||
//Деняк не хватило
|
||||
// history.pushState({}, null, "https://hub.pena.digital/wallet?action=squizpay");
|
||||
|
||||
var link = document.createElement("a");
|
||||
link.href = `https://${isTestServer ? "s" : ""}hub.pena.digital/quizpayment?action=squizpay&dif=${Math.round(
|
||||
price * 100 - cashCop,
|
||||
)}&data=${token}&userid=${userId}`;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
try {
|
||||
const data = await makeRequest({
|
||||
method: "POST",
|
||||
url: process.env.REACT_APP_DOMAIN + "/customer/cart/pay",
|
||||
});
|
||||
console.log(data);
|
||||
setCash(
|
||||
currencyFormatter.format(Number(data.wallet.cash) / 100),
|
||||
Number(data.wallet.cash),
|
||||
Number(data.wallet.cash) / 100,
|
||||
);
|
||||
enqueueSnackbar("Тариф успешно приобретён");
|
||||
} catch (e) {
|
||||
//если денег не хватило
|
||||
if (e.response.data.message.includes("insufficient funds")) {
|
||||
let cashDif = Number(e.response.data.message.split(":")[1]);
|
||||
var link = document.createElement("a");
|
||||
link.href = `https://${isTestServer ? "s" : ""}hub.pena.digital/quizpayment?action=squizpay&dif=${cashDif}&data=${token}&userid=${userId}`;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
}
|
||||
//другая ошибка
|
||||
enqueueSnackbar("Произошла ошибка. Попробуйте позже");
|
||||
}
|
||||
//Развращаем товары в корзину
|
||||
inCart();
|
||||
};
|
||||
|
||||
const filteredTariffs = tariffs.filter((tariff) => {
|
||||
|
@ -12,47 +12,16 @@ export const createTariffElements = (
|
||||
discounts: any,
|
||||
onclick: any,
|
||||
) => {
|
||||
console.log("я карточка и я получила скидки ", discounts)
|
||||
calcTariffPrice(
|
||||
{
|
||||
"_id": "6606f2241747c1eea800bb67",
|
||||
"name": "1 месяц",
|
||||
"description": "Скрытие логотипа \"Pena\" во всех quiz на 1 месяц",
|
||||
"price": 0,
|
||||
"order": 0,
|
||||
"isCustom": false,
|
||||
"privileges": [
|
||||
{
|
||||
"name": "Скрытие шильдика в опроснике",
|
||||
"privilegeId": "squizHideBadge",
|
||||
"serviceKey": "squiz",
|
||||
"description": "Количество дней скрытия шильдика в опроснике",
|
||||
"type": "day",
|
||||
"value": "день",
|
||||
"price": 16700,
|
||||
"amount": 30
|
||||
}
|
||||
],
|
||||
"isDeleted": false,
|
||||
"createdAt": "2024-03-29T16:53:56.191Z",
|
||||
"updatedAt": "2024-03-29T16:53:56.191Z"
|
||||
},
|
||||
discounts,
|
||||
user.wallet.spent,
|
||||
[],
|
||||
false,
|
||||
user.id,
|
||||
)
|
||||
const tariffElements = filteredTariffs
|
||||
.filter((tariff) => tariff.privileges.length > 0)
|
||||
.map((tariff, index) => {
|
||||
const { priceBeforeDiscounts, priceAfterDiscounts } = calcTariffPrice(
|
||||
tariff,
|
||||
discounts,
|
||||
2752015,
|
||||
user.wallet.spent,
|
||||
[],
|
||||
false,
|
||||
"661970ac059f40a30ab24c92",
|
||||
user.isUserNko,
|
||||
user.userId,
|
||||
);
|
||||
|
||||
return (
|
||||
|
Loading…
Reference in New Issue
Block a user