при применении ФЛ акк и кастомер акк не null
This commit is contained in:
parent
ce284ee0d4
commit
1a8fb106bc
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user