diff --git a/packages/~/app/urls/src/pattern.d.ts b/packages/~/app/urls/src/pattern.d.ts
index 0668dd03..d7bc507c 100644
--- a/packages/~/app/urls/src/pattern.d.ts
+++ b/packages/~/app/urls/src/pattern.d.ts
@@ -54,6 +54,19 @@ declare const app: import("hono/hono-base").HonoBase<
};
};
"/organizations/:id/domains/:domain_id": {
+ $delete: {
+ input: {
+ param: {
+ id: string;
+ domain_id: string;
+ } & {
+ id: string;
+ };
+ };
+ output: "OK";
+ outputFormat: "text";
+ status: 200;
+ };
$patch: {
input: {
param: {
@@ -103,11 +116,11 @@ declare const app: import("hono/hono-base").HonoBase<
id: string;
};
form: {
- is_external?:
+ verification_type?:
| import("hono/types").ParsedFormValue
| import("hono/types").ParsedFormValue[]
| undefined;
- verification_type?:
+ is_external?:
| import("hono/types").ParsedFormValue
| import("hono/types").ParsedFormValue[]
| undefined;
@@ -197,10 +210,10 @@ declare const app: import("hono/hono-base").HonoBase<
$get: {
input: {
query: {
- id?: string | string[] | undefined;
page?: string | string[] | undefined;
page_size?: string | string[] | undefined;
q?: string | string[] | undefined;
+ id?: string | string[] | undefined;
};
};
output: {};
@@ -333,9 +346,9 @@ declare const app: import("hono/hono-base").HonoBase<
id: string;
};
};
- output: {};
- outputFormat: string;
- status: import("hono/utils/http-status").StatusCode;
+ output: "OK";
+ outputFormat: "text";
+ status: 200;
};
};
"/moderations/:id/$procedures/rejected": {
diff --git a/packages/~/organizations/api/src/:id/domains/Table.tsx b/packages/~/organizations/api/src/:id/domains/Table.tsx
index 42d8d929..3f1061e9 100644
--- a/packages/~/organizations/api/src/:id/domains/Table.tsx
+++ b/packages/~/organizations/api/src/:id/domains/Table.tsx
@@ -159,7 +159,7 @@ async function Row_Actions({
}: {
organization_domain: get_orginization_domains_dto[number];
}) {
- const { id, organization_id } = organization_domain;
+ const { domain, id, organization, organization_id } = organization_domain;
const hx_change_type_props = (type: MCP_EmailDomain_Type) =>
hx_urls.organizations[":id"].domains[":domain_id"].$patch({
@@ -167,6 +167,12 @@ async function Row_Actions({
query: { type },
});
+ const hx_delete_domain_props = await hx_urls.organizations[":id"].domains[
+ ":domain_id"
+ ].$delete({
+ param: { id: organization_id.toString(), domain_id: id.toString() },
+ });
+
return (
@@ -200,6 +206,17 @@ async function Row_Actions({
🚫 Domaine refusé
+ -
+
+
);
diff --git a/packages/~/organizations/api/src/:id/domains/index.tsx b/packages/~/organizations/api/src/:id/domains/index.tsx
index 4017ec9e..39c31291 100644
--- a/packages/~/organizations/api/src/:id/domains/index.tsx
+++ b/packages/~/organizations/api/src/:id/domains/index.tsx
@@ -9,6 +9,7 @@ import {
} from "@~/app.core/schema";
import { EmailDomain_Type_Schema } from "@~/moncomptepro.lib/email_domain";
import { ORGANISATION_EVENTS } from "@~/organizations.lib/event";
+import { RemoveDomainEmailById } from "@~/organizations.lib/usecase";
import { add_authorized_domain } from "@~/organizations.repository/add_authorized_domain";
import { get_orginization_domains } from "@~/organizations.repository/get_orginization_domains";
import { update_domain_by_id } from "@~/organizations.repository/update_domain_by_id";
@@ -63,6 +64,22 @@ export default new Hono()
} as Htmx_Header);
},
)
+ .delete(
+ "/:domain_id",
+ zValidator("param", Entity_Schema.merge(DomainParams_Schema)),
+ async function DELETE({ text, req, var: { moncomptepro_pg } }) {
+ const { domain_id } = req.valid("param");
+
+ const remove_domain_email_by_id = RemoveDomainEmailById({
+ pg: moncomptepro_pg,
+ });
+ await remove_domain_email_by_id(domain_id);
+
+ return text("OK", 200, {
+ "HX-Trigger": ORGANISATION_EVENTS.Enum.DOMAIN_UPDATED,
+ } as Htmx_Header);
+ },
+ )
.patch(
"/:domain_id",
zValidator("param", Entity_Schema.merge(DomainParams_Schema)),
diff --git a/packages/~/organizations/lib/package.json b/packages/~/organizations/lib/package.json
index ae60c692..6d51edb1 100644
--- a/packages/~/organizations/lib/package.json
+++ b/packages/~/organizations/lib/package.json
@@ -7,6 +7,9 @@
".": {
"default": "./src/index.ts"
},
+ "./usecase": {
+ "default": "./src/usecase/index.ts"
+ },
"./*": {
"default": "./src/*.ts"
}
diff --git a/packages/~/organizations/lib/src/usecase/RemoveDomainEmailById.test.ts b/packages/~/organizations/lib/src/usecase/RemoveDomainEmailById.test.ts
new file mode 100644
index 00000000..439c017e
--- /dev/null
+++ b/packages/~/organizations/lib/src/usecase/RemoveDomainEmailById.test.ts
@@ -0,0 +1,36 @@
+//
+
+import { schema } from "@~/moncomptepro.database";
+import { create_unicorn_organization } from "@~/moncomptepro.database/seed/unicorn";
+import { empty_database, migrate, pg } from "@~/moncomptepro.database/testing";
+import { beforeAll, beforeEach, expect, test } from "bun:test";
+import { RemoveDomainEmailById } from "./RemoveDomainEmailById";
+
+//
+
+beforeAll(migrate);
+beforeEach(empty_database);
+
+const remove_domain_email_by_id = RemoveDomainEmailById({ pg });
+
+//
+
+test("returns no membership", async () => {
+ const organization_id = await create_unicorn_organization(pg);
+ const [{ domain_id }] = await pg
+ .insert(schema.email_domains)
+ .values({
+ domain: "unicorn.xyz",
+ organization_id,
+ })
+ .returning({ domain_id: schema.email_domains.id });
+
+ await remove_domain_email_by_id(domain_id);
+
+ expect(
+ await pg.query.email_domains.findFirst({
+ columns: { id: true },
+ where: (table, { eq }) => eq(table.id, domain_id),
+ }),
+ ).toBeUndefined();
+});
diff --git a/packages/~/organizations/lib/src/usecase/RemoveDomainEmailById.ts b/packages/~/organizations/lib/src/usecase/RemoveDomainEmailById.ts
new file mode 100644
index 00000000..c898e1dc
--- /dev/null
+++ b/packages/~/organizations/lib/src/usecase/RemoveDomainEmailById.ts
@@ -0,0 +1,21 @@
+//
+
+import {
+ schema,
+ type MonCompteProDatabaseCradle,
+} from "@~/moncomptepro.database";
+import { eq } from "drizzle-orm";
+
+//
+
+export function RemoveDomainEmailById({ pg }: MonCompteProDatabaseCradle) {
+ return async function remove_domain_email_by_id(id: number) {
+ return pg
+ .delete(schema.email_domains)
+ .where(eq(schema.email_domains.id, id));
+ };
+}
+
+export type RemoveDomainEmailByIdHandler = ReturnType<
+ typeof RemoveDomainEmailById
+>;
diff --git a/packages/~/organizations/lib/src/usecase/index.ts b/packages/~/organizations/lib/src/usecase/index.ts
new file mode 100644
index 00000000..e6375391
--- /dev/null
+++ b/packages/~/organizations/lib/src/usecase/index.ts
@@ -0,0 +1,3 @@
+//
+
+export * from "./RemoveDomainEmailById";