refactor: migrate from ESLint to Biome and extract SQL queries to data.ts
- Replace ESLint with Biome for linting and formatting - Configure Biome with tabs, double quotes, and organized imports - Move all SQL/Drizzle queries from page.tsx files to data.ts files - Create new data.ts files for: ajustes, dashboard, relatorios/categorias - Update existing data.ts files: extrato, fatura (add lancamentos queries) - Remove all drizzle-orm imports from page.tsx files - Update README.md with new tooling info Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,58 +1,57 @@
|
||||
"use client";
|
||||
|
||||
import React, { createContext, useContext, useEffect, useState } from "react";
|
||||
import type React from "react";
|
||||
import { createContext, useContext, useEffect, useState } from "react";
|
||||
|
||||
interface PrivacyContextType {
|
||||
privacyMode: boolean;
|
||||
toggle: () => void;
|
||||
set: (value: boolean) => void;
|
||||
privacyMode: boolean;
|
||||
toggle: () => void;
|
||||
set: (value: boolean) => void;
|
||||
}
|
||||
|
||||
const PrivacyContext = createContext<PrivacyContextType | undefined>(
|
||||
undefined
|
||||
);
|
||||
const PrivacyContext = createContext<PrivacyContextType | undefined>(undefined);
|
||||
|
||||
const STORAGE_KEY = "app:privacyMode";
|
||||
|
||||
export function PrivacyProvider({ children }: { children: React.ReactNode }) {
|
||||
const [privacyMode, setPrivacyMode] = useState(false);
|
||||
const [hydrated, setHydrated] = useState(false);
|
||||
const [privacyMode, setPrivacyMode] = useState(false);
|
||||
const [hydrated, setHydrated] = useState(false);
|
||||
|
||||
// Sincronizar com localStorage na montagem (evitar mismatch SSR/CSR)
|
||||
useEffect(() => {
|
||||
const stored = localStorage.getItem(STORAGE_KEY);
|
||||
if (stored !== null) {
|
||||
setPrivacyMode(stored === "true");
|
||||
}
|
||||
setHydrated(true);
|
||||
}, []);
|
||||
// Sincronizar com localStorage na montagem (evitar mismatch SSR/CSR)
|
||||
useEffect(() => {
|
||||
const stored = localStorage.getItem(STORAGE_KEY);
|
||||
if (stored !== null) {
|
||||
setPrivacyMode(stored === "true");
|
||||
}
|
||||
setHydrated(true);
|
||||
}, []);
|
||||
|
||||
// Persistir mudanças no localStorage
|
||||
useEffect(() => {
|
||||
if (hydrated) {
|
||||
localStorage.setItem(STORAGE_KEY, String(privacyMode));
|
||||
}
|
||||
}, [privacyMode, hydrated]);
|
||||
// Persistir mudanças no localStorage
|
||||
useEffect(() => {
|
||||
if (hydrated) {
|
||||
localStorage.setItem(STORAGE_KEY, String(privacyMode));
|
||||
}
|
||||
}, [privacyMode, hydrated]);
|
||||
|
||||
const toggle = () => {
|
||||
setPrivacyMode((prev) => !prev);
|
||||
};
|
||||
const toggle = () => {
|
||||
setPrivacyMode((prev) => !prev);
|
||||
};
|
||||
|
||||
const set = (value: boolean) => {
|
||||
setPrivacyMode(value);
|
||||
};
|
||||
const set = (value: boolean) => {
|
||||
setPrivacyMode(value);
|
||||
};
|
||||
|
||||
return (
|
||||
<PrivacyContext.Provider value={{ privacyMode, toggle, set }}>
|
||||
{children}
|
||||
</PrivacyContext.Provider>
|
||||
);
|
||||
return (
|
||||
<PrivacyContext.Provider value={{ privacyMode, toggle, set }}>
|
||||
{children}
|
||||
</PrivacyContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
export function usePrivacyMode() {
|
||||
const context = useContext(PrivacyContext);
|
||||
if (context === undefined) {
|
||||
throw new Error("usePrivacyMode must be used within a PrivacyProvider");
|
||||
}
|
||||
return context;
|
||||
const context = useContext(PrivacyContext);
|
||||
if (context === undefined) {
|
||||
throw new Error("usePrivacyMode must be used within a PrivacyProvider");
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user