Skip to content

Commit 4726159

Browse files
feat(domains): add refused verification type (#553)
1 parent 5a203c9 commit 4726159

File tree

6 files changed

+86
-52
lines changed

6 files changed

+86
-52
lines changed

e2e/features/moderations/jean_bon_join_abracadabra.feature

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ Fonctionnalité: Moderation blockante à accepter
2929

3030
Quand j'ouvre le menu déroulant sur la même ligne
3131
Et je clique sur le bouton "🚫 Domaine refusé"
32-
Alors je ne vois pas "✅ Domaine autorisé"
32+
Alors sur la même ligne je vois "🚫"
33+
Alors sur la même ligne je vois "refused"
3334

3435
Quand je clique sur le champs dans le tableau
3536
* je tape "poymail.com"

hyyypertool.code-workspace

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,61 @@
168168
"instanceLimit": 1,
169169
},
170170
},
171+
{
172+
"label": "🧪 Run Test",
173+
"command": "bun test",
174+
"type": "shell",
175+
"group": "build",
176+
"options": {
177+
"cwd": "${workspaceFolder:root}",
178+
},
179+
"problemMatcher": ["$tsc-watch"],
180+
"runOptions": { "instanceLimit": 1 },
181+
},
182+
{
183+
"label": "🧪 Update Test Snapshots",
184+
"command": "bun test --update-snapshots",
185+
"type": "shell",
186+
"group": "build",
187+
"options": {
188+
"cwd": "${workspaceFolder:root}",
189+
},
190+
"problemMatcher": ["$tsc-watch"],
191+
"runOptions": { "instanceLimit": 1 },
192+
},
193+
{
194+
"label": "🧪 Watch Test",
195+
"command": "bun test --watch",
196+
"type": "shell",
197+
"group": "build",
198+
"options": {
199+
"cwd": "${workspaceFolder:root}",
200+
},
201+
"problemMatcher": ["$tsc-watch"],
202+
"runOptions": { "instanceLimit": 1 },
203+
},
204+
{
205+
"label": "🧪 Cypress Studio",
206+
"command": "pnpm run studio",
207+
"type": "shell",
208+
"group": "build",
209+
"options": {
210+
"cwd": "${workspaceFolder:🧪 e2e}",
211+
},
212+
"problemMatcher": ["$tsc-watch"],
213+
"runOptions": { "instanceLimit": 1 },
214+
},
215+
{
216+
"label": "🧪 Cypress Run : Current file",
217+
"command": "pnpm run test --spec ${fileDirname}/${fileBasename}",
218+
"type": "shell",
219+
"group": "build",
220+
"options": {
221+
"cwd": "${workspaceFolder:🧪 e2e}",
222+
},
223+
"problemMatcher": ["$tsc-watch"],
224+
"runOptions": { "instanceLimit": 1 },
225+
},
171226
{
172227
"label": "🏗️ Database MonComptePro Migrate",
173228
"command": "bun",

packages/~/app/urls/src/pattern.d.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,6 @@ declare const app: import("hono/hono-base").HonoBase<
5454
};
5555
};
5656
"/organizations/:id/domains/:domain_id": {
57-
$delete: {
58-
input: {
59-
param: {
60-
id: string;
61-
domain_id: string;
62-
} & {
63-
id: string;
64-
};
65-
};
66-
output: "OK";
67-
outputFormat: "text";
68-
status: 200;
69-
};
7057
$patch: {
7158
input: {
7259
param: {
@@ -116,11 +103,11 @@ declare const app: import("hono/hono-base").HonoBase<
116103
id: string;
117104
};
118105
form: {
119-
is_external?:
106+
verification_type?:
120107
| import("hono/types").ParsedFormValue
121108
| import("hono/types").ParsedFormValue[]
122109
| undefined;
123-
verification_type?:
110+
is_external?:
124111
| import("hono/types").ParsedFormValue
125112
| import("hono/types").ParsedFormValue[]
126113
| undefined;

packages/~/infra/moncomptepro/lib/src/email_domain.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ import { z } from "zod";
66

77
export const EmailDomain_Type_Schema = z
88
.enum([
9+
"authorized", // legacy ?
910
"blacklisted",
1011
"external",
1112
"official_contact",
12-
"trackdechet_postal_mail",
13+
"refused",
14+
"trackdechets_postal_mail",
1315
"verified",
1416
])
1517
.nullable();

packages/~/organizations/api/src/:id/domains/Table.tsx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { GoogleSearchButton } from "@~/app.ui/button/components/search";
55
import { menu_item } from "@~/app.ui/menu";
66
import { Horizontal_Menu } from "@~/app.ui/menu/components/Horizontal_Menu";
77
import { hx_urls } from "@~/app.urls";
8+
import type { EmailDomain_Type } from "@~/moncomptepro.lib/email_domain";
89
import type { MCP_EmailDomain_Type } from "@~/moncomptepro.lib/moncomptepro.d";
910
import type { get_orginization_domains_dto } from "@~/organizations.repository/get_orginization_domains";
1011
import { match } from "ts-pattern";
@@ -75,38 +76,43 @@ async function Add_Domain() {
7576
);
7677
}
7778

78-
function TypeToEmoji({ type }: { type: MCP_EmailDomain_Type }) {
79+
function TypeToEmoji({ type }: { type: EmailDomain_Type }) {
7980
return match(type)
80-
.with("verified", () => (
81-
<span role="img" aria-label="vérifié" title="vérifié">
82-
83-
</span>
84-
))
8581
.with("authorized", () => (
8682
<span role="img" aria-label="autorisé" title="autorisé">
8783
🔓
8884
</span>
8985
))
90-
.with("external", () => (
91-
<span role="img" aria-label="externe" title="externe">
92-
93-
</span>
94-
))
9586
.with("blacklisted", () => (
9687
<span role="img" aria-label="blacklisté" title="blacklisté">
9788
☠️
9889
</span>
9990
))
91+
.with("external", () => (
92+
<span role="img" aria-label="externe" title="externe">
93+
94+
</span>
95+
))
10096
.with("official_contact", () => (
10197
<span role="img" aria-label="contact officiel" title="contact officiel">
10298
10399
</span>
104100
))
101+
.with("refused", () => (
102+
<span role="img" aria-label="postal mail" title="postal mail">
103+
🚫
104+
</span>
105+
))
105106
.with("trackdechets_postal_mail", () => (
106107
<span role="img" aria-label="postal mail" title="postal mail">
107108
108109
</span>
109110
))
111+
.with("verified", () => (
112+
<span role="img" aria-label="vérifié" title="vérifié">
113+
114+
</span>
115+
))
110116
.otherwise(() => (
111117
<span role="img" aria-label="inconnu" title="inconnu">
112118
@@ -155,12 +161,6 @@ async function Row_Actions({
155161
}) {
156162
const { id, organization_id } = organization_domain;
157163

158-
const hx_delete_domain_props = await hx_urls.organizations[":id"].domains[
159-
":domain_id"
160-
].$delete({
161-
param: { id: organization_id.toString(), domain_id: id.toString() },
162-
});
163-
164164
const hx_change_type_props = (type: MCP_EmailDomain_Type) =>
165165
hx_urls.organizations[":id"].domains[":domain_id"].$patch({
166166
param: { id: organization_id.toString(), domain_id: id.toString() },
@@ -192,7 +192,7 @@ async function Row_Actions({
192192
</li>
193193
<li>
194194
<button
195-
{...await hx_delete_domain_props}
195+
{...await hx_change_type_props("refused")}
196196
class={menu_item()}
197197
hx-swap="none"
198198
role="menuitem"

packages/~/organizations/api/src/:id/domains/index.tsx

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { Entity_Schema, Id_Schema } from "@~/app.core/schema";
66
import { EmailDomain_Type_Schema } from "@~/moncomptepro.lib/email_domain";
77
import { ORGANISATION_EVENTS } from "@~/organizations.lib/event";
88
import { add_authorized_domain } from "@~/organizations.repository/add_authorized_domain";
9-
import { delete_domain_by_id } from "@~/organizations.repository/delete_domain_by_id";
109
import { get_orginization_domains } from "@~/organizations.repository/get_orginization_domains";
1110
import { update_domain_by_id } from "@~/organizations.repository/update_domain_by_id";
1211
import { Hono } from "hono";
@@ -61,33 +60,23 @@ export default new Hono<ContextType>()
6160
} as Htmx_Header);
6261
},
6362
)
64-
.delete(
65-
"/:domain_id",
66-
zValidator("param", Entity_Schema.merge(DomainParams_Schema)),
67-
async function DELETE({ text, req, var: { moncomptepro_pg } }) {
68-
const { domain_id } = req.valid("param");
69-
70-
await delete_domain_by_id(moncomptepro_pg, domain_id);
71-
72-
return text("OK", 200, {
73-
"HX-Trigger": ORGANISATION_EVENTS.Enum.DOMAIN_UPDATED,
74-
} as Htmx_Header);
75-
},
76-
)
7763
.patch(
7864
"/:domain_id",
7965
zValidator("param", Entity_Schema.merge(DomainParams_Schema)),
8066
zValidator(
8167
"query",
82-
z.object({ type: EmailDomain_Type_Schema.or(z.literal("null")) }),
68+
z.object({
69+
type: EmailDomain_Type_Schema.or(
70+
z.literal("null").transform(() => null),
71+
),
72+
}),
8373
),
8474
async function PATCH({ text, req, var: { moncomptepro_pg } }) {
8575
const { domain_id } = req.valid("param");
8676
const { type: verification_type } = req.valid("query");
8777

8878
await update_domain_by_id(moncomptepro_pg, domain_id, {
89-
verification_type:
90-
verification_type === "null" ? null : verification_type,
79+
verification_type: verification_type,
9180
verified_at:
9281
verification_type === "verified"
9382
? new Date().toISOString()

0 commit comments

Comments
 (0)