diff --git a/apps/infoalloggi/biome.json b/apps/infoalloggi/biome.json index 8b9e013..c440289 100644 --- a/apps/infoalloggi/biome.json +++ b/apps/infoalloggi/biome.json @@ -34,7 +34,6 @@ "!*compose.yml", "!.kanelrc.js", "!TODO", - "!*.d.ts", "!src/i18n/comuni.ts", "!src/i18n/nazioni.ts", "!src/i18n/provincie.ts", diff --git a/apps/infoalloggi/global.d.ts b/apps/infoalloggi/global.d.ts new file mode 100644 index 0000000..8d4ba7d --- /dev/null +++ b/apps/infoalloggi/global.d.ts @@ -0,0 +1,25 @@ +declare global { + type OverseerData = { + cognome?: string; + nome?: string; + cf?: string; + telefono?: string; + email?: string; + data_nascita?: string; + luogo_nascita?: string; + naz_residenza?: string; + provincia_residenza?: string; + cap_residenza?: string; + comune_residenza?: string; + indirizzo_residenza?: string; + civico_residenza?: string; + }; + type OverseerCapture = { + capture: (data: OverseerData) => void; + }; + interface Window { + OverseerCapture?: OverseerCapture; + } +} + +export {}; diff --git a/apps/infoalloggi/src/components/area-riservata/userViewHeader.tsx b/apps/infoalloggi/src/components/area-riservata/userViewHeader.tsx index 646e107..9d76f50 100644 --- a/apps/infoalloggi/src/components/area-riservata/userViewHeader.tsx +++ b/apps/infoalloggi/src/components/area-riservata/userViewHeader.tsx @@ -1,5 +1,6 @@ import { format } from "date-fns"; import { + CloudSync, ExternalLink, Mail, MessagesSquare, @@ -13,7 +14,7 @@ import { import Link from "next/link"; import { usePathname } from "next/navigation"; import { useRouter } from "next/router"; -import { useState } from "react"; +import { useEffect, useState } from "react"; import toast from "react-hot-toast"; import LoadingButton from "~/components/custom_ui/loading-button"; import { Textarea } from "~/components/custom_ui/textarea"; @@ -85,6 +86,7 @@ export const UserViewHeader = () => { +
@@ -173,6 +175,49 @@ export const UserViewHeader = () => { ); }; +const OverseerButton = () => { + const data = useUserViewContext(); + const [overseer, setOverseer] = useState(null); + useEffect(() => { + if (typeof window !== "undefined" && window.OverseerCapture) { + setOverseer(window.OverseerCapture); + } + }, []); + + const handleSendToOverseer = () => { + if (overseer) { + overseer.capture({ + cognome: data.cognome, + nome: data.nome, + cf: data.codice_fiscale || undefined, + telefono: data.telefono, + email: data.email, + data_nascita: data.data_nascita?.toISOString() || undefined, + luogo_nascita: data.luogo_nascita || undefined, + naz_residenza: data.nazione_residenza || undefined, + provincia_residenza: data.provincia_residenza || undefined, + cap_residenza: data.cap_residenza || undefined, + comune_residenza: data.comune_residenza || undefined, + indirizzo_residenza: data.via_residenza || undefined, + civico_residenza: data.civico_residenza || undefined, + }); + } else { + console.warn("Overseer extension not installed"); + } + }; + + return ( + + ); +}; + const VOCALI = ["A", "E", "I", "O", "U"] as const; const IntestazioneMaker = () => { diff --git a/apps/infoalloggi/tsconfig.json b/apps/infoalloggi/tsconfig.json index dc64a34..696f517 100644 --- a/apps/infoalloggi/tsconfig.json +++ b/apps/infoalloggi/tsconfig.json @@ -1,67 +1,62 @@ { - "compilerOptions": { - "allowJs": true, - /* Path Aliases */ - "baseUrl": ".", - "checkJs": true, - /* Base Options: */ - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "incremental": true, - "isolatedModules": true, - "jsx": "react-jsx", - /* Bundled projects */ - "lib": [ - "dom", - "dom.iterable", - "esnext" - ], - "module": "ESNext", - "moduleDetection": "force", - "moduleResolution": "Bundler", - "noEmit": true, - "noUncheckedIndexedAccess": true, - "paths": { - "~/*": [ - "./src/*" - ] - }, - "plugins": [ - { - "name": "next" - } - ], - "resolveJsonModule": true, - "skipLibCheck": true, - /* Strictness */ - "strict": true, - "target": "esnext" - }, - "exclude": [ - "node_modules", - "out", - "dist", - "headers", - "kyselyRules", - ".kanelrc.js" - ], - "include": [ - "src", - "next-env.d.ts", - "next.config.ts", - "postcss.config.cjs", - "reset.d.ts", - "TypeHelpers.type.ts", - "public", - "emails", - ".next/types/**/*.ts", - "tests" - ], - "ts-node": { - // these options are overrides used only by ts-node - // same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable - "compilerOptions": { - "module": "commonjs" - } - } + "compilerOptions": { + "allowJs": true, + /* Path Aliases */ + "baseUrl": ".", + "checkJs": true, + /* Base Options: */ + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "incremental": true, + "isolatedModules": true, + "jsx": "react-jsx", + /* Bundled projects */ + "lib": ["dom", "dom.iterable", "esnext"], + "module": "ESNext", + "moduleDetection": "force", + "moduleResolution": "Bundler", + "noEmit": true, + "noUncheckedIndexedAccess": true, + "paths": { + "~/*": ["./src/*"] + }, + "plugins": [ + { + "name": "next" + } + ], + "resolveJsonModule": true, + "skipLibCheck": true, + /* Strictness */ + "strict": true, + "target": "esnext" + }, + "exclude": [ + "node_modules", + "out", + "dist", + "headers", + "kyselyRules", + ".kanelrc.js" + ], + "include": [ + "src", + "global.d.ts", + "next-env.d.ts", + "next.config.ts", + "postcss.config.cjs", + "reset.d.ts", + "TypeHelpers.type.ts", + "public", + "emails", + ".next/types/**/*.ts", + "tests" + ], + "ts-node": { + // these options are overrides used only by ts-node + // same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable + "compilerOptions": { + "module": "commonjs" + } + } }