Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(domains): add refused verification type #553

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion e2e/features/moderations/jean_bon_join_abracadabra.feature
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ Fonctionnalité: Moderation blockante à accepter

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

Quand je clique sur le champs dans le tableau
* je tape "poymail.com"
Expand Down
55 changes: 55 additions & 0 deletions hyyypertool.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,61 @@
"instanceLimit": 1,
},
},
{
"label": "🧪 Run Test",
"command": "bun test",
"type": "shell",
"group": "build",
"options": {
"cwd": "${workspaceFolder:root}",
},
"problemMatcher": ["$tsc-watch"],
"runOptions": { "instanceLimit": 1 },
},
{
"label": "🧪 Update Test Snapshots",
"command": "bun test --update-snapshots",
"type": "shell",
"group": "build",
"options": {
"cwd": "${workspaceFolder:root}",
},
"problemMatcher": ["$tsc-watch"],
"runOptions": { "instanceLimit": 1 },
},
{
"label": "🧪 Watch Test",
"command": "bun test --watch",
"type": "shell",
"group": "build",
"options": {
"cwd": "${workspaceFolder:root}",
},
"problemMatcher": ["$tsc-watch"],
"runOptions": { "instanceLimit": 1 },
},
{
"label": "🧪 Cypress Studio",
"command": "pnpm run studio",
"type": "shell",
"group": "build",
"options": {
"cwd": "${workspaceFolder:🧪 e2e}",
},
"problemMatcher": ["$tsc-watch"],
"runOptions": { "instanceLimit": 1 },
},
{
"label": "🧪 Cypress Run : Current file",
"command": "pnpm run test --spec ${fileDirname}/${fileBasename}",
"type": "shell",
"group": "build",
"options": {
"cwd": "${workspaceFolder:🧪 e2e}",
},
"problemMatcher": ["$tsc-watch"],
"runOptions": { "instanceLimit": 1 },
},
{
"label": "🏗️ Database MonComptePro Migrate",
"command": "bun",
Expand Down
17 changes: 2 additions & 15 deletions packages/~/app/urls/src/pattern.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,6 @@ 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: {
Expand Down Expand Up @@ -116,11 +103,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;
Expand Down
4 changes: 3 additions & 1 deletion packages/~/infra/moncomptepro/lib/src/email_domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import { z } from "zod";

export const EmailDomain_Type_Schema = z
.enum([
"authorized", // legacy ?
"blacklisted",
"external",
"official_contact",
"trackdechet_postal_mail",
"refused",
"trackdechets_postal_mail",
"verified",
])
.nullable();
Expand Down
36 changes: 18 additions & 18 deletions packages/~/organizations/api/src/:id/domains/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { GoogleSearchButton } from "@~/app.ui/button/components/search";
import { menu_item } from "@~/app.ui/menu";
import { Horizontal_Menu } from "@~/app.ui/menu/components/Horizontal_Menu";
import { hx_urls } from "@~/app.urls";
import type { EmailDomain_Type } from "@~/moncomptepro.lib/email_domain";
import type { MCP_EmailDomain_Type } from "@~/moncomptepro.lib/moncomptepro.d";
import type { get_orginization_domains_dto } from "@~/organizations.repository/get_orginization_domains";
import { match } from "ts-pattern";
Expand Down Expand Up @@ -75,38 +76,43 @@ async function Add_Domain() {
);
}

function TypeToEmoji({ type }: { type: MCP_EmailDomain_Type }) {
function TypeToEmoji({ type }: { type: EmailDomain_Type }) {
return match(type)
.with("verified", () => (
<span role="img" aria-label="vérifié" title="vérifié">
</span>
))
.with("authorized", () => (
<span role="img" aria-label="autorisé" title="autorisé">
🔓
</span>
))
.with("external", () => (
<span role="img" aria-label="externe" title="externe">
</span>
))
.with("blacklisted", () => (
<span role="img" aria-label="blacklisté" title="blacklisté">
☠️
</span>
))
.with("external", () => (
<span role="img" aria-label="externe" title="externe">
</span>
))
.with("official_contact", () => (
<span role="img" aria-label="contact officiel" title="contact officiel">
</span>
))
.with("refused", () => (
<span role="img" aria-label="postal mail" title="postal mail">
🚫
</span>
))
.with("trackdechets_postal_mail", () => (
<span role="img" aria-label="postal mail" title="postal mail">
</span>
))
.with("verified", () => (
<span role="img" aria-label="vérifié" title="vérifié">
</span>
))
.otherwise(() => (
<span role="img" aria-label="inconnu" title="inconnu">
Expand Down Expand Up @@ -155,12 +161,6 @@ async function Row_Actions({
}) {
const { id, organization_id } = organization_domain;

const hx_delete_domain_props = await hx_urls.organizations[":id"].domains[
":domain_id"
].$delete({
param: { id: organization_id.toString(), domain_id: id.toString() },
});

const hx_change_type_props = (type: MCP_EmailDomain_Type) =>
hx_urls.organizations[":id"].domains[":domain_id"].$patch({
param: { id: organization_id.toString(), domain_id: id.toString() },
Expand Down Expand Up @@ -192,7 +192,7 @@ async function Row_Actions({
</li>
<li>
<button
{...await hx_delete_domain_props}
{...await hx_change_type_props("refused")}
class={menu_item()}
hx-swap="none"
role="menuitem"
Expand Down
23 changes: 6 additions & 17 deletions packages/~/organizations/api/src/:id/domains/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { Entity_Schema, Id_Schema } from "@~/app.core/schema";
import { EmailDomain_Type_Schema } from "@~/moncomptepro.lib/email_domain";
import { ORGANISATION_EVENTS } from "@~/organizations.lib/event";
import { add_authorized_domain } from "@~/organizations.repository/add_authorized_domain";
import { delete_domain_by_id } from "@~/organizations.repository/delete_domain_by_id";
import { get_orginization_domains } from "@~/organizations.repository/get_orginization_domains";
import { update_domain_by_id } from "@~/organizations.repository/update_domain_by_id";
import { Hono } from "hono";
Expand Down Expand Up @@ -61,33 +60,23 @@ export default new Hono<ContextType>()
} 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");

await delete_domain_by_id(moncomptepro_pg, 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)),
zValidator(
"query",
z.object({ type: EmailDomain_Type_Schema.or(z.literal("null")) }),
z.object({
type: EmailDomain_Type_Schema.or(
z.literal("null").transform(() => null),
),
}),
),
async function PATCH({ text, req, var: { moncomptepro_pg } }) {
const { domain_id } = req.valid("param");
const { type: verification_type } = req.valid("query");

await update_domain_by_id(moncomptepro_pg, domain_id, {
verification_type:
verification_type === "null" ? null : verification_type,
verification_type: verification_type,
verified_at:
verification_type === "verified"
? new Date().toISOString()
Expand Down