@vitnode/blog 1.2.0-canary.16 → 1.2.0-canary.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/api/modules/categories/categories.module.d.ts +343 -0
- package/dist/src/api/modules/categories/categories.module.d.ts.map +1 -0
- package/dist/src/api/modules/categories/categories.module.js +1 -0
- package/dist/src/api/modules/categories/routes/create.route.d.ts +79 -0
- package/dist/src/api/modules/categories/routes/create.route.d.ts.map +1 -0
- package/dist/src/api/modules/categories/routes/create.route.js +1 -0
- package/dist/src/api/modules/categories/routes/delete.route.d.ts +40 -0
- package/dist/src/api/modules/categories/routes/delete.route.d.ts.map +1 -0
- package/dist/src/api/modules/categories/routes/delete.route.js +1 -0
- package/dist/src/api/modules/categories/routes/edit.route.d.ts +100 -0
- package/dist/src/api/modules/categories/routes/edit.route.d.ts.map +1 -0
- package/dist/src/api/modules/categories/routes/edit.route.js +1 -0
- package/dist/src/api/modules/categories/routes/get.route.d.ts +148 -0
- package/dist/src/api/modules/categories/routes/get.route.d.ts.map +1 -0
- package/dist/src/api/modules/categories/routes/get.route.js +1 -0
- package/dist/src/api/modules/posts/posts.module.d.ts +448 -0
- package/dist/src/api/modules/posts/posts.module.d.ts.map +1 -0
- package/dist/src/api/modules/posts/posts.module.js +1 -0
- package/dist/src/api/modules/posts/routes/create.route.d.ts +109 -0
- package/dist/src/api/modules/posts/routes/create.route.d.ts.map +1 -0
- package/dist/src/api/modules/posts/routes/create.route.js +1 -0
- package/dist/src/api/modules/posts/routes/delete.route.d.ts +40 -0
- package/dist/src/api/modules/posts/routes/delete.route.d.ts.map +1 -0
- package/dist/src/api/modules/posts/routes/delete.route.js +1 -0
- package/dist/src/api/modules/posts/routes/edit.route.d.ts +127 -0
- package/dist/src/api/modules/posts/routes/edit.route.d.ts.map +1 -0
- package/dist/src/api/modules/posts/routes/edit.route.js +1 -0
- package/dist/src/api/modules/posts/routes/get.route.d.ts +208 -0
- package/dist/src/api/modules/posts/routes/get.route.d.ts.map +1 -0
- package/dist/src/api/modules/posts/routes/get.route.js +1 -0
- package/dist/src/app_admin/blog/categories/page.d.ts +5 -0
- package/dist/src/app_admin/blog/categories/page.d.ts.map +1 -0
- package/dist/src/app_admin/blog/categories/page.js +1 -0
- package/dist/src/config.api.d.ts +2 -0
- package/dist/src/config.api.d.ts.map +1 -0
- package/dist/src/config.api.js +1 -0
- package/dist/src/config.d.ts +4 -0
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/config.js +1 -0
- package/dist/src/database/categories.d.ts +97 -0
- package/dist/src/database/categories.d.ts.map +1 -0
- package/dist/src/database/categories.js +1 -0
- package/{src/database/index.ts → dist/src/database/index.d.ts} +1 -3
- package/dist/src/database/index.d.ts.map +1 -0
- package/dist/src/database/index.js +1 -0
- package/dist/src/database/posts.d.ts +131 -0
- package/dist/src/database/posts.d.ts.map +1 -0
- package/dist/src/database/posts.js +1 -0
- package/dist/src/database/relations.d.ts +7 -0
- package/dist/src/database/relations.d.ts.map +1 -0
- package/dist/src/database/relations.js +1 -0
- package/dist/src/plugin.d.ts +2 -0
- package/dist/src/plugin.d.ts.map +1 -0
- package/dist/src/plugin.js +1 -0
- package/dist/src/views/admin/categories/actions/actions.d.ts +2 -0
- package/dist/src/views/admin/categories/actions/actions.d.ts.map +1 -0
- package/dist/src/views/admin/categories/actions/actions.js +1 -0
- package/dist/src/views/admin/categories/actions/create-edit/create-edit.d.ts +8 -0
- package/dist/src/views/admin/categories/actions/create-edit/create-edit.d.ts.map +1 -0
- package/dist/src/views/admin/categories/actions/create-edit/create-edit.js +1 -0
- package/dist/src/views/admin/categories/actions/create-edit/mutation-api.d.ts +11 -0
- package/dist/src/views/admin/categories/actions/create-edit/mutation-api.d.ts.map +1 -0
- package/dist/src/views/admin/categories/actions/create-edit/mutation-api.js +1 -0
- package/dist/src/views/admin/categories/categories-admin-view.d.ts +4 -0
- package/dist/src/views/admin/categories/categories-admin-view.d.ts.map +1 -0
- package/dist/src/views/admin/categories/categories-admin-view.js +1 -0
- package/dist/src/views/admin/categories/row-actions/delete/delete-action.d.ts +5 -0
- package/dist/src/views/admin/categories/row-actions/delete/delete-action.d.ts.map +1 -0
- package/dist/src/views/admin/categories/row-actions/delete/delete-action.js +1 -0
- package/dist/src/views/admin/categories/row-actions/delete/mutation-api.d.ts +4 -0
- package/dist/src/views/admin/categories/row-actions/delete/mutation-api.d.ts.map +1 -0
- package/dist/src/views/admin/categories/row-actions/delete/mutation-api.js +1 -0
- package/dist/src/views/admin/categories/row-actions/edit-action.d.ts +9 -0
- package/dist/src/views/admin/categories/row-actions/edit-action.d.ts.map +1 -0
- package/dist/src/views/admin/categories/row-actions/edit-action.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +3 -3
- package/src/database/categories.ts +0 -12
- package/src/database/posts.ts +0 -19
- package/src/database/relations.ts +0 -18
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{pgTable}from"drizzle-orm/pg-core";export const blog_categories=pgTable("blog_categories",t=>({id:t.serial().primaryKey(),title:t.varchar({length:100}).notNull(),createdAt:t.timestamp().notNull().defaultNow(),updatedAt:t.timestamp().notNull().$onUpdate(()=>new Date),titleSeo:t.varchar({length:100}).notNull().unique().default("")})).enableRLS();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/database/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AAGxB,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./categories.js";export*from"./posts.js";export*from"./relations.js";
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
export declare const blog_posts: Omit<import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
2
|
+
name: "blog_posts";
|
|
3
|
+
schema: undefined;
|
|
4
|
+
columns: {
|
|
5
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
6
|
+
name: "id";
|
|
7
|
+
tableName: "blog_posts";
|
|
8
|
+
dataType: "number";
|
|
9
|
+
columnType: "PgSerial";
|
|
10
|
+
data: number;
|
|
11
|
+
driverParam: number;
|
|
12
|
+
notNull: true;
|
|
13
|
+
hasDefault: true;
|
|
14
|
+
isPrimaryKey: true;
|
|
15
|
+
isAutoincrement: false;
|
|
16
|
+
hasRuntimeDefault: false;
|
|
17
|
+
enumValues: undefined;
|
|
18
|
+
baseColumn: never;
|
|
19
|
+
identity: undefined;
|
|
20
|
+
generated: undefined;
|
|
21
|
+
}, {}, {}>;
|
|
22
|
+
title: import("drizzle-orm/pg-core").PgColumn<{
|
|
23
|
+
name: "title";
|
|
24
|
+
tableName: "blog_posts";
|
|
25
|
+
dataType: "string";
|
|
26
|
+
columnType: "PgVarchar";
|
|
27
|
+
data: string;
|
|
28
|
+
driverParam: string;
|
|
29
|
+
notNull: true;
|
|
30
|
+
hasDefault: false;
|
|
31
|
+
isPrimaryKey: false;
|
|
32
|
+
isAutoincrement: false;
|
|
33
|
+
hasRuntimeDefault: false;
|
|
34
|
+
enumValues: [string, ...string[]];
|
|
35
|
+
baseColumn: never;
|
|
36
|
+
identity: undefined;
|
|
37
|
+
generated: undefined;
|
|
38
|
+
}, {}, {
|
|
39
|
+
length: 255;
|
|
40
|
+
}>;
|
|
41
|
+
titleSeo: import("drizzle-orm/pg-core").PgColumn<{
|
|
42
|
+
name: "titleSeo";
|
|
43
|
+
tableName: "blog_posts";
|
|
44
|
+
dataType: "string";
|
|
45
|
+
columnType: "PgVarchar";
|
|
46
|
+
data: string;
|
|
47
|
+
driverParam: string;
|
|
48
|
+
notNull: true;
|
|
49
|
+
hasDefault: false;
|
|
50
|
+
isPrimaryKey: false;
|
|
51
|
+
isAutoincrement: false;
|
|
52
|
+
hasRuntimeDefault: false;
|
|
53
|
+
enumValues: [string, ...string[]];
|
|
54
|
+
baseColumn: never;
|
|
55
|
+
identity: undefined;
|
|
56
|
+
generated: undefined;
|
|
57
|
+
}, {}, {
|
|
58
|
+
length: 255;
|
|
59
|
+
}>;
|
|
60
|
+
content: import("drizzle-orm/pg-core").PgColumn<{
|
|
61
|
+
name: "content";
|
|
62
|
+
tableName: "blog_posts";
|
|
63
|
+
dataType: "string";
|
|
64
|
+
columnType: "PgText";
|
|
65
|
+
data: string;
|
|
66
|
+
driverParam: string;
|
|
67
|
+
notNull: true;
|
|
68
|
+
hasDefault: false;
|
|
69
|
+
isPrimaryKey: false;
|
|
70
|
+
isAutoincrement: false;
|
|
71
|
+
hasRuntimeDefault: false;
|
|
72
|
+
enumValues: [string, ...string[]];
|
|
73
|
+
baseColumn: never;
|
|
74
|
+
identity: undefined;
|
|
75
|
+
generated: undefined;
|
|
76
|
+
}, {}, {}>;
|
|
77
|
+
categoryId: import("drizzle-orm/pg-core").PgColumn<{
|
|
78
|
+
name: "categoryId";
|
|
79
|
+
tableName: "blog_posts";
|
|
80
|
+
dataType: "number";
|
|
81
|
+
columnType: "PgInteger";
|
|
82
|
+
data: number;
|
|
83
|
+
driverParam: string | number;
|
|
84
|
+
notNull: true;
|
|
85
|
+
hasDefault: false;
|
|
86
|
+
isPrimaryKey: false;
|
|
87
|
+
isAutoincrement: false;
|
|
88
|
+
hasRuntimeDefault: false;
|
|
89
|
+
enumValues: undefined;
|
|
90
|
+
baseColumn: never;
|
|
91
|
+
identity: undefined;
|
|
92
|
+
generated: undefined;
|
|
93
|
+
}, {}, {}>;
|
|
94
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
95
|
+
name: "createdAt";
|
|
96
|
+
tableName: "blog_posts";
|
|
97
|
+
dataType: "date";
|
|
98
|
+
columnType: "PgTimestamp";
|
|
99
|
+
data: Date;
|
|
100
|
+
driverParam: string;
|
|
101
|
+
notNull: true;
|
|
102
|
+
hasDefault: true;
|
|
103
|
+
isPrimaryKey: false;
|
|
104
|
+
isAutoincrement: false;
|
|
105
|
+
hasRuntimeDefault: false;
|
|
106
|
+
enumValues: undefined;
|
|
107
|
+
baseColumn: never;
|
|
108
|
+
identity: undefined;
|
|
109
|
+
generated: undefined;
|
|
110
|
+
}, {}, {}>;
|
|
111
|
+
updatedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
112
|
+
name: "updatedAt";
|
|
113
|
+
tableName: "blog_posts";
|
|
114
|
+
dataType: "date";
|
|
115
|
+
columnType: "PgTimestamp";
|
|
116
|
+
data: Date;
|
|
117
|
+
driverParam: string;
|
|
118
|
+
notNull: true;
|
|
119
|
+
hasDefault: true;
|
|
120
|
+
isPrimaryKey: false;
|
|
121
|
+
isAutoincrement: false;
|
|
122
|
+
hasRuntimeDefault: false;
|
|
123
|
+
enumValues: undefined;
|
|
124
|
+
baseColumn: never;
|
|
125
|
+
identity: undefined;
|
|
126
|
+
generated: undefined;
|
|
127
|
+
}, {}, {}>;
|
|
128
|
+
};
|
|
129
|
+
dialect: "pg";
|
|
130
|
+
}>, "enableRLS">;
|
|
131
|
+
//# sourceMappingURL=posts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"posts.d.ts","sourceRoot":"","sources":["../../../src/database/posts.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAcR,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{pgTable}from"drizzle-orm/pg-core";import{blog_categories}from"./categories.js";export const blog_posts=pgTable("blog_posts",t=>({id:t.serial().primaryKey(),title:t.varchar({length:255}).notNull(),titleSeo:t.varchar({length:255}).notNull().unique(),content:t.text().notNull(),categoryId:t.integer().references(()=>blog_categories.id).notNull(),createdAt:t.timestamp().notNull().defaultNow(),updatedAt:t.timestamp().notNull().$onUpdate(()=>new Date)})).enableRLS();
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const blog_posts_relations: import("drizzle-orm").Relations<"blog_posts", {
|
|
2
|
+
category: import("drizzle-orm").One<"blog_categories", true>;
|
|
3
|
+
}>;
|
|
4
|
+
export declare const blog_categories_relations: import("drizzle-orm").Relations<"blog_categories", {
|
|
5
|
+
posts: import("drizzle-orm").Many<"blog_posts">;
|
|
6
|
+
}>;
|
|
7
|
+
//# sourceMappingURL=relations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relations.d.ts","sourceRoot":"","sources":["../../../src/database/relations.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,oBAAoB;;EAK9B,CAAC;AAEJ,eAAO,MAAM,yBAAyB;;EAKrC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{relations}from"drizzle-orm";import{blog_categories}from"./categories.js";import{blog_posts}from"./posts.js";export const blog_posts_relations=relations(blog_posts,({one})=>({category:one(blog_categories,{fields:[blog_posts.categoryId],references:[blog_categories.id]})}));export const blog_categories_relations=relations(blog_categories,({many})=>({posts:many(blog_posts)}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/plugin.tsx"],"names":[],"mappings":"AAKA,eAAO,MAAM,UAAU,6EAatB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{buildPlugin}from"@vitnode/core/lib/plugin";import{ListIcon}from"lucide-react";import{CONFIG_PLUGIN}from"./config.js";export const blogPlugin=()=>{return buildPlugin({...CONFIG_PLUGIN,admin:{nav:[{id:"categories",href:"/admin/blog/categories",icon:_jsx(ListIcon,{})}]}})};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../../../../src/views/admin/categories/actions/actions.tsx"],"names":[],"mappings":"AAsBA,eAAO,MAAM,sBAAsB,+CAwBlC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{Button}from"@vitnode/core/components/ui/button";import{Dialog,DialogContent,DialogDescription,DialogHeader,DialogTitle,DialogTrigger}from"@vitnode/core/components/ui/dialog";import{Loader}from"@vitnode/core/components/ui/loader";import{PlusIcon}from"lucide-react";import{useTranslations}from"next-intl";import React from"react";const CreateEditActionCategoriesAdmin=React.lazy(async()=>import("./create-edit/create-edit.js").then(mod=>({default:mod.CreateEditActionCategoriesAdmin})));export const ActionsCategoriesAdmin=()=>{const t=useTranslations("@vitnode/blog.admin.categories.create");return _jsxs(Dialog,{children:[_jsx(DialogTrigger,{asChild:true,children:_jsxs(Button,{children:[_jsx(PlusIcon,{}),t("title")]})}),_jsxs(DialogContent,{children:[_jsxs(DialogHeader,{children:[_jsx(DialogTitle,{children:t("title")}),_jsx(DialogDescription,{children:t("desc")})]}),_jsx(React.Suspense,{fallback:_jsx(Loader,{}),children:_jsx(CreateEditActionCategoriesAdmin,{})})]})]})};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { zodCreateCategorySchema } from '../../../../../api/modules/categories/routes/create.route';
|
|
3
|
+
export declare const CreateEditActionCategoriesAdmin: ({ data, }: {
|
|
4
|
+
data?: z.infer<typeof zodCreateCategorySchema> & {
|
|
5
|
+
id: number;
|
|
6
|
+
};
|
|
7
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=create-edit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-edit.d.ts","sourceRoot":"","sources":["../../../../../../../src/views/admin/categories/actions/create-edit/create-edit.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAI5F,eAAO,MAAM,+BAA+B,GAAI,WAE7C;IACD,IAAI,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,GAAG;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;CACjE,4CA4EA,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{AutoForm}from"@vitnode/core/components/form/auto-form";import{AutoFormInput}from"@vitnode/core/components/form/fields/input";import{useDialog}from"@vitnode/core/components/ui/dialog";import{usePathname,useRouter}from"@vitnode/core/lib/navigation";import{useTranslations}from"next-intl";import{toast}from"sonner";import{z}from"zod";import{createMutationApi,editMutationApi}from"./mutation-api.js";export const CreateEditActionCategoriesAdmin=({data})=>{const t=useTranslations("@vitnode/blog.admin.categories");const tCore=useTranslations("core.global.errors");const{setOpen}=useDialog();const{push}=useRouter();const pathname=usePathname();const formSchema=z.object({title:z.string().min(3,{message:tCore("field_min_length",{min:3})}).default(data?.title??"")});const onSubmit=async(values,form)=>{let error="";if(data?.id){const mutation=await editMutationApi({id:data.id,...values});if(mutation?.error){error=mutation.error}}else{const mutation=await createMutationApi(values);if(mutation?.error){error=mutation.error}}if(error){if(error.includes("already exists")){form.setError("title",{type:"manual",message:t("create.form.title.already_exists")});return}toast.error(tCore("title"),{description:tCore("internal_server_error")});return}setOpen?.(false);push(pathname)};return _jsx(AutoForm,{fields:[{id:"title",component:props=>_jsx(AutoFormInput,{label:t("create.form.title.label"),...props})}],formSchema:formSchema,onSubmit:onSubmit,submitButtonProps:{children:t(`${data?"edit":"create"}.submit`)}})};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { zodCreateCategorySchema } from '../../../../../api/modules/categories/routes/create.route';
|
|
3
|
+
export declare const createMutationApi: (body: z.infer<typeof zodCreateCategorySchema>) => Promise<{
|
|
4
|
+
error: string;
|
|
5
|
+
} | undefined>;
|
|
6
|
+
export declare const editMutationApi: ({ id, ...body }: z.infer<typeof zodCreateCategorySchema> & {
|
|
7
|
+
id: number;
|
|
8
|
+
}) => Promise<{
|
|
9
|
+
error: string;
|
|
10
|
+
} | undefined>;
|
|
11
|
+
//# sourceMappingURL=mutation-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutation-api.d.ts","sourceRoot":"","sources":["../../../../../../../src/views/admin/categories/actions/create-edit/mutation-api.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAK7B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAI5F,eAAO,MAAM,iBAAiB,GAC5B,MAAM,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC;;cAmB9C,CAAC;AAEF,eAAO,MAAM,eAAe,GAAU,iBAGnC,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE;;cAqB1D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use server";import{fetcher}from"@vitnode/core/lib/fetcher";import{revalidatePath}from"next/cache";import{categoriesModule}from"../../../../../api/modules/categories/categories.module.js";export const createMutationApi=async body=>{const res=await fetcher(categoriesModule,{method:"post",module:"categories",path:"/",args:{body}});if(res.status!==201){return{error:await res.text()}}revalidatePath("/[locale]/admin/(auth)/(plugins)/(vitnode-blog)/blog/categories","page")};export const editMutationApi=async({id,...body})=>{const res=await fetcher(categoriesModule,{method:"put",module:"categories",path:"/{id}",args:{params:{id},body}});if(res.status!==200){return{error:await res.text()}}revalidatePath("/[locale]/admin/(auth)/(plugins)/(vitnode-blog)/blog/categories","page")};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"categories-admin-view.d.ts","sourceRoot":"","sources":["../../../../../src/views/admin/categories/categories-admin-view.tsx"],"names":[],"mappings":"AAUA,eAAO,MAAM,mBAAmB,GAAU,mBAEvC;IACD,YAAY,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC;CACtE,qDA0DA,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{DateFormat}from"@vitnode/core/components/date-format";import{DataTable}from"@vitnode/core/components/table/data-table";import{fetcher}from"@vitnode/core/lib/fetcher";import{getTranslations}from"next-intl/server";import{categoriesModule}from"../../../api/modules/categories/categories.module.js";import{DeleteAction}from"./row-actions/delete/delete-action.js";import{EditAction}from"./row-actions/edit-action.js";export const CategoriesAdminView=async({searchParams})=>{const t=await getTranslations("@vitnode/blog.admin.categories.table");const query=await searchParams;const res=await fetcher(categoriesModule,{path:"/",method:"get",module:"categories",args:{query},withPagination:true,options:{cache:"force-cache"}});const data=await res.json();return _jsx(DataTable,{columns:[{id:"id",label:"ID",className:"w-24"},{id:"title",label:t("title")},{id:"updatedAt",label:t("updated_at"),className:"w-48",cell:({row})=>_jsx(DateFormat,{date:row.updatedAt})},{id:"actions",label:"",className:"w-10",cell:({row})=>_jsxs(_Fragment,{children:[_jsx(EditAction,{data:row}),_jsx(DeleteAction,{...row})]})}],edges:data.edges.map(edge=>({...edge})),order:{columns:["createdAt","updatedAt"],defaultOrder:{column:"createdAt",order:"desc"}},pageInfo:data.pageInfo})};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-action.d.ts","sourceRoot":"","sources":["../../../../../../../src/views/admin/categories/row-actions/delete/delete-action.tsx"],"names":[],"mappings":"AA0BA,eAAO,MAAM,YAAY,GAAI,eAAe;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,4CAsDxE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{AlertDialog,AlertDialogAction,AlertDialogCancel,AlertDialogContent,AlertDialogDescription,AlertDialogFooter,AlertDialogHeader,AlertDialogTitle,AlertDialogTrigger}from"@vitnode/core/components/ui/alert-dialog";import{Button}from"@vitnode/core/components/ui/button";import{Tooltip,TooltipContent,TooltipProvider,TooltipTrigger}from"@vitnode/core/components/ui/tooltip";import{Trash2Icon}from"lucide-react";import{useTranslations}from"next-intl";import{toast}from"sonner";import{mutationApi}from"./mutation-api.js";export const DeleteAction=({title,id})=>{const t=useTranslations("@vitnode/blog.admin.categories.delete");const tGlobal=useTranslations("core.global");return _jsxs(AlertDialog,{children:[_jsx(TooltipProvider,{children:_jsxs(Tooltip,{children:[_jsx(TooltipTrigger,{asChild:true,children:_jsx(AlertDialogTrigger,{asChild:true,children:_jsx(Button,{size:"icon",variant:"destructive",children:_jsx(Trash2Icon,{className:"size-4"})})})}),_jsx(TooltipContent,{children:t("title")})]})}),_jsxs(AlertDialogContent,{children:[_jsxs(AlertDialogHeader,{children:[_jsx(AlertDialogTitle,{children:t("title")}),_jsx(AlertDialogDescription,{children:t.rich("desc",{title:()=>_jsx("span",{className:"text-foreground font-bold",children:title})})})]}),_jsxs(AlertDialogFooter,{children:[_jsx(AlertDialogCancel,{children:tGlobal("cancel")}),_jsx(AlertDialogAction,{onClick:async()=>{const mutation=await mutationApi(id);if(mutation?.error){toast.error(tGlobal("errors.title"),{description:tGlobal("errors.internal_server_error")});return}toast.success(t("success"),{description:title})},children:t("confirm")})]})]})]})};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutation-api.d.ts","sourceRoot":"","sources":["../../../../../../../src/views/admin/categories/row-actions/delete/mutation-api.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,WAAW,GAAU,IAAI,MAAM;;cAoB3C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use server";import{fetcher}from"@vitnode/core/lib/fetcher";import{revalidatePath}from"next/cache";import{categoriesModule}from"../../../../../api/modules/categories/categories.module.js";export const mutationApi=async id=>{const res=await fetcher(categoriesModule,{method:"delete",path:"/{id}",module:"categories",args:{params:{id}}});if(!res.ok){return{error:await res.text()}}revalidatePath("/[locale]/admin/(auth)/(plugins)/(vitnode-blog)/blog/categories","page")};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare const CreateEditActionCategoriesAdmin: React.LazyExoticComponent<({ data, }: {
|
|
3
|
+
data?: import("zod").TypeOf<typeof import("../../../../api/modules/categories/routes/create.route").zodCreateCategorySchema> & {
|
|
4
|
+
id: number;
|
|
5
|
+
};
|
|
6
|
+
}) => import("react/jsx-runtime").JSX.Element>;
|
|
7
|
+
export declare const EditAction: (props: Required<React.ComponentProps<typeof CreateEditActionCategoriesAdmin>>) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=edit-action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit-action.d.ts","sourceRoot":"","sources":["../../../../../../src/views/admin/categories/row-actions/edit-action.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,QAAA,MAAM,+BAA+B;QAEhB,CAAC;;;8CAErB,CAAC;AAEF,eAAO,MAAM,UAAU,GACrB,OAAO,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,+BAA+B,CAAC,CAAC,4CA+B9E,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{Button}from"@vitnode/core/components/ui/button";import{Dialog,DialogContent,DialogDescription,DialogHeader,DialogTitle,DialogTrigger}from"@vitnode/core/components/ui/dialog";import{Loader}from"@vitnode/core/components/ui/loader";import{Tooltip,TooltipContent,TooltipProvider,TooltipTrigger}from"@vitnode/core/components/ui/tooltip";import{PencilIcon}from"lucide-react";import{useTranslations}from"next-intl";import React from"react";const CreateEditActionCategoriesAdmin=React.lazy(async()=>import("../actions/create-edit/create-edit.js").then(mod=>({default:mod.CreateEditActionCategoriesAdmin})));export const EditAction=props=>{const t=useTranslations("@vitnode/blog.admin.categories.edit");return _jsxs(Dialog,{children:[_jsx(TooltipProvider,{children:_jsxs(Tooltip,{children:[_jsx(TooltipTrigger,{asChild:true,children:_jsx(DialogTrigger,{asChild:true,children:_jsx(Button,{size:"icon",variant:"ghost",children:_jsx(PencilIcon,{})})})}),_jsx(TooltipContent,{children:t("title")})]})}),_jsxs(DialogContent,{children:[_jsxs(DialogHeader,{children:[_jsx(DialogTitle,{children:t("title")}),_jsx(DialogDescription,{children:props.data.title})]}),_jsx(React.Suspense,{fallback:_jsx(Loader,{}),children:_jsx(CreateEditActionCategoriesAdmin,{...props})})]})]})};
|