Merge branch 'main' into update-multi-attach

This commit is contained in:
John Yeo
2025-09-05 13:41:17 -07:00
2 changed files with 13 additions and 3 deletions

View File

@@ -54,5 +54,13 @@ export const getAttachScenario = ({
prices2: fullProduct.prices,
});
if (
!isUpgrade &&
!isFreeProduct(curFullProduct.prices) &&
isFreeProduct(fullProduct.prices)
) {
return AttachScenario.Cancel;
}
return isUpgrade ? AttachScenario.Upgrade : AttachScenario.Downgrade;
};

View File

@@ -18,10 +18,11 @@ import { useProductsContext } from "../../ProductsContext";
import { RewardService } from "@/services/products/RewardService";
import { RewardConfig } from "./RewardConfig";
import { defaultReward } from "../utils/defaultRewardModels";
import { useRewardsQuery } from "@/hooks/queries/useRewardsQuery";
function CreateReward() {
const { mutate, env } = useProductsContext();
const axiosInstance = useAxiosInstance({ env: env });
const axiosInstance = useAxiosInstance();
const { refetch } = useRewardsQuery();
const [isLoading, setIsLoading] = useState(false);
const [open, setOpen] = useState(false);
@@ -42,9 +43,10 @@ function CreateReward() {
data: reward,
});
await mutate();
await refetch();
setOpen(false);
} catch (error) {
console.log("Error:", error);
toast.error(getBackendErr(error, "Failed to create coupon"));
}
setIsLoading(false);