refactor: remove unused incroci router and related components; update SCAN_DIRS and PROCEDURE_REGEX
This commit is contained in:
parent
73675480f6
commit
dc28e42baa
11 changed files with 15 additions and 358 deletions
|
|
@ -4,12 +4,21 @@ import * as path from "node:path";
|
||||||
// --- CONFIGURATION ---
|
// --- CONFIGURATION ---
|
||||||
const ROOT_DIR: string = process.cwd();
|
const ROOT_DIR: string = process.cwd();
|
||||||
const ROUTERS_DIR: string = path.join(ROOT_DIR, "src/server/api/routers");
|
const ROUTERS_DIR: string = path.join(ROOT_DIR, "src/server/api/routers");
|
||||||
const SCAN_DIRS: string[] = [path.join(ROOT_DIR, "src")];
|
const SCAN_DIRS: string[] = [
|
||||||
|
path.join(ROOT_DIR, "src/pages"),
|
||||||
|
path.join(ROOT_DIR, "src/components"),
|
||||||
|
path.join(ROOT_DIR, "src/forms"),
|
||||||
|
path.join(ROOT_DIR, "src/hooks"),
|
||||||
|
path.join(ROOT_DIR, "src/lib"),
|
||||||
|
path.join(ROOT_DIR, "src/providers"),
|
||||||
|
];
|
||||||
const IGNORE_DIRS: string[] = ["node_modules", ".next", "dist"];
|
const IGNORE_DIRS: string[] = ["node_modules", ".next", "dist"];
|
||||||
|
|
||||||
// Regex to find tRPC procedure definitions
|
// Regex to find tRPC procedure definitions.
|
||||||
|
// Matches `procedureName: someProcedure` where the procedure type is one of the known base procedures.
|
||||||
|
// This handles chained .input()/.output() before .query/.mutation/.subscription.
|
||||||
const PROCEDURE_REGEX: RegExp =
|
const PROCEDURE_REGEX: RegExp =
|
||||||
/([a-zA-Z0-9_]+)\s*:\s*[a-zA-Z0-9_.]+\.(?:query|mutation|subscription)\s*\(/g;
|
/([a-zA-Z0-9_]+)\s*:\s*(?:adminProcedure|protectedProcedure|publicProcedure)\b/g;
|
||||||
|
|
||||||
interface ProcedureDefinition {
|
interface ProcedureDefinition {
|
||||||
name: string;
|
name: string;
|
||||||
|
|
|
||||||
|
|
@ -1,121 +0,0 @@
|
||||||
import { format } from "date-fns";
|
|
||||||
import type { GetServerSideProps } from "next";
|
|
||||||
import Head from "next/head";
|
|
||||||
import Link from "next/link";
|
|
||||||
import { AreaRiservataLayout } from "~/components/Layout";
|
|
||||||
import { LoadingPage } from "~/components/loading";
|
|
||||||
import { Status500 } from "~/components/status-page";
|
|
||||||
import { Button } from "~/components/ui/button";
|
|
||||||
import { Separator } from "~/components/ui/separator";
|
|
||||||
import type { NextPageWithLayout } from "~/pages/_app";
|
|
||||||
import { TrpcAuthedFetchingIstance } from "~/server/utils/ssgHelper";
|
|
||||||
import { api } from "~/utils/api";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Pagina di gestione incroci per admin: /area-riservata/admin/incroci
|
|
||||||
*/
|
|
||||||
const Incroci: NextPageWithLayout = () => {
|
|
||||||
const { data, isLoading } = api.incroci.getAll.useQuery();
|
|
||||||
|
|
||||||
if (isLoading) return <LoadingPage />;
|
|
||||||
if (!data) return <Status500 />;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Head>
|
|
||||||
<title>Incorici - Infoalloggi.it</title>
|
|
||||||
</Head>
|
|
||||||
|
|
||||||
<div className="mx-3 flex flex-1 flex-col gap-4 overflow-auto pt-5">
|
|
||||||
<div className="items-start justify-between md:flex">
|
|
||||||
<div className="mx-1 flex items-center">
|
|
||||||
<h3 className="font-bold text-2xl">Incroci</h3>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="space-y-4">
|
|
||||||
{data.map((incrocio) => (
|
|
||||||
<div className="rounded-md border p-4" key={incrocio.id}>
|
|
||||||
<div className="flex items-center gap-2 font-bold text-xl">
|
|
||||||
<span>Cod:</span>
|
|
||||||
<span>{incrocio.codice}</span>
|
|
||||||
</div>
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<span className="font-bold">Titolo:</span>
|
|
||||||
<span>{incrocio.titolo_it}</span>
|
|
||||||
</div>
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<span className="font-bold">Richieste:</span>
|
|
||||||
</div>
|
|
||||||
<ul className="ml-4 space-y-2">
|
|
||||||
{incrocio.richieste.map((r) => (
|
|
||||||
<li key={r.servizio_id}>
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<span className="font-bold">Username:</span>
|
|
||||||
<span>{r.username}</span>
|
|
||||||
</div>
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<span className="font-bold">Aggiunto il:</span>
|
|
||||||
<span>
|
|
||||||
{format(new Date(r.created_at), "dd/MM/yyyy")}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<span className="font-bold">Aperto Contatti il:</span>
|
|
||||||
<span>
|
|
||||||
{r.open_contatti_at
|
|
||||||
? format(new Date(r.open_contatti_at), "dd/MM/yyyy")
|
|
||||||
: "Non aperto"}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<span className="font-bold">Mandato conferma il:</span>
|
|
||||||
<span>
|
|
||||||
{r.user_confirmed_at
|
|
||||||
? format(new Date(r.user_confirmed_at), "dd/MM/yyyy")
|
|
||||||
: "Non confermato"}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<span className="font-bold">Conferma da Admin:</span>
|
|
||||||
<span>{r.hasConfermaAdmin ? "Si" : "No"}</span>
|
|
||||||
</div>
|
|
||||||
<Link
|
|
||||||
href={`/area-riservata/admin/user-view/servizio/${r.userId}/${r.servizio_id}`}
|
|
||||||
target="_blank"
|
|
||||||
>
|
|
||||||
<Button size="sm">Apri Servizio</Button>
|
|
||||||
</Link>
|
|
||||||
<Separator className="mt-2" />
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Incroci;
|
|
||||||
|
|
||||||
export const getServerSideProps = (async (context) => {
|
|
||||||
const access_token = context.req.cookies.access_token;
|
|
||||||
|
|
||||||
const helpers = await TrpcAuthedFetchingIstance({ access_token });
|
|
||||||
if (helpers) {
|
|
||||||
await helpers.trpc.incroci.getAll.prefetch();
|
|
||||||
return {
|
|
||||||
props: {
|
|
||||||
trpcState: helpers.trpc.dehydrate(),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
props: {},
|
|
||||||
};
|
|
||||||
}) satisfies GetServerSideProps;
|
|
||||||
|
|
||||||
Incroci.getLayout = function getLayout(page) {
|
|
||||||
return <AreaRiservataLayout>{page}</AreaRiservataLayout>;
|
|
||||||
};
|
|
||||||
|
|
@ -22,7 +22,6 @@ import { bannersRouter } from "./routers/banners";
|
||||||
import { catastoRouter } from "./routers/catasto";
|
import { catastoRouter } from "./routers/catasto";
|
||||||
import { etichetteRouter } from "./routers/etichette";
|
import { etichetteRouter } from "./routers/etichette";
|
||||||
import { flagsRouter } from "./routers/flags";
|
import { flagsRouter } from "./routers/flags";
|
||||||
import { incrociRouter } from "./routers/incroci";
|
|
||||||
import { inviteRouter } from "./routers/invite";
|
import { inviteRouter } from "./routers/invite";
|
||||||
import { potenzialiRouter } from "./routers/potenziali";
|
import { potenzialiRouter } from "./routers/potenziali";
|
||||||
import { revalidationRouter } from "./routers/revalidation";
|
import { revalidationRouter } from "./routers/revalidation";
|
||||||
|
|
@ -59,6 +58,5 @@ export const appRouter = createTRPCRouter({
|
||||||
revalidation: revalidationRouter,
|
revalidation: revalidationRouter,
|
||||||
potenziali: potenzialiRouter,
|
potenziali: potenzialiRouter,
|
||||||
invite: inviteRouter,
|
invite: inviteRouter,
|
||||||
incroci: incrociRouter,
|
|
||||||
});
|
});
|
||||||
export type AppRouter = typeof appRouter;
|
export type AppRouter = typeof appRouter;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
import { adminProcedure, createTRPCRouter } from "~/server/api/trpc";
|
|
||||||
import { getAll } from "~/server/controllers/incroci.controller";
|
|
||||||
|
|
||||||
export const incrociRouter = createTRPCRouter({
|
|
||||||
getAll: adminProcedure.query(async () => {
|
|
||||||
return await getAll();
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
|
|
@ -15,7 +15,6 @@ import {
|
||||||
getPotenzialiGroups,
|
getPotenzialiGroups,
|
||||||
type PotenzialeData,
|
type PotenzialeData,
|
||||||
updatePotenziale,
|
updatePotenziale,
|
||||||
updatePotenzialeGroup,
|
|
||||||
updatePotenziali,
|
updatePotenziali,
|
||||||
} from "~/server/services/potenziali.service";
|
} from "~/server/services/potenziali.service";
|
||||||
|
|
||||||
|
|
@ -97,18 +96,7 @@ export const potenzialiRouter = createTRPCRouter({
|
||||||
.mutation(async ({ input }) => {
|
.mutation(async ({ input }) => {
|
||||||
return await addPotenzialeGroup({ name: input.name });
|
return await addPotenzialeGroup({ name: input.name });
|
||||||
}),
|
}),
|
||||||
updatePotenzialeGroup: adminProcedure
|
|
||||||
.input(
|
|
||||||
z.object({
|
|
||||||
potenzialiGroupId: zPotenzialiGroupId,
|
|
||||||
name: z.string().min(1).max(255),
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.mutation(async ({ input }) => {
|
|
||||||
return await updatePotenzialeGroup(input.potenzialiGroupId, {
|
|
||||||
name: input.name,
|
|
||||||
});
|
|
||||||
}),
|
|
||||||
deletePotenzialeGroup: adminProcedure
|
deletePotenzialeGroup: adminProcedure
|
||||||
.input(
|
.input(
|
||||||
z.object({
|
z.object({
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ import { db } from "~/server/db";
|
||||||
import {
|
import {
|
||||||
addPrezziario,
|
addPrezziario,
|
||||||
getPrezziario,
|
getPrezziario,
|
||||||
getPrezziarioByIdHandler,
|
|
||||||
getPrezziarioByTipologia,
|
getPrezziarioByTipologia,
|
||||||
getPrezziarioConsulenza,
|
getPrezziarioConsulenza,
|
||||||
updatePrezziario,
|
updatePrezziario,
|
||||||
|
|
@ -81,11 +80,7 @@ export const prezziarioRouter = createTRPCRouter({
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
getPrezzoPerServizio: publicProcedure
|
|
||||||
.input(z.object({ idprezziario: zPrezziarioId }))
|
|
||||||
.query(async ({ input }) => {
|
|
||||||
return await getPrezziarioByIdHandler(input.idprezziario);
|
|
||||||
}),
|
|
||||||
updatePrezziario: adminProcedure
|
updatePrezziario: adminProcedure
|
||||||
.input(
|
.input(
|
||||||
z.object({
|
z.object({
|
||||||
|
|
|
||||||
|
|
@ -1,36 +0,0 @@
|
||||||
import { jsonArrayFrom } from "kysely/helpers/postgres";
|
|
||||||
import { db } from "../db";
|
|
||||||
|
|
||||||
export const getAll = async () => {
|
|
||||||
const data = await db
|
|
||||||
.selectFrom("annunci")
|
|
||||||
.innerJoin("servizio_annunci", "servizio_annunci.annunci_id", "annunci.id")
|
|
||||||
|
|
||||||
.select((eb) => [
|
|
||||||
"annunci.id",
|
|
||||||
"annunci.titolo_it",
|
|
||||||
"annunci.codice",
|
|
||||||
jsonArrayFrom(
|
|
||||||
eb
|
|
||||||
.selectFrom("servizio_annunci")
|
|
||||||
.select([
|
|
||||||
"servizio_annunci.open_contatti_at",
|
|
||||||
"servizio_annunci.servizio_id",
|
|
||||||
"servizio_annunci.created_at",
|
|
||||||
"servizio_annunci.user_confirmed_at",
|
|
||||||
"servizio_annunci.hasConfermaAdmin",
|
|
||||||
])
|
|
||||||
.leftJoin(
|
|
||||||
"servizio",
|
|
||||||
"servizio.servizio_id",
|
|
||||||
"servizio_annunci.servizio_id",
|
|
||||||
)
|
|
||||||
.leftJoin("users", "users.id", "servizio.user_id")
|
|
||||||
.select(["users.username", "users.id as userId"])
|
|
||||||
.whereRef("servizio_annunci.annunci_id", "=", "annunci.id"),
|
|
||||||
).as("richieste"),
|
|
||||||
])
|
|
||||||
.groupBy("annunci.id")
|
|
||||||
.execute();
|
|
||||||
return data;
|
|
||||||
};
|
|
||||||
|
|
@ -5,7 +5,6 @@ import { z } from "zod/v4";
|
||||||
import { env } from "~/env";
|
import { env } from "~/env";
|
||||||
import { withParsedDates } from "~/lib/dateParserJsonKysely";
|
import { withParsedDates } from "~/lib/dateParserJsonKysely";
|
||||||
import type { Annunci, AnnunciId } from "~/schemas/public/Annunci";
|
import type { Annunci, AnnunciId } from "~/schemas/public/Annunci";
|
||||||
import OrderTypeEnum from "~/schemas/public/OrderTypeEnum";
|
|
||||||
import type { Ordini, OrdiniOrdineId } from "~/schemas/public/Ordini";
|
import type { Ordini, OrdiniOrdineId } from "~/schemas/public/Ordini";
|
||||||
import type { Prezziario } from "~/schemas/public/Prezziario";
|
import type { Prezziario } from "~/schemas/public/Prezziario";
|
||||||
import type {
|
import type {
|
||||||
|
|
@ -38,40 +37,8 @@ import {
|
||||||
withVideos,
|
withVideos,
|
||||||
} from "~/utils/kysely-helper";
|
} from "~/utils/kysely-helper";
|
||||||
import { GetUserInterests } from "../services/interests.service";
|
import { GetUserInterests } from "../services/interests.service";
|
||||||
import { createOrdine } from "../services/ordini.service";
|
|
||||||
import { getServizioById } from "../services/servizio.service";
|
import { getServizioById } from "../services/servizio.service";
|
||||||
import type { AnnuncioRicerca } from "./annunci.controller";
|
import type { AnnuncioRicerca } from "./annunci.controller";
|
||||||
import { SaldoSolver } from "./pagamenti.controller";
|
|
||||||
|
|
||||||
export const getServiziByUserId = async (userId: UsersId) => {
|
|
||||||
try {
|
|
||||||
return await db
|
|
||||||
.selectFrom("servizio")
|
|
||||||
.selectAll("servizio")
|
|
||||||
.select((eb) => [
|
|
||||||
jsonArrayFrom(
|
|
||||||
eb
|
|
||||||
.selectFrom("servizio_annunci")
|
|
||||||
.select(["servizio_annunci.annunci_id"])
|
|
||||||
.innerJoin("annunci", "annunci.id", "servizio_annunci.annunci_id")
|
|
||||||
.select("annunci.codice")
|
|
||||||
.whereRef(
|
|
||||||
"servizio_annunci.servizio_id",
|
|
||||||
"=",
|
|
||||||
"servizio.servizio_id",
|
|
||||||
),
|
|
||||||
).as("annunci"),
|
|
||||||
])
|
|
||||||
.where("user_id", "=", userId)
|
|
||||||
.orderBy("created_at", "asc")
|
|
||||||
.execute();
|
|
||||||
} catch (e) {
|
|
||||||
throw new TRPCError({
|
|
||||||
code: "INTERNAL_SERVER_ERROR",
|
|
||||||
message: `Error fetching servizi by user ID: ${(e as Error).message}`,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getDataPerAcquisto = async (servizioId: ServizioServizioId) => {
|
export const getDataPerAcquisto = async (servizioId: ServizioServizioId) => {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
import { TRPCError } from "@trpc/server";
|
import { TRPCError } from "@trpc/server";
|
||||||
import type { UsersId } from "~/schemas/public/Users";
|
import type { UsersId } from "~/schemas/public/Users";
|
||||||
import type {
|
import type { NewUsersStorage } from "~/schemas/public/UsersStorage";
|
||||||
NewUsersStorage,
|
|
||||||
UsersStorageUserStorageId,
|
|
||||||
} from "~/schemas/public/UsersStorage";
|
|
||||||
import { db, type Querier } from "~/server/db";
|
import { db, type Querier } from "~/server/db";
|
||||||
import { fetchFiles, retriveFilesSafely } from "../services/storage.service";
|
import { fetchFiles, retriveFilesSafely } from "../services/storage.service";
|
||||||
|
|
||||||
|
|
@ -86,31 +83,6 @@ export const retrieveUserFiles = async ({ userId }: { userId: UsersId }) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getStorageIdFromUserStorageId = async ({
|
|
||||||
userStorageId,
|
|
||||||
}: {
|
|
||||||
userStorageId: UsersStorageUserStorageId;
|
|
||||||
}) => {
|
|
||||||
try {
|
|
||||||
const storage = await db
|
|
||||||
.selectFrom("users_storage")
|
|
||||||
.select("storageId")
|
|
||||||
.where("user_storage_id", "=", userStorageId)
|
|
||||||
.executeTakeFirstOrThrow(
|
|
||||||
() =>
|
|
||||||
new Error(
|
|
||||||
`User storage entry not found - userStorageId: ${userStorageId}`,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
return storage.storageId;
|
|
||||||
} catch (e) {
|
|
||||||
throw new TRPCError({
|
|
||||||
code: "INTERNAL_SERVER_ERROR",
|
|
||||||
message: `Error while getting storage ID from user storage ID: ${(e as Error).message}`,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getAllWithFromAdmin = async () => {
|
export const getAllWithFromAdmin = async () => {
|
||||||
try {
|
try {
|
||||||
const files = await db
|
const files = await db
|
||||||
|
|
|
||||||
|
|
@ -1,87 +0,0 @@
|
||||||
import { z } from "zod/v4";
|
|
||||||
|
|
||||||
const ClientTypeSchema = z.enum(["company", "person", "pa", "condo"]);
|
|
||||||
|
|
||||||
const VatTypeSchema = z.object({
|
|
||||||
description: z.string().nullish(),
|
|
||||||
e_invoice: z.boolean().nullish(),
|
|
||||||
editable: z.boolean().nullish(),
|
|
||||||
ei_description: z.string().nullish(),
|
|
||||||
ei_type: z.string().nullish(),
|
|
||||||
id: z.number().nullish(),
|
|
||||||
is_disabled: z.boolean().nullish(),
|
|
||||||
notes: z.string().nullish(),
|
|
||||||
value: z.number().nullish(),
|
|
||||||
});
|
|
||||||
|
|
||||||
const PaymentTermsTypeSchema = z.enum(["standard", "end_of_month"]);
|
|
||||||
const PaymentMethodTypeSchema = z.enum(["standard", "riba"]);
|
|
||||||
const PaymentAccountTypeSchema = z.enum(["standard", "bank"]);
|
|
||||||
const PaymentAccountSchema = z.object({
|
|
||||||
cuc: z.string().nullish(),
|
|
||||||
iban: z.string().nullish(),
|
|
||||||
id: z.number().nullish(),
|
|
||||||
name: z.string().nullish(),
|
|
||||||
sia: z.string().nullish(),
|
|
||||||
type: PaymentAccountTypeSchema.optional(),
|
|
||||||
virtual: z.boolean().nullish(),
|
|
||||||
});
|
|
||||||
|
|
||||||
const PaymentMethodDetailsSchema = z.object({
|
|
||||||
description: z.string().nullish(),
|
|
||||||
title: z.string().nullish(),
|
|
||||||
});
|
|
||||||
|
|
||||||
const PaymentMethodSchema = z.object({
|
|
||||||
bank_beneficiary: z.string().nullish(),
|
|
||||||
bank_iban: z.string().nullish(),
|
|
||||||
bank_name: z.string().nullish(),
|
|
||||||
default_payment_account: PaymentAccountSchema.nullish(),
|
|
||||||
details: z.array(PaymentMethodDetailsSchema).optional(),
|
|
||||||
ei_payment_method: z.string().nullish(),
|
|
||||||
id: z.number().nullish(),
|
|
||||||
is_default: z.boolean().nullish(),
|
|
||||||
name: z.string().nullish(),
|
|
||||||
type: PaymentMethodTypeSchema.optional(),
|
|
||||||
});
|
|
||||||
|
|
||||||
export const ClientSchema = z.object({
|
|
||||||
address_city: z.string().nullish(),
|
|
||||||
address_extra: z.string().nullish(),
|
|
||||||
address_postal_code: z.string().nullish(),
|
|
||||||
address_province: z.string().nullish(),
|
|
||||||
address_street: z.string().nullish(),
|
|
||||||
bank_iban: z.string().nullish(),
|
|
||||||
bank_name: z.string().nullish(),
|
|
||||||
bank_swift_code: z.string().nullish(),
|
|
||||||
certified_email: z.string().nullish(),
|
|
||||||
code: z.string().nullish(),
|
|
||||||
contact_person: z.string().nullish(),
|
|
||||||
country: z.string().nullish(),
|
|
||||||
country_iso: z.string().nullish(),
|
|
||||||
created_at: z.string().nullish(),
|
|
||||||
default_discount: z.number().nullish(),
|
|
||||||
default_payment_method: PaymentMethodSchema.optional(),
|
|
||||||
default_payment_terms: z.number().nullish(),
|
|
||||||
default_payment_terms_type: PaymentTermsTypeSchema.optional(),
|
|
||||||
default_vat: VatTypeSchema.nullish(),
|
|
||||||
discount_highlight: z.boolean().nullish(),
|
|
||||||
e_invoice: z.boolean().nullish(),
|
|
||||||
ei_code: z.string().nullish(),
|
|
||||||
email: z.string().nullish(),
|
|
||||||
fax: z.string().nullish(),
|
|
||||||
first_name: z.string().nullish(),
|
|
||||||
has_intent_declaration: z.boolean().nullish(),
|
|
||||||
id: z.number().nullish(),
|
|
||||||
intent_declaration_protocol_date: z.string().nullish(),
|
|
||||||
intent_declaration_protocol_number: z.string().nullish(),
|
|
||||||
last_name: z.string().nullish(),
|
|
||||||
name: z.string().nullish(),
|
|
||||||
notes: z.string().nullish(),
|
|
||||||
phone: z.string().nullish(),
|
|
||||||
shipping_address: z.string().nullish(),
|
|
||||||
tax_code: z.string().nullish(),
|
|
||||||
type: ClientTypeSchema.nullish(),
|
|
||||||
updated_at: z.string().nullish(),
|
|
||||||
vat_number: z.string().nullish(),
|
|
||||||
});
|
|
||||||
|
|
@ -10,7 +10,6 @@ import type {
|
||||||
NewPotenzialiGroups,
|
NewPotenzialiGroups,
|
||||||
PotenzialiGroups,
|
PotenzialiGroups,
|
||||||
PotenzialiGroupsId,
|
PotenzialiGroupsId,
|
||||||
PotenzialiGroupsUpdate,
|
|
||||||
} from "~/schemas/public/PotenzialiGroups";
|
} from "~/schemas/public/PotenzialiGroups";
|
||||||
import type { Users } from "~/schemas/public/Users";
|
import type { Users } from "~/schemas/public/Users";
|
||||||
import { db } from "../db";
|
import { db } from "../db";
|
||||||
|
|
@ -89,25 +88,6 @@ export const deletePotenzialeGroup = async (id: PotenzialiGroupsId) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const updatePotenzialeGroup = async (
|
|
||||||
id: PotenzialiGroupsId,
|
|
||||||
data: PotenzialiGroupsUpdate,
|
|
||||||
) => {
|
|
||||||
try {
|
|
||||||
await db
|
|
||||||
.updateTable("potenziali_groups")
|
|
||||||
.set(data)
|
|
||||||
.where("id", "=", id)
|
|
||||||
.execute();
|
|
||||||
return { status: "success" };
|
|
||||||
} catch (e) {
|
|
||||||
throw new TRPCError({
|
|
||||||
code: "INTERNAL_SERVER_ERROR",
|
|
||||||
message: `Failed to update potenziale group, error: ${(e as Error).message}`,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const addPotenziale = async (data: NewPotenziali) => {
|
export const addPotenziale = async (data: NewPotenziali) => {
|
||||||
try {
|
try {
|
||||||
await db.insertInto("potenziali").values(data).execute();
|
await db.insertInto("potenziali").values(data).execute();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue