feat: add Overseer integration with capture functionality and update tsconfig for global type definitions
This commit is contained in:
parent
37b5c01846
commit
3ecbc54515
4 changed files with 131 additions and 67 deletions
|
|
@ -34,7 +34,6 @@
|
|||
"!*compose.yml",
|
||||
"!.kanelrc.js",
|
||||
"!TODO",
|
||||
"!*.d.ts",
|
||||
"!src/i18n/comuni.ts",
|
||||
"!src/i18n/nazioni.ts",
|
||||
"!src/i18n/provincie.ts",
|
||||
|
|
|
|||
25
apps/infoalloggi/global.d.ts
vendored
Normal file
25
apps/infoalloggi/global.d.ts
vendored
Normal file
|
|
@ -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 {};
|
||||
|
|
@ -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 = () => {
|
|||
</Button>
|
||||
</Confirm>
|
||||
<NoteUtenteDialog />
|
||||
<OverseerButton />
|
||||
</div>
|
||||
<div className="flex flex-row flex-wrap gap-2">
|
||||
<Link href={`/area-riservata/admin/user-view/edit-user/${data.id}`}>
|
||||
|
|
@ -173,6 +175,49 @@ export const UserViewHeader = () => {
|
|||
);
|
||||
};
|
||||
|
||||
const OverseerButton = () => {
|
||||
const data = useUserViewContext();
|
||||
const [overseer, setOverseer] = useState<OverseerCapture | null>(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 (
|
||||
<Button
|
||||
disabled={!overseer}
|
||||
onClick={handleSendToOverseer}
|
||||
size="sm"
|
||||
variant="outline"
|
||||
>
|
||||
<CloudSync />
|
||||
</Button>
|
||||
);
|
||||
};
|
||||
|
||||
const VOCALI = ["A", "E", "I", "O", "U"] as const;
|
||||
|
||||
const IntestazioneMaker = () => {
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue