tr]:last:border-b-0",
+ 'border-t bg-muted/50 font-medium [&>tr]:last:border-b-0',
className
)}
{...props}
/>
-))
-TableFooter.displayName = "TableFooter"
+));
+TableFooter.displayName = 'TableFooter';
const TableRow = React.forwardRef<
HTMLTableRowElement,
@@ -58,13 +58,13 @@ const TableRow = React.forwardRef<
-))
-TableRow.displayName = "TableRow"
+));
+TableRow.displayName = 'TableRow';
const TableHead = React.forwardRef<
HTMLTableCellElement,
@@ -73,13 +73,13 @@ const TableHead = React.forwardRef<
[role=checkbox]]:translate-y-[2px]",
+ 'h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]',
className
)}
{...props}
/>
-))
-TableHead.displayName = "TableHead"
+));
+TableHead.displayName = 'TableHead';
const TableCell = React.forwardRef<
HTMLTableCellElement,
@@ -88,13 +88,13 @@ const TableCell = React.forwardRef<
| [role=checkbox]]:translate-y-[2px]",
+ 'p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]',
className
)}
{...props}
/>
-))
-TableCell.displayName = "TableCell"
+));
+TableCell.displayName = 'TableCell';
const TableCaption = React.forwardRef<
HTMLTableCaptionElement,
@@ -102,11 +102,11 @@ const TableCaption = React.forwardRef<
>(({ className, ...props }, ref) => (
-))
-TableCaption.displayName = "TableCaption"
+));
+TableCaption.displayName = 'TableCaption';
export {
Table,
@@ -117,4 +117,4 @@ export {
TableRow,
TableCell,
TableCaption,
-}
+};
diff --git a/src/components/ui/tabs.tsx b/src/components/ui/tabs.tsx
index 0f4caeb..d19d7ea 100644
--- a/src/components/ui/tabs.tsx
+++ b/src/components/ui/tabs.tsx
@@ -1,11 +1,11 @@
-"use client"
+'use client';
-import * as React from "react"
-import * as TabsPrimitive from "@radix-ui/react-tabs"
+import * as React from 'react';
+import * as TabsPrimitive from '@radix-ui/react-tabs';
-import { cn } from "@/lib/utils"
+import { cn } from '@/lib/utils';
-const Tabs = TabsPrimitive.Root
+const Tabs = TabsPrimitive.Root;
const TabsList = React.forwardRef<
React.ElementRef,
@@ -14,13 +14,13 @@ const TabsList = React.forwardRef<
-))
-TabsList.displayName = TabsPrimitive.List.displayName
+));
+TabsList.displayName = TabsPrimitive.List.displayName;
const TabsTrigger = React.forwardRef<
React.ElementRef,
@@ -29,13 +29,13 @@ const TabsTrigger = React.forwardRef<
-))
-TabsTrigger.displayName = TabsPrimitive.Trigger.displayName
+));
+TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
const TabsContent = React.forwardRef<
React.ElementRef,
@@ -44,12 +44,12 @@ const TabsContent = React.forwardRef<
-))
-TabsContent.displayName = TabsPrimitive.Content.displayName
+));
+TabsContent.displayName = TabsPrimitive.Content.displayName;
-export { Tabs, TabsList, TabsTrigger, TabsContent }
+export { Tabs, TabsList, TabsTrigger, TabsContent };
diff --git a/src/helpers/firebase/auth.ts b/src/helpers/firebase/auth.ts
index b3e9681..fd9f4f0 100644
--- a/src/helpers/firebase/auth.ts
+++ b/src/helpers/firebase/auth.ts
@@ -7,8 +7,8 @@ import {
signOut,
User,
getIdToken,
-} from "firebase/auth";
-import firebaseApp from ".";
+} from 'firebase/auth';
+import firebaseApp from '.';
const auth = getAuth(firebaseApp);
@@ -19,7 +19,7 @@ export const signInWithGoogle = () =>
.then((result) => {
const credential = GoogleAuthProvider.credentialFromResult(result);
if (!credential) {
- throw new Error("No credential");
+ throw new Error('No credential');
}
return result.user;
})
@@ -35,7 +35,7 @@ export const signOutUser = () => signOut(auth);
export const getCurrentUser = () => {
if (!auth.currentUser) {
- throw new Error("No user");
+ throw new Error('No user');
}
return auth.currentUser;
};
diff --git a/src/lib/utils.ts b/src/lib/utils.ts
index bd0c391..2819a83 100644
--- a/src/lib/utils.ts
+++ b/src/lib/utils.ts
@@ -1,6 +1,6 @@
-import { clsx, type ClassValue } from "clsx"
-import { twMerge } from "tailwind-merge"
+import { clsx, type ClassValue } from 'clsx';
+import { twMerge } from 'tailwind-merge';
export function cn(...inputs: ClassValue[]) {
- return twMerge(clsx(inputs))
+ return twMerge(clsx(inputs));
}
diff --git a/src/server/firebase-admin/auth.ts b/src/server/firebase-admin/auth.ts
index 2406741..69faede 100644
--- a/src/server/firebase-admin/auth.ts
+++ b/src/server/firebase-admin/auth.ts
@@ -1,5 +1,5 @@
-import { getAuth } from "firebase-admin/auth";
-import { firebaseAdmin } from ".";
+import { getAuth } from 'firebase-admin/auth';
+import { firebaseAdmin } from '.';
const auth = getAuth(firebaseAdmin);
diff --git a/src/server/firebase-admin/database.ts b/src/server/firebase-admin/database.ts
index afe4829..df3921c 100644
--- a/src/server/firebase-admin/database.ts
+++ b/src/server/firebase-admin/database.ts
@@ -1,7 +1,7 @@
-import { getDatabase, Query } from "firebase-admin/database";
-import { firebaseAdmin } from ".";
-import { UserRecord } from "firebase-admin/auth";
-import { TFetch } from "@/types/database";
+import { getDatabase, Query } from 'firebase-admin/database';
+import { firebaseAdmin } from '.';
+import { UserRecord } from 'firebase-admin/auth';
+import { TFetch } from '@/types/database';
const database = getDatabase(firebaseAdmin);
@@ -27,7 +27,7 @@ export const fetch = async ({ relPath, user, ...filters }: TFetch) => {
query = query.limitToLast(filters.limitToLast);
}
- const snapshot = await query.once("value");
+ const snapshot = await query.once('value');
return snapshot.exists() ? snapshot.val() : undefined;
};
diff --git a/src/server/routers/card-router.ts b/src/server/routers/card-router.ts
index b04eeca..084434c 100644
--- a/src/server/routers/card-router.ts
+++ b/src/server/routers/card-router.ts
@@ -1,7 +1,7 @@
-import { CardDataRecordSchema, CardDataSchema } from "@/types/card";
-import { addCard, getAllCards } from "../services/card-service";
-import { protectedProcedure } from "./procedures";
-import { t } from "./trpc";
+import { CardDataRecordSchema, CardDataSchema } from '@/types/card';
+import { addCard, getAllCards } from '../services/card-service';
+import { protectedProcedure } from './procedures';
+import { t } from './trpc';
const cardRouter = t.router({
getAll: protectedProcedure
diff --git a/src/server/routers/procedures.ts b/src/server/routers/procedures.ts
index 603c1c6..792d947 100644
--- a/src/server/routers/procedures.ts
+++ b/src/server/routers/procedures.ts
@@ -1,5 +1,5 @@
-import { TRPCError } from "@trpc/server";
-import { t } from "./trpc";
+import { TRPCError } from '@trpc/server';
+import { t } from './trpc';
const verifyAuthMiddleware = t.middleware(async (opts) => {
const { ctx } = opts;
@@ -7,20 +7,20 @@ const verifyAuthMiddleware = t.middleware(async (opts) => {
if (!user) {
throw new TRPCError({
- code: "UNAUTHORIZED",
- message: "Authentication token not found",
+ code: 'UNAUTHORIZED',
+ message: 'Authentication token not found',
});
}
if (user.disabled) {
throw new TRPCError({
- code: "FORBIDDEN",
- message: "User is disabled",
+ code: 'FORBIDDEN',
+ message: 'User is disabled',
});
}
if (!user.emailVerified) {
throw new TRPCError({
- code: "FORBIDDEN",
- message: "User email is unverified",
+ code: 'FORBIDDEN',
+ message: 'User email is unverified',
});
}
diff --git a/src/server/routers/root-router.ts b/src/server/routers/root-router.ts
index 6cbf0df..d961ad4 100644
--- a/src/server/routers/root-router.ts
+++ b/src/server/routers/root-router.ts
@@ -1,6 +1,6 @@
-import cardRouter from "./card-router";
-import transactionRouter from "./transaction-router";
-import { t } from "./trpc";
+import cardRouter from './card-router';
+import transactionRouter from './transaction-router';
+import { t } from './trpc';
export const rootRouter = t.router({
card: cardRouter,
diff --git a/src/server/routers/transaction-router.ts b/src/server/routers/transaction-router.ts
index dd74062..bdf832a 100644
--- a/src/server/routers/transaction-router.ts
+++ b/src/server/routers/transaction-router.ts
@@ -1,15 +1,15 @@
import {
CardTransactionFormSchema,
CardTransactionRecordSchema,
-} from "@/types/card";
-import { z } from "zod";
-import { protectedProcedure } from "./procedures";
-import { t } from "./trpc";
+} from '@/types/card';
+import { z } from 'zod';
+import { protectedProcedure } from './procedures';
+import { t } from './trpc';
import {
getPaginatedTransactions,
getTransactionsByMonthYear,
saveTransaction,
-} from "../services/transaction-service";
+} from '../services/transaction-service';
const transactionRouter = t.router({
getByMonthYear: protectedProcedure
diff --git a/src/server/routers/trpc.ts b/src/server/routers/trpc.ts
index c0a3efd..a8a6a4e 100644
--- a/src/server/routers/trpc.ts
+++ b/src/server/routers/trpc.ts
@@ -1,9 +1,9 @@
-import { TRPCError, initTRPC } from "@trpc/server";
-import { getFirebaseUser, verifyAuthToken } from "../firebase-admin/auth";
-import { ITRPCContext } from "@/types/trpc";
+import { TRPCError, initTRPC } from '@trpc/server';
+import { getFirebaseUser, verifyAuthToken } from '../firebase-admin/auth';
+import { ITRPCContext } from '@/types/trpc';
const getAuthBearer = (req: Request) =>
- req.headers.get("authorization")?.split?.("Bearer ")?.[1];
+ req.headers.get('authorization')?.split?.('Bearer ')?.[1];
const getLoggedInUser = async (idToken: string | undefined) => {
if (!idToken) {
@@ -13,10 +13,10 @@ const getLoggedInUser = async (idToken: string | undefined) => {
const { uid } = await verifyAuthToken(idToken, true);
return await getFirebaseUser(uid);
} catch (error) {
- console.error("Error in getLoggedInUser: ", error);
+ console.error('Error in getLoggedInUser:', error);
throw new TRPCError({
- code: "UNAUTHORIZED",
- message: "Firebase authorization failed",
+ code: 'UNAUTHORIZED',
+ message: 'Firebase authorization failed',
});
}
};
diff --git a/src/server/services/card-service.ts b/src/server/services/card-service.ts
index 2a5c6fc..718dd70 100644
--- a/src/server/services/card-service.ts
+++ b/src/server/services/card-service.ts
@@ -1,7 +1,7 @@
-import { DB_PATHS } from "@/types/database";
-import { UserRecord } from "firebase-admin/auth";
-import { appendToList, fetch } from "../firebase-admin/database";
-import { TCardData } from "@/types/card";
+import { DB_PATHS } from '@/types/database';
+import { UserRecord } from 'firebase-admin/auth';
+import { appendToList, fetch } from '../firebase-admin/database';
+import { TCardData } from '@/types/card';
export const getAllCards = async (user: UserRecord) => {
return fetch({ relPath: DB_PATHS.CARDS, user });
diff --git a/src/server/services/transaction-service.ts b/src/server/services/transaction-service.ts
index adfb680..726bb58 100644
--- a/src/server/services/transaction-service.ts
+++ b/src/server/services/transaction-service.ts
@@ -1,8 +1,8 @@
-import { TCardTransaction, TCardTransactionForm } from "@/types/card";
-import { DB_PATHS } from "@/types/database";
-import { TRPCError } from "@trpc/server";
-import { UserRecord } from "firebase-admin/auth";
-import { appendToList, fetch } from "../firebase-admin/database";
+import { TCardTransaction, TCardTransactionForm } from '@/types/card';
+import { DB_PATHS } from '@/types/database';
+import { TRPCError } from '@trpc/server';
+import { UserRecord } from 'firebase-admin/auth';
+import { appendToList, fetch } from '../firebase-admin/database';
const getShortKey = (month: number, year: number) => `${year}-${month}`;
@@ -17,7 +17,7 @@ export const getTransactionsByMonthYear = async (
const transactions = await fetch({
relPath: DB_PATHS.TRANSACTIONS,
user,
- orderByChild: "__shortKey",
+ orderByChild: '__shortKey',
equalTo: getShortKey(month, year),
});
return transactions ?? {};
@@ -30,7 +30,7 @@ export const getPaginatedTransactions = async (
return fetch({
relPath: DB_PATHS.TRANSACTIONS,
user,
- orderByChild: "date",
+ orderByChild: 'date',
endBefore: cursor,
limitToLast: 5,
});
@@ -48,14 +48,14 @@ export const saveTransaction = async (
const sameMonthTransaction = await fetch({
user,
relPath: DB_PATHS.TRANSACTIONS,
- orderByChild: "__fullKey",
+ orderByChild: '__fullKey',
equalTo: fullKey,
limitToFirst: 1,
});
if (sameMonthTransaction) {
throw new TRPCError({
- code: "BAD_REQUEST",
- message: "Transaction already exists for this month",
+ code: 'BAD_REQUEST',
+ message: 'Transaction already exists for this month',
});
}
diff --git a/src/trpc-client/api.ts b/src/trpc-client/api.ts
index ca03f8d..8bd7af4 100644
--- a/src/trpc-client/api.ts
+++ b/src/trpc-client/api.ts
@@ -5,6 +5,7 @@ import { httpBatchLink, loggerLink } from '@trpc/client';
import { createTRPCReact } from '@trpc/react-query';
const getBaseUrl = () => {
+ // eslint-disable-next-line unicorn/prefer-global-this
if (typeof window !== 'undefined') {
return '';
}
diff --git a/src/types/card.ts b/src/types/card.ts
index 8d014d3..96309cc 100644
--- a/src/types/card.ts
+++ b/src/types/card.ts
@@ -1,15 +1,15 @@
-import { z } from "zod";
+import { z } from 'zod';
export const CardBrandEnum = z.enum([
- "icici",
- "hdfc",
- "sbi",
- "kotak",
- "axis",
- "indusind",
- "hsbc",
- "niyo",
- "onecard",
+ 'icici',
+ 'hdfc',
+ 'sbi',
+ 'kotak',
+ 'axis',
+ 'indusind',
+ 'hsbc',
+ 'niyo',
+ 'onecard',
]);
export type TCardBrand = z.infer;
diff --git a/src/types/database.ts b/src/types/database.ts
index e66196c..9be05c3 100644
--- a/src/types/database.ts
+++ b/src/types/database.ts
@@ -1,9 +1,9 @@
-import { UserRecord } from "firebase-admin/auth";
-import { TCardData, TCardTransaction } from "./card";
+import { UserRecord } from 'firebase-admin/auth';
+import { TCardData, TCardTransaction } from './card';
export enum DB_PATHS {
- CARDS = "cards",
- TRANSACTIONS = "transactions",
+ CARDS = 'cards',
+ TRANSACTIONS = 'transactions',
}
type TFetchCard = {
diff --git a/src/types/trpc.ts b/src/types/trpc.ts
index f64afff..e99e503 100644
--- a/src/types/trpc.ts
+++ b/src/types/trpc.ts
@@ -1,4 +1,4 @@
-import { UserRecord } from "firebase-admin/auth";
+import { UserRecord } from 'firebase-admin/auth';
export interface ITRPCContext {
user: UserRecord | null;
diff --git a/tailwind.config.ts b/tailwind.config.ts
index 9710302..cb82a9e 100644
--- a/tailwind.config.ts
+++ b/tailwind.config.ts
@@ -1,73 +1,73 @@
-import type { Config } from "tailwindcss";
+import type { Config } from 'tailwindcss';
const config: Config = {
- darkMode: ["class"],
+ darkMode: ['class'],
content: [
- "./src/pages/**/*.{js,ts,jsx,tsx,mdx}",
- "./src/components/**/*.{js,ts,jsx,tsx,mdx}",
- "./src/app/**/*.{js,ts,jsx,tsx,mdx}",
+ './src/pages/**/*.{js,ts,jsx,tsx,mdx}',
+ './src/components/**/*.{js,ts,jsx,tsx,mdx}',
+ './src/app/**/*.{js,ts,jsx,tsx,mdx}',
],
theme: {
container: {
center: true,
padding: {
- DEFAULT: "1rem",
- sm: "2rem",
- lg: "4rem",
- xl: "5rem",
- "2xl": "6rem",
+ DEFAULT: '1rem',
+ sm: '2rem',
+ lg: '4rem',
+ xl: '5rem',
+ '2xl': '6rem',
},
},
extend: {
colors: {
- background: "hsl(var(--background))",
- foreground: "hsl(var(--foreground))",
+ background: 'hsl(var(--background))',
+ foreground: 'hsl(var(--foreground))',
card: {
- DEFAULT: "hsl(var(--card))",
- foreground: "hsl(var(--card-foreground))",
+ DEFAULT: 'hsl(var(--card))',
+ foreground: 'hsl(var(--card-foreground))',
},
popover: {
- DEFAULT: "hsl(var(--popover))",
- foreground: "hsl(var(--popover-foreground))",
+ DEFAULT: 'hsl(var(--popover))',
+ foreground: 'hsl(var(--popover-foreground))',
},
primary: {
- DEFAULT: "hsl(var(--primary))",
- foreground: "hsl(var(--primary-foreground))",
+ DEFAULT: 'hsl(var(--primary))',
+ foreground: 'hsl(var(--primary-foreground))',
},
secondary: {
- DEFAULT: "hsl(var(--secondary))",
- foreground: "hsl(var(--secondary-foreground))",
+ DEFAULT: 'hsl(var(--secondary))',
+ foreground: 'hsl(var(--secondary-foreground))',
},
muted: {
- DEFAULT: "hsl(var(--muted))",
- foreground: "hsl(var(--muted-foreground))",
+ DEFAULT: 'hsl(var(--muted))',
+ foreground: 'hsl(var(--muted-foreground))',
},
accent: {
- DEFAULT: "hsl(var(--accent))",
- foreground: "hsl(var(--accent-foreground))",
+ DEFAULT: 'hsl(var(--accent))',
+ foreground: 'hsl(var(--accent-foreground))',
},
destructive: {
- DEFAULT: "hsl(var(--destructive))",
- foreground: "hsl(var(--destructive-foreground))",
+ DEFAULT: 'hsl(var(--destructive))',
+ foreground: 'hsl(var(--destructive-foreground))',
},
- border: "hsl(var(--border))",
- input: "hsl(var(--input))",
- ring: "hsl(var(--ring))",
+ border: 'hsl(var(--border))',
+ input: 'hsl(var(--input))',
+ ring: 'hsl(var(--ring))',
chart: {
- "1": "hsl(var(--chart-1))",
- "2": "hsl(var(--chart-2))",
- "3": "hsl(var(--chart-3))",
- "4": "hsl(var(--chart-4))",
- "5": "hsl(var(--chart-5))",
+ '1': 'hsl(var(--chart-1))',
+ '2': 'hsl(var(--chart-2))',
+ '3': 'hsl(var(--chart-3))',
+ '4': 'hsl(var(--chart-4))',
+ '5': 'hsl(var(--chart-5))',
},
},
borderRadius: {
- lg: "var(--radius)",
- md: "calc(var(--radius) - 2px)",
- sm: "calc(var(--radius) - 4px)",
+ lg: 'var(--radius)',
+ md: 'calc(var(--radius) - 2px)',
+ sm: 'calc(var(--radius) - 4px)',
},
},
},
- plugins: [require("tailwindcss-animate")],
+ plugins: [require('tailwindcss-animate')],
};
export default config;
|