Merge branch 'dev' into 'staging'

Dev

See merge request frontend/squiz!310
This commit is contained in:
Nastya 2024-05-11 18:38:51 +00:00
commit 9d93f0f159
2 changed files with 16 additions and 11 deletions

@ -283,8 +283,8 @@ export default function App() {
path={"/qaz"}
element={<LazyLoading children={<InfoPrivilege />} />}
/>
<Route path={"/image/:srcImage"} element={<ChatImageNewWindow />} />
<Route element={<PrivateRoute />}>
<Route path={"/image/:srcImage"} element={<ChatImageNewWindow />} />
{routeslink.map((e, i) => (
<Route
key={i}

@ -12,18 +12,20 @@ import { parseAxiosError } from "@utils/parse-error";
import type { Discount } from "@model/discounts";
export function CheckFastlink() {
const userId = useUserStore((state) => state.userId);
const user = useUserStore();
const [discounts, setDiscounts] = useState<Discount[]>([]);
const [askToChange, setAskToChange] = useState(false);
const [promocode, setPromocode] = useState("");
console.log(
user.userAccount,
user.customerAccount)
useEffect(() => {
const get = async () => {
if (!userId) {
if (!user.userId) {
return;
}
const [discounts] = await getDiscounts(userId);
const [discounts] = await getDiscounts(user.userId);
if (discounts?.length) {
setDiscounts(discounts);
@ -75,16 +77,19 @@ export function CheckFastlink() {
if (flLS !== null && flLS.length > 0) {
setPromocode(flLS);
if (userId !== null) {
if (user.userId !== null) {
//У нас есть промокод и юзер авторизован. Проверяем есть ли у него применённый промокод
if (discounts?.find((e) => e.Condition.User === userId)) {
setAskToChange(true);
} else {
fetchPromocode();
//Проверяем были ли запросы на аккаунт и кастомер аккаунт
if (user.userAccount !== null && user.customerAccount !== null) {
if (discounts?.find((e) => e.Condition.User === user.userId)) {
setAskToChange(true);
} else {
fetchPromocode();
}
}
}
}
}, [userId, discounts]);
}, [user.userId, discounts]);
return (
<Modal