Es-tu sûr·e ?
+Il est impossible de revenir en arrière
+ {#if deletionResult} +{message}
+ {/each} +diff --git a/.changeset/bright-hairs-pay.md b/.changeset/bright-hairs-pay.md
new file mode 100644
index 000000000..31a25505f
--- /dev/null
+++ b/.changeset/bright-hairs-pay.md
@@ -0,0 +1,5 @@
+---
+'@churros/app': major
+---
+
+Remove /posts/:group/create - the URL was not used anywhere in the UI anymore
diff --git a/.changeset/fifty-cars-judge.md b/.changeset/fifty-cars-judge.md
new file mode 100644
index 000000000..8253b860d
--- /dev/null
+++ b/.changeset/fifty-cars-judge.md
@@ -0,0 +1,5 @@
+---
+'@churros/api': major
+---
+
+change return type and argument type for Mutation.deleteArticle
diff --git a/.changeset/odd-horses-fold.md b/.changeset/odd-horses-fold.md
new file mode 100644
index 000000000..33de39797
--- /dev/null
+++ b/.changeset/odd-horses-fold.md
@@ -0,0 +1,5 @@
+---
+'@churros/app': patch
+---
+
+make delete button on posts work
diff --git a/packages/api/src/modules/posts/resolvers/mutation.delete-article.ts b/packages/api/src/modules/posts/resolvers/mutation.delete-article.ts
index fc6e8f4d7..a0533b965 100644
--- a/packages/api/src/modules/posts/resolvers/mutation.delete-article.ts
+++ b/packages/api/src/modules/posts/resolvers/mutation.delete-article.ts
@@ -1,33 +1,30 @@
-import { builder, log, prisma, publish } from '#lib';
+import { builder, ensureGlobalId, log, prisma, publish } from '#lib';
+import { LocalID } from '#modules/global';
+import { ArticleType, canEditArticle } from '#modules/posts';
builder.mutationField('deleteArticle', (t) =>
- t.field({
- type: 'Boolean',
- args: { id: t.arg.id() },
+ t.prismaField({
+ type: ArticleType,
+ errors: {},
+ description: 'Supprimer un post',
+ args: { id: t.arg({ type: LocalID }) },
async authScopes(_, { id }, { user }) {
- if (!user) return false;
- if (user.canEditGroups) return true;
-
- const article = await prisma.article.findUniqueOrThrow({ where: { id } });
-
- // Who can delete this article?
- return (
- // Admins
- user.admin ||
- // The author
- user.id === article.authorId ||
- // Other authors of the group
- user.groups.some(
- ({ groupId, canEditArticles }) => canEditArticles && groupId === article.groupId,
- )
- );
+ const post = await prisma.article.findUniqueOrThrow({
+ where: { id: ensureGlobalId(id, 'Article') },
+ include: canEditArticle.prismaIncludes,
+ });
+ return canEditArticle(post, { authorId: null, group: null }, user);
},
- async resolve(_, { id }, { user }) {
- await prisma.article.delete({ where: { id } });
+ async resolve(query, _, { id }, { user }) {
+ id = ensureGlobalId(id, 'Article');
await log('article', 'delete', { message: `Article ${id} deleted` }, id, user);
+
+ const result = await prisma.article.delete({ ...query, where: { id } });
+
publish(id, 'deleted', id);
- return true;
+
+ return result;
},
}),
);
diff --git a/packages/app/schema.graphql b/packages/app/schema.graphql
index aeacee442..accb0c221 100644
--- a/packages/app/schema.graphql
+++ b/packages/app/schema.graphql
@@ -2371,7 +2371,10 @@ type Mutation @rateLimit(limit: 1200, duration: 600) {
"""
deduplicateBookings(event: LocalID!): MutationDeduplicateBookingsResult!
deleteAnnouncement(id: ID!): Boolean!
- deleteArticle(id: ID!): Boolean!
+ """
+ Supprimer un post
+ """
+ deleteArticle(id: LocalID!): MutationDeleteArticleResult!
deleteArticlePicture(id: ID!): Boolean!
deleteComment(id: ID!): Comment!
"""
@@ -3343,6 +3346,12 @@ type MutationDeduplicateBookingsSuccess {
data: Int!
}
+union MutationDeleteArticleResult = Error | MutationDeleteArticleSuccess | ZodError
+
+type MutationDeleteArticleSuccess {
+ data: Article!
+}
+
union MutationDeleteContributionResult = Error | MutationDeleteContributionSuccess | ZodError
type MutationDeleteContributionSuccess {
diff --git a/packages/app/src/lib/ROUTES.ts b/packages/app/src/lib/ROUTES.ts
index 34ca3b042..2c5ebfebc 100644
--- a/packages/app/src/lib/ROUTES.ts
+++ b/packages/app/src/lib/ROUTES.ts
@@ -220,9 +220,6 @@ const PAGES = {
'/logout': `/logout`,
'/logs': `/logs`,
'/notifications': `/notifications`,
- '/posts/create': (params?: { group?: string | number }) => {
- return `/posts${params?.group ? `/${params?.group}` : ''}/create`;
- },
'/posts/[id]': (id: string | number, params?: {}) => {
return `/posts/${id}`;
},
@@ -579,7 +576,6 @@ export type KIT_ROUTES = {
'/logout': never;
'/logs': never;
'/notifications': never;
- '/posts/create': 'group';
'/posts/[id]': 'id';
'/posts/[id]/edit': 'id';
'/posts/[id]/edit/body': 'id';
diff --git a/packages/app/src/lib/components/FormArticle.houdini.svelte b/packages/app/src/lib/components/FormArticle.houdini.svelte
deleted file mode 100644
index bbdba8d65..000000000
--- a/packages/app/src/lib/components/FormArticle.houdini.svelte
+++ /dev/null
@@ -1,514 +0,0 @@
-
-
-
- Ce post est lié à l'évènement
-
- Pour créer un post lié à un évènement, se rendre sur la page de l'évènement puis choisir ⋮ >
- Post lié
-
Il est impossible de revenir en arrière
+ {#if deletionResult} +{message}
+ {/each} +