{
Click to select or click here to browse
-
(PDF, JPG, PNG, max 5MB)
+
+ (PDF, JPG, PNG,Doc,docx,xls,xlsx max 5MB)
+
{
return { isOpen, onOpen, onClose, onToggle };
};
+export const useSubscription = (frequency) => {
+ return useQuery({
+ queryKey: ["subscriptionPlans", frequency],
+ queryFn: async () => {
+ debugger
+ const resp = await AuthRepository.getSubscription(frequency);
+ return resp.data;
+ },
+ });
+};
// -------------------APIHook-------------------------------------
@@ -85,8 +95,8 @@ export const useAuthModal = () => {
export const useLogout = () => {
const queryClient = useQueryClient();
- const naviget = useNavigate()
- const dispatch = useDispatch()
+ const naviget = useNavigate();
+ const dispatch = useDispatch();
return useMutation({
mutationFn: async () => {
@@ -99,12 +109,12 @@ export const useLogout = () => {
},
onSuccess: (data) => {
- queryClient.clear()
+ queryClient.clear();
removeSession();
- dispatch(cacheProfileData(null))
+ dispatch(cacheProfileData(null));
// window.location.href = "/auth/login";
- naviget("/auth/login",{replace:true})
+ naviget("/auth/login", { replace: true });
if (onSuccessCallBack) onSuccessCallBack();
},
diff --git a/src/pages/Home/LandingPage.jsx b/src/pages/Home/LandingPage.jsx
index 35b01202..d3288a9d 100644
--- a/src/pages/Home/LandingPage.jsx
+++ b/src/pages/Home/LandingPage.jsx
@@ -206,8 +206,8 @@ const LandingPage = () => {
navigation={false}
modules={[EffectFlip, Autoplay, Pagination, Navigation]}
className="mySwiper"
- onSlideChange={() => console.log("slide change")}
- onSwiper={(swiper) => console.log(swiper)}
+ onSlideChange={() => {}}
+ onSwiper={(swiper) => {}}
>
{
const [plans, setPlans] = useState([]);
const [frequency, setFrequency] = useState(1);
+ const { data, isLoading, isError, error } = useSubscription(frequency);
const [loading, setLoading] = useState(false);
- useEffect(() => {
- const fetchPlans = async () => {
- try {
- setLoading(true);
- const res = await axios.get(
- `http://localhost:5032/api/market/list/subscription-plan?frequency=${frequency}`,
- { headers: { "Content-Type": "application/json" } }
- );
- setPlans(res.data?.data || []);
- } catch (err) {
- console.error("Error fetching plans:", err);
- } finally {
- setLoading(false);
- }
- };
- fetchPlans();
- }, [frequency]);
+
const frequencyLabel = (freq) => {
switch (freq) {
- case 0: return "1 mo";
- case 1: return "3 mo";
- case 2: return "6 mo";
- case 3: return "1 yr";
- default: return "mo";
+ case 0:
+ return "1 mo";
+ case 1:
+ return "3 mo";
+ case 2:
+ return "6 mo";
+ case 3:
+ return "1 yr";
+ default:
+ return "mo";
}
};
@@ -41,38 +32,49 @@ const SubscriptionPlans = () => {
{/* Frequency Switcher */}
- {["Monthly", "Quarterly", "Half-Yearly", "Yearly"].map((label, idx) => (
-
- ))}
+ {["Monthly", "Quarterly", "Half-Yearly", "Yearly"].map(
+ (label, idx) => (
+
+ )
+ )}
{/* Cards */}
- {loading ? (
+ {isLoading ? (
// Show 3 skeletons
<>
>
- ) : plans.length === 0 ? (
+ ) : data.length === 0 ? (
No plans found
+ ) : isError ? (
+
+
{error.message}
+
{error.name}
+
) : (
- plans.map((plan) => (
+ data.map((plan) => (
{/* Header */}
-
{plan.planName}
+
+ {plan.planName}
+
{plan.description}
@@ -80,7 +82,9 @@ const SubscriptionPlans = () => {
{plan.currency?.symbol} {plan.price}
- / {frequencyLabel(frequency)}
+
+ / {frequencyLabel(frequency)}
+
@@ -133,7 +137,6 @@ const SubscriptionPlans = () => {
))
)}
-
);
};
diff --git a/src/pages/collections/CollectionPage.jsx b/src/pages/collections/CollectionPage.jsx
index 4e9eaf6a..ce802acf 100644
--- a/src/pages/collections/CollectionPage.jsx
+++ b/src/pages/collections/CollectionPage.jsx
@@ -181,7 +181,7 @@ const CollectionPage = () => {
handleMarkedPayment(processedPayment?.invoiceId)}
diff --git a/src/repositories/AuthRepository.jsx b/src/repositories/AuthRepository.jsx
index 700020fd..ba68946e 100644
--- a/src/repositories/AuthRepository.jsx
+++ b/src/repositories/AuthRepository.jsx
@@ -10,6 +10,7 @@ const AuthRepository = {
verifyOTP: (data) => api.postPublic("/api/auth/login-otp", data),
register: (data) => api.postPublic("/api/auth/register", data),
sendMail: (data) => api.postPublic("/api/auth/sendmail", data),
+ getSubscription:(frequency)=> api.getPublic(`/api/market/list/subscription-plan?frequency=${frequency}`),
// Protected routes (require auth token)
logout: (data) => api.post("/api/auth/logout", data),
@@ -17,7 +18,9 @@ const AuthRepository = {
changepassword: (data) => api.post("/api/auth/change-password", data),
appmenu: () => api.get('/api/appmenu/get/menu'),
selectTenant: (tenantId) => api.post(`/api/Auth/select-tenant/${tenantId}`),
- getTenantList: () => api.get("/api/Auth/get/user/tenants"),
+ getTenantList: () => api.get("/api/Auth/get/user/tenants"),
+
+ //
};
diff --git a/src/utils/axiosClient.jsx b/src/utils/axiosClient.jsx
index bf26500e..0f2f14a2 100644
--- a/src/utils/axiosClient.jsx
+++ b/src/utils/axiosClient.jsx
@@ -72,7 +72,9 @@ axiosClient.interceptors.response.use(
if (status === 401 && !isRefreshRequest) {
originalRequest._retry = true;
- const refreshToken = localStorage.getItem("refreshToken") || sessionStorage.getItem("refreshToken");
+ const refreshToken =
+ localStorage.getItem("refreshToken") ||
+ sessionStorage.getItem("refreshToken");
if (
!refreshToken ||
@@ -87,7 +89,9 @@ axiosClient.interceptors.response.use(
try {
// Refresh token call
const res = await axiosClient.post("/api/Auth/refresh-token", {
- token: localStorage.getItem("jwtToken") || sessionStorage.getItem("jwtToken"),
+ token:
+ localStorage.getItem("jwtToken") ||
+ sessionStorage.getItem("jwtToken"),
refreshToken,
});
@@ -144,6 +148,11 @@ export const api = {
headers: { ...customHeaders },
authRequired: false,
}),
+ getPublic: (url, data = {}, customHeaders = {}) =>
+ apiRequest("get", url, data, {
+ headers: { ...customHeaders },
+ authRequired: false,
+ }),
// Authenticated routes
get: (url, params = {}, customHeaders = {}) =>