>
);
diff --git a/src/pages/Home/SubscriptionPlans.jsx b/src/pages/Home/SubscriptionPlans.jsx
index be94f5e0..3310ed43 100644
--- a/src/pages/Home/SubscriptionPlans.jsx
+++ b/src/pages/Home/SubscriptionPlans.jsx
@@ -125,8 +125,8 @@ const SubscriptionPlans = () => {
{/* Button */}
-
Subscribe
diff --git a/src/router/AppRoutes.jsx b/src/router/AppRoutes.jsx
index daf5210c..e3b8757a 100644
--- a/src/router/AppRoutes.jsx
+++ b/src/router/AppRoutes.jsx
@@ -72,11 +72,13 @@ const router = createBrowserRouter(
{ path: "/reset-password", element:
},
{ path: "/legal-info", element:
},
{ path: "/auth/changepassword", element:
},
-
],
},
{ path: "/auth/switch/org", element:
},
- { path: "/auth/subscripe/:frequency/:planName", element:
},
+ {
+ path: "/auth/subscripe/:frequency/:planId",
+ element:
,
+ },
{
element:
,
errorElement:
,
@@ -95,7 +97,10 @@ const router = createBrowserRouter(
{ path: "/directory", element:
},
{ path: "/inventory", element:
},
{ path: "/activities/attendance", element:
},
- { path: "/activities/records/:projectId?", element:
},
+ {
+ path: "/activities/records/:projectId?",
+ element:
,
+ },
{ path: "/activities/task", element:
},
{ path: "/activities/reports", element:
},
{ path: "/gallary", element:
},
diff --git a/src/slices/localVariablesSlice.jsx b/src/slices/localVariablesSlice.jsx
index c48b634b..fba4390c 100644
--- a/src/slices/localVariablesSlice.jsx
+++ b/src/slices/localVariablesSlice.jsx
@@ -31,6 +31,7 @@ const localVariablesSlice = createSlice({
AuthModal: {
isOpen: false,
},
+
selfTenant: {
tenantEnquireId: null,
planId: null,
@@ -106,12 +107,12 @@ const localVariablesSlice = createSlice({
setSelfTenant: (state, action) => {
state.selfTenant.tenantEnquireId =
action.payload.tenantEnquireId ?? state.selfTenant.tenantEnquireId;
- state.selfTenant.planId =
+ state.selfTenant.planId =
action.payload.planId ?? state.selfTenant.planId;
state.selfTenant.details =
action.payload.details ?? state.selfTenant.details;
- state.selfTenant.frequency = action.payload.frequency ?? state.selfTenant.frequency;
- state.selfTenant.paymentDetailId = action.payload.paymentDetailId ?? state.selfTenant.paymentDetailId;
+ state.selfTenant.frequency = action.payload.frequency ?? state.selfTenant.frequency;
+ state.selfTenant.paymentDetailId = action.payload.paymentDetailId ?? state.selfTenant.paymentDetailId;
},
},
});
@@ -127,6 +128,10 @@ export const {
toggleOrgModal,
openAuthModal,
closeAuthModal,
- setOrganization,openModal, closeModal, toggleModal , setSelfTenant
+ setOrganization,
+ openModal,
+ closeModal,
+ toggleModal,
+ setSelfTenant,
} = localVariablesSlice.actions;
export default localVariablesSlice.reducer;
diff --git a/src/utils/appUtils.js b/src/utils/appUtils.js
index d9514fe8..d6ec6e52 100644
--- a/src/utils/appUtils.js
+++ b/src/utils/appUtils.js
@@ -1,5 +1,5 @@
import { useEffect, useState } from "react";
-import { format, parseISO } from "date-fns";
+import { parseISO, formatISO } from "date-fns";
export const formatFileSize = (bytes) => {
if (bytes < 1024) return bytes + " B";
else if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(2) + " KB";
@@ -70,50 +70,50 @@ export const normalizeAllowedContentTypes = (allowedContentType) => {
return [];
};
export function localToUtc(dateString) {
-if (!dateString || typeof dateString !== "string") return null;
+ if (!dateString || typeof dateString !== "string") return null;
-const parts = dateString.trim().split("-");
-if (parts.length !== 3) return null;
+ const parts = dateString.trim().split("-");
+ if (parts.length !== 3) return null;
-let day, month, year;
+ let day, month, year;
-if (parts[0].length === 4) {
-// Format: yyyy-mm-dd
-[year, month, day] = parts;
-} else {
-// Format: dd-mm-yyyy
-[day, month, year] = parts;
+ if (parts[0].length === 4) {
+ // Format: yyyy-mm-dd
+ [year, month, day] = parts;
+ } else {
+ // Format: dd-mm-yyyy
+ [day, month, year] = parts;
+ }
+
+ if (!day || !month || !year) return null;
+
+ const date = new Date(
+ Date.UTC(Number(year), Number(month) - 1, Number(day), 0, 0, 0)
+ );
+ return isNaN(date.getTime()) ? null : date.toISOString();
}
-if (!day || !month || !year) return null;
+export const formatCurrency = (amount, currency = "INR", locale = "en-US") => {
+ return new Intl.NumberFormat(locale, {
+ style: "currency",
+ notation: "compact",
+ compactDisplay: "short",
+ currency: currency,
+ minimumFractionDigits: 0,
+ maximumFractionDigits: 2,
+ }).format(amount);
+};
-const date = new Date(
-Date.UTC(Number(year), Number(month) - 1, Number(day), 0, 0, 0)
-);
-return isNaN(date.getTime()) ? null : date.toISOString();
-}
-
-
-/**
- * Flexible number formatter for currency, numbers, or percentages.
- *
- * @param {number} amount - The value to format.
- * @param {Object} options - Formatting options.
- * @param {"currency"|"number"|"percent"} [options.type="number"] - Type of format.
- * @param {string} [options.currency="INR"] - Currency code (only used when type="currency").
- * @param {string} [options.locale="en-US"] - Locale for formatting.
- * @param {"short"|"long"|"standard"} [options.notation="compact"] - Display style for large numbers.
- * @param {number} [options.minimumFractionDigits=0] - Minimum decimal places.
- * @param {number} [options.maximumFractionDigits=2] - Maximum decimal places.
- * @returns {string} Formatted number string.
- */
+export const countDigit = (num) => {
+ return Math.abs(num).toString().length;
+};
export const formatFigure = (
amount,
{
type = "number",
currency = "INR",
locale = "en-US",
- notation = "standard", // standard or compact
+ notation = "standard", // standard or compact
compactDisplay = "short",
minimumFractionDigits = 0,
maximumFractionDigits = 2,
@@ -122,7 +122,12 @@ export const formatFigure = (
if (amount == null || isNaN(amount)) return "-";
const formatterOptions = {
- style: type === "currency" ? "currency" : type === "percent" ? "percent" : "decimal",
+ style:
+ type === "currency"
+ ? "currency"
+ : type === "percent"
+ ? "percent"
+ : "decimal",
notation: notation,
compactDisplay,
minimumFractionDigits,
@@ -135,18 +140,54 @@ export const formatFigure = (
return new Intl.NumberFormat(locale, formatterOptions).format(amount);
};
-export const frequencyLabel = (freq, isLong = false) => {
- const frequency = parseInt(freq, 10);
+
+export const frequencyLabel = (
+ freq,
+ isLong = false,
+ isMonthRequired = false
+) => {
+ const frequency = parseInt(freq, 10);
switch (frequency) {
case 0:
- return isLong ? "1 Month" : "1 mo";
+ if (isLong && isMonthRequired) {
+ return { planDurationInString: "1 Month", planDurationInInt: 1 };
+ }
+ if (isLong) {
+ return "1 Month";
+ } else {
+ return "1 mon";
+ }
case 1:
- return isLong ? "Quarterly (3 Months)" : "3 mo";
+ if (isLong && isMonthRequired) {
+ return {
+ planDurationInString: "Quarterly (3 Months)",
+ planDurationInInt: 3,
+ };
+ }
+ if (isLong) {
+ return "Quarterly (3 Months)";
+ } else {
+ return "3 mon";
+ }
case 2:
- return isLong ? "6 Months" : "6 mo";
+ if (isLong && isMonthRequired) {
+ return { planDurationInString: "6 Month", planDurationInInt: 6 };
+ }
+ if (isLong) {
+ return "6 Month";
+ } else {
+ return "6 mon";
+ }
case 3:
- return isLong ? "1 Year" : "1 yr";
+ if (isLong && isMonthRequired) {
+ return { planDurationInString: "1 Year", planDurationInInt: 12 };
+ }
+ if (isLong) {
+ return "1 Year";
+ } else {
+ return "1 yr";
+ }
default:
return isLong ? "Unknown" : "N/A";
}
-};
\ No newline at end of file
+};