Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,11 @@ export default tseslint.config(
},
rules: {
...reactHooks.configs.recommended.rules,
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
"react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-unused-vars": [
"error",
{ "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" }
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
],
},
},
Expand Down
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default defineConfig({

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: "on-first-retry",

/* Disable video/screenshots by default for speed, can be enabled on retry */
screenshot: "only-on-failure",
},
Expand Down
38 changes: 38 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/config/sidebar.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const sidebarItems = [
},
{
title: "Teams",
path: "/org/teams",
path: "/member/teams",
icon: Users,
},
{
Expand Down
4 changes: 3 additions & 1 deletion src/features/Auth/v1/Pages/LoginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ const LoginPage = () => {
password,
});

const Role = response.data.role;
console.log("Login successful: come from login page --->", response);

const Role = response.data.FindUser.role;

if (Role === "organization") {
navigate("/org/dashboard");
Expand Down
1 change: 0 additions & 1 deletion src/features/Auth/v1/Store/Organization.Store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { create } from "zustand";
import { persist } from "zustand/middleware";
import { CommunitySchema } from "../Types/Organization.Type";


const useOrganizationStore = create<{
organization: CommunitySchema | null;
setOrganization: (organization: CommunitySchema) => void;
Expand Down
24 changes: 10 additions & 14 deletions src/features/Auth/v1/hooks/useAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import AUTH_ENDPOINTS from "../Constant/Auth.Endpoint.Constant";
import useAuthStore from "../Store/Auth.Store";
import useOrganizationStore from "../Store/Organization.Store";

const baseUrl =
import.meta.env.VITE_API_BASE_URL || "http://localhost:8000/api/v1";
import usePermissionStore from "@/features/Permission/Store/Permission.Store";

const baseUrl = import.meta.env.VITE_API_BASE_URL || "http://localhost:8000/api/v1";

// =========================
// GET ORGANIZATION
Expand All @@ -18,13 +19,14 @@ const useGetOrganizationMutation = () => {

mutationFn: async (_id: string) => {
const response = await api.get(
`${baseUrl}${AUTH_ENDPOINTS.GET_ORGANIZATION_BY_ID}?ownerId=${_id}`
`${baseUrl}${AUTH_ENDPOINTS.GET_ORGANIZATION_BY_ID}?ownerId=${_id}`,
);

return response.data;
},

onSuccess: (response) => {
console.log("Organization fetched successfully:", response.data);
useOrganizationStore.getState().setOrganization(response.data);
},

Expand All @@ -44,23 +46,17 @@ const useLoginMutation = () => {
return useMutation({
mutationKey: ["login"],

mutationFn: async (credentials: {
email: string;
password: string;
}) => {
const response = await api.post(
`${baseUrl}${AUTH_ENDPOINTS.LOGIN}`,
credentials
);
mutationFn: async (credentials: { email: string; password: string }) => {
const response = await api.post(`${baseUrl}${AUTH_ENDPOINTS.LOGIN}`, credentials);

return response.data;
},

onSuccess: async (response) => {
const user = response.data;
const user = response.data.FindUser;
const token = response.token;

console.log("Login successful:", user);
usePermissionStore.getState().setPermissions(response.data.perms);

// Save auth first
useAuthStore.getState().setAuthData(user, token);
Expand All @@ -87,4 +83,4 @@ export const useAuth = () => {
return {
loginMutation,
};
};
};
5 changes: 4 additions & 1 deletion src/features/Billing/v1/components/analytics/UsageCharts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ export default function UsageCharts() {
<div
key={i}
className="h-64 rounded-2xl border animate-pulse"
style={{ backgroundColor: "var(--cd-surface-2)", borderColor: "var(--cd-border-subtle)" }}
style={{
backgroundColor: "var(--cd-surface-2)",
borderColor: "var(--cd-border-subtle)",
}}
/>
))}
</div>
Expand Down
95 changes: 77 additions & 18 deletions src/features/Billing/v1/components/layout/AddFundsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ import {
} from "lucide-react";
import { MIN_ADD_RUPEES } from "../../constants/billing.constants";
import { useAddFunds } from "../../hooks/useWallet";
import { buildAddFundsPreview, formatCredits, formatRupees, validateMinAddFunds } from "../../utils/credits";
import {
buildAddFundsPreview,
formatCredits,
formatRupees,
validateMinAddFunds,
} from "../../utils/credits";
import type { AddFundsPayload, PaymentState } from "../../Billing.types";
import Input from "@/Component/ui/Input";

Expand Down Expand Up @@ -118,10 +123,17 @@ export default function AddFundsModal({ isOpen, onClose, onSuccess, onError }: P
}}
>
<div className="pr-10">
<p className="text-xs font-black uppercase tracking-wide" style={{ color: "var(--cd-primary)" }}>
<p
className="text-xs font-black uppercase tracking-wide"
style={{ color: "var(--cd-primary)" }}
>
Community wallet
</p>
<h2 id="add-funds-modal-title" className="mt-1 text-2xl font-black" style={{ color: "var(--cd-text)" }}>
<h2
id="add-funds-modal-title"
className="mt-1 text-2xl font-black"
style={{ color: "var(--cd-text)" }}
>
Add Funds
</h2>
<p className="mt-1 text-sm" style={{ color: "var(--cd-text-muted)" }}>
Expand All @@ -141,7 +153,7 @@ export default function AddFundsModal({ isOpen, onClose, onSuccess, onError }: P
setAmountStr(digitsOnly.replace(/^0+(?=\d)/, ""));
}}
leftIcon={<Banknote size={18} />}
error={validation.valid ? undefined : validation.error ?? undefined}
error={validation.valid ? undefined : (validation.error ?? undefined)}
className="w-full !mb-0"
inputClassName="!text-lg !font-bold"
/>
Expand All @@ -151,14 +163,26 @@ export default function AddFundsModal({ isOpen, onClose, onSuccess, onError }: P
<SectionTitle title="Credit calculator" />
<div
className="grid gap-3 rounded-xl border p-4 sm:grid-cols-3"
style={{ backgroundColor: "var(--cd-bg)", borderColor: "var(--cd-border-subtle)" }}
style={{
backgroundColor: "var(--cd-bg)",
borderColor: "var(--cd-border-subtle)",
}}
>
<GeneratedCreditTile label="Base credits" value={formatCredits(preview.baseCredits)} />
<GeneratedCreditTile
label="Base credits"
value={formatCredits(preview.baseCredits)}
/>
<GeneratedCreditTile
label="Bonus credits"
value={preview.bonusCredits > 0 ? `+${formatCredits(preview.bonusCredits)}` : "0"}
value={
preview.bonusCredits > 0 ? `+${formatCredits(preview.bonusCredits)}` : "0"
}
/>
<GeneratedCreditTile
label="Total credits"
value={formatCredits(preview.totalCredits)}
accent
/>
<GeneratedCreditTile label="Total credits" value={formatCredits(preview.totalCredits)} accent />
</div>
</section>

Expand Down Expand Up @@ -195,23 +219,42 @@ export default function AddFundsModal({ isOpen, onClose, onSuccess, onError }: P
<SectionTitle title="Pay details" />
<div
className="mt-3 rounded-xl border p-4"
style={{ backgroundColor: "var(--cd-surface)", borderColor: "var(--cd-border-subtle)" }}
style={{
backgroundColor: "var(--cd-surface)",
borderColor: "var(--cd-border-subtle)",
}}
>
<div className="space-y-3 text-sm">
<SummaryRow label="Wallet amount" value={formatRupees(preview.amountRupees)} />
<SummaryRow label="GST (18%)" value={formatRupees(preview.gstRupees)} />
<SummaryRow label="Platform fee" value={formatRupees(preview.platformFeeRupees)} />
<SummaryRow
label="Platform fee"
value={formatRupees(preview.platformFeeRupees)}
/>
<SummaryRow label="Base credits" value={formatCredits(preview.baseCredits)} />
{preview.bonusCredits > 0 ? (
<SummaryRow label="Bonus credits" value={`+${formatCredits(preview.bonusCredits)}`} accent />
<SummaryRow
label="Bonus credits"
value={`+${formatCredits(preview.bonusCredits)}`}
accent
/>
) : null}
</div>
<div
className="mt-4 border-t pt-4"
style={{ borderColor: "var(--cd-border-subtle)" }}
>
<SummaryRow label="Credits added" value={formatCredits(preview.totalCredits)} accent strong />
<SummaryRow label="Total payable" value={formatRupees(preview.totalPayableRupees)} strong />
<SummaryRow
label="Credits added"
value={formatCredits(preview.totalCredits)}
accent
strong
/>
<SummaryRow
label="Total payable"
value={formatRupees(preview.totalPayableRupees)}
strong
/>
</div>
</div>

Expand Down Expand Up @@ -243,7 +286,10 @@ export default function AddFundsModal({ isOpen, onClose, onSuccess, onError }: P
)}
</button>

<div className="mt-3 flex items-center justify-center gap-2 text-xs" style={{ color: "var(--cd-text-muted)" }}>
<div
className="mt-3 flex items-center justify-center gap-2 text-xs"
style={{ color: "var(--cd-text-muted)" }}
>
<ShieldCheck size={14} style={{ color: "var(--cd-success)" }} />
Encrypted payment simulation
</div>
Expand All @@ -257,7 +303,10 @@ export default function AddFundsModal({ isOpen, onClose, onSuccess, onError }: P

function SectionTitle({ title }: { title: string }) {
return (
<h3 className="mb-3 text-sm font-black uppercase tracking-wide" style={{ color: "var(--cd-text)" }}>
<h3
className="mb-3 text-sm font-black uppercase tracking-wide"
style={{ color: "var(--cd-text)" }}
>
{title}
</h3>
);
Expand All @@ -280,10 +329,16 @@ function GeneratedCreditTile({
borderColor: accent ? "var(--cd-primary)" : "var(--cd-border-subtle)",
}}
>
<span className="text-xs font-bold uppercase tracking-wide" style={{ color: "var(--cd-text-muted)" }}>
<span
className="text-xs font-bold uppercase tracking-wide"
style={{ color: "var(--cd-text-muted)" }}
>
{label}
</span>
<span className="mt-3 block text-2xl font-black" style={{ color: accent ? "var(--cd-primary)" : "var(--cd-text)" }}>
<span
className="mt-3 block text-2xl font-black"
style={{ color: accent ? "var(--cd-primary)" : "var(--cd-text)" }}
>
{value}
</span>
</div>
Expand Down Expand Up @@ -328,7 +383,11 @@ function SuccessContent({ credits, onClose }: { credits: number; onClose: () =>
<p className="mt-2 text-sm" style={{ color: "var(--cd-text-muted)" }}>
{formatCredits(credits)} credits have been added to your wallet.
</p>
<button type="button" onClick={onClose} className="cd-btn cd-btn-primary mt-8 rounded-xl px-8 py-2.5">
<button
type="button"
onClick={onClose}
className="cd-btn cd-btn-primary mt-8 rounded-xl px-8 py-2.5"
>
Done
</button>
</div>
Expand Down
Loading
Loading