@arch-cadre/sample-module 0.0.1
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/actions/settings.cjs +34 -0
- package/dist/actions/settings.d.ts +7 -0
- package/dist/actions/settings.mjs +31 -0
- package/dist/index.cjs +42 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.mjs +38 -0
- package/dist/intl.d.ts +13 -0
- package/dist/routes.cjs +15 -0
- package/dist/routes.d.ts +3 -0
- package/dist/routes.mjs +10 -0
- package/dist/schema.cjs +18 -0
- package/dist/schema.d.ts +106 -0
- package/dist/schema.mjs +10 -0
- package/dist/ui/settings-page.cjs +64 -0
- package/dist/ui/settings-page.d.ts +2 -0
- package/dist/ui/settings-page.mjs +51 -0
- package/locales/en/global.json +11 -0
- package/manifest.json +11 -0
- package/package.json +53 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use server";
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getSampleConfig = getSampleConfig;
|
|
8
|
+
exports.updateSampleConfig = updateSampleConfig;
|
|
9
|
+
var _core = require("@arch-cadre/core");
|
|
10
|
+
var _server = require("@arch-cadre/core/server");
|
|
11
|
+
var _server2 = require("@arch-cadre/modules/server");
|
|
12
|
+
var _cache = require("next/cache");
|
|
13
|
+
async function getSampleConfig() {
|
|
14
|
+
const config = await (0, _server2.getModuleConfig)("sample-module");
|
|
15
|
+
return config ?? {
|
|
16
|
+
defaultVar: ""
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
async function updateSampleConfig(config) {
|
|
20
|
+
await (0, _server2.updateModuleConfig)("sample-module", config);
|
|
21
|
+
(0, _cache.revalidatePath)(`${(0, _server2.getKryoPathPrefix)()}/sample-module/settings`);
|
|
22
|
+
const {
|
|
23
|
+
user
|
|
24
|
+
} = await (0, _server.getCurrentSession)();
|
|
25
|
+
await _core.eventBus.publish("activity.create", {
|
|
26
|
+
action: "sample-module.config.updated",
|
|
27
|
+
description: `User updated sample module config`,
|
|
28
|
+
userId: user?.id,
|
|
29
|
+
metadata: config
|
|
30
|
+
}, "sample-module");
|
|
31
|
+
return {
|
|
32
|
+
success: true
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
import { eventBus } from "@arch-cadre/core";
|
|
3
|
+
import { getCurrentSession } from "@arch-cadre/core/server";
|
|
4
|
+
import {
|
|
5
|
+
getKryoPathPrefix,
|
|
6
|
+
getModuleConfig,
|
|
7
|
+
updateModuleConfig
|
|
8
|
+
} from "@arch-cadre/modules/server";
|
|
9
|
+
import { revalidatePath } from "next/cache";
|
|
10
|
+
export async function getSampleConfig() {
|
|
11
|
+
const config = await getModuleConfig("sample-module");
|
|
12
|
+
return config ?? {
|
|
13
|
+
defaultVar: ""
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export async function updateSampleConfig(config) {
|
|
17
|
+
await updateModuleConfig("sample-module", config);
|
|
18
|
+
revalidatePath(`${getKryoPathPrefix()}/sample-module/settings`);
|
|
19
|
+
const { user } = await getCurrentSession();
|
|
20
|
+
await eventBus.publish(
|
|
21
|
+
"activity.create",
|
|
22
|
+
{
|
|
23
|
+
action: "sample-module.config.updated",
|
|
24
|
+
description: `User updated sample module config`,
|
|
25
|
+
userId: user?.id,
|
|
26
|
+
metadata: config
|
|
27
|
+
},
|
|
28
|
+
"sample-module"
|
|
29
|
+
);
|
|
30
|
+
return { success: true };
|
|
31
|
+
}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _server = require("@arch-cadre/core/server");
|
|
8
|
+
var _intl = require("@arch-cadre/intl");
|
|
9
|
+
var _drizzleOrm = require("drizzle-orm");
|
|
10
|
+
var _manifest = _interopRequireDefault(require("../manifest.json"));
|
|
11
|
+
var _routes = require("./routes.cjs");
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
const _module = {
|
|
14
|
+
manifest: _manifest.default,
|
|
15
|
+
onEnable: async () => {},
|
|
16
|
+
onDisable: async () => {
|
|
17
|
+
console.log("[Module:Sample] onDisable: Dropping all tables physically...");
|
|
18
|
+
try {
|
|
19
|
+
const tables = ["sample"];
|
|
20
|
+
for (const table of tables) {
|
|
21
|
+
await _server.db.execute(_drizzleOrm.sql.raw(`DROP TABLE IF EXISTS ${table} CASCADE`));
|
|
22
|
+
}
|
|
23
|
+
} catch (e) {
|
|
24
|
+
console.error("[Module:Sample] onDisable Error:", e);
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
routes: {
|
|
28
|
+
private: _routes.privateRoutes,
|
|
29
|
+
api: _routes.apiRoutes
|
|
30
|
+
},
|
|
31
|
+
navigation: {
|
|
32
|
+
admin: {
|
|
33
|
+
[(0, _intl.i18n)("General")]: [{
|
|
34
|
+
id: "sample-settings",
|
|
35
|
+
title: (0, _intl.i18n)("Sample Configuration"),
|
|
36
|
+
url: "/sample/settings",
|
|
37
|
+
icon: "solar:box-bold-duotone"
|
|
38
|
+
}]
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
module.exports = _module;
|
package/dist/index.d.ts
ADDED
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { db } from "@arch-cadre/core/server";
|
|
2
|
+
import { i18n } from "@arch-cadre/intl";
|
|
3
|
+
import { sql } from "drizzle-orm";
|
|
4
|
+
import manifest from "../manifest.json";
|
|
5
|
+
import { apiRoutes, privateRoutes } from "./routes.mjs";
|
|
6
|
+
const module = {
|
|
7
|
+
manifest,
|
|
8
|
+
onEnable: async () => {
|
|
9
|
+
},
|
|
10
|
+
onDisable: async () => {
|
|
11
|
+
console.log("[Module:Sample] onDisable: Dropping all tables physically...");
|
|
12
|
+
try {
|
|
13
|
+
const tables = ["sample"];
|
|
14
|
+
for (const table of tables) {
|
|
15
|
+
await db.execute(sql.raw(`DROP TABLE IF EXISTS ${table} CASCADE`));
|
|
16
|
+
}
|
|
17
|
+
} catch (e) {
|
|
18
|
+
console.error("[Module:Sample] onDisable Error:", e);
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
routes: {
|
|
22
|
+
private: privateRoutes,
|
|
23
|
+
api: apiRoutes
|
|
24
|
+
},
|
|
25
|
+
navigation: {
|
|
26
|
+
admin: {
|
|
27
|
+
[i18n("General")]: [
|
|
28
|
+
{
|
|
29
|
+
id: "sample-settings",
|
|
30
|
+
title: i18n("Sample Configuration"),
|
|
31
|
+
url: "/sample/settings",
|
|
32
|
+
icon: "solar:box-bold-duotone"
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
export default module;
|
package/dist/intl.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type messages from "../locales/en/global.json";
|
|
2
|
+
|
|
3
|
+
type JsonDataType = typeof messages;
|
|
4
|
+
|
|
5
|
+
// declare global {
|
|
6
|
+
// interface IntlMessages extends JsonDataType {}
|
|
7
|
+
// }
|
|
8
|
+
|
|
9
|
+
declare module "@arch-cadre/intl" {
|
|
10
|
+
export interface IntlMessages extends JsonDataType {}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export {};
|
package/dist/routes.cjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.privateRoutes = exports.apiRoutes = void 0;
|
|
7
|
+
var _settingsPage = _interopRequireDefault(require("./ui/settings-page.cjs"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
const privateRoutes = exports.privateRoutes = [{
|
|
10
|
+
path: "/sample/settings",
|
|
11
|
+
// Będzie widoczne pod /sample/settings
|
|
12
|
+
component: _settingsPage.default,
|
|
13
|
+
auth: true
|
|
14
|
+
}];
|
|
15
|
+
const apiRoutes = exports.apiRoutes = [];
|
package/dist/routes.d.ts
ADDED
package/dist/routes.mjs
ADDED
package/dist/schema.cjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.sampleTable = exports.sampleSchema = void 0;
|
|
7
|
+
var _core = require("@arch-cadre/core");
|
|
8
|
+
var _pgCore = require("drizzle-orm/pg-core");
|
|
9
|
+
const sampleTable = exports.sampleTable = (0, _pgCore.pgTable)("sample", {
|
|
10
|
+
id: (0, _pgCore.text)("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
|
|
11
|
+
userId: (0, _pgCore.text)("user_id").references(() => _core.userTable.id, {
|
|
12
|
+
onDelete: "cascade"
|
|
13
|
+
}).notNull(),
|
|
14
|
+
createdAt: (0, _pgCore.timestamp)("created_at").defaultNow().notNull()
|
|
15
|
+
});
|
|
16
|
+
const sampleSchema = exports.sampleSchema = {
|
|
17
|
+
sampleTable
|
|
18
|
+
};
|
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
export declare const sampleTable: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
2
|
+
name: "sample";
|
|
3
|
+
schema: undefined;
|
|
4
|
+
columns: {
|
|
5
|
+
id: import("drizzle-orm/pg-core").PgBuildColumn<"sample", import("drizzle-orm/pg-core").SetHasRuntimeDefault<import("drizzle-orm/pg-core").SetIsPrimaryKey<import("drizzle-orm/pg-core").PgTextBuilder<[string, ...string[]]>>>, {
|
|
6
|
+
name: string;
|
|
7
|
+
tableName: "sample";
|
|
8
|
+
dataType: "string";
|
|
9
|
+
data: string;
|
|
10
|
+
driverParam: string;
|
|
11
|
+
notNull: true;
|
|
12
|
+
hasDefault: true;
|
|
13
|
+
isPrimaryKey: false;
|
|
14
|
+
isAutoincrement: false;
|
|
15
|
+
hasRuntimeDefault: false;
|
|
16
|
+
enumValues: undefined;
|
|
17
|
+
identity: undefined;
|
|
18
|
+
generated: undefined;
|
|
19
|
+
}>;
|
|
20
|
+
userId: import("drizzle-orm/pg-core").PgBuildColumn<"sample", import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgTextBuilder<[string, ...string[]]>>, {
|
|
21
|
+
name: string;
|
|
22
|
+
tableName: "sample";
|
|
23
|
+
dataType: "string";
|
|
24
|
+
data: string;
|
|
25
|
+
driverParam: string;
|
|
26
|
+
notNull: true;
|
|
27
|
+
hasDefault: false;
|
|
28
|
+
isPrimaryKey: false;
|
|
29
|
+
isAutoincrement: false;
|
|
30
|
+
hasRuntimeDefault: false;
|
|
31
|
+
enumValues: undefined;
|
|
32
|
+
identity: undefined;
|
|
33
|
+
generated: undefined;
|
|
34
|
+
}>;
|
|
35
|
+
createdAt: import("drizzle-orm/pg-core").PgBuildColumn<"sample", import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").SetHasDefault<import("drizzle-orm/pg-core").PgTimestampBuilder>>, {
|
|
36
|
+
name: string;
|
|
37
|
+
tableName: "sample";
|
|
38
|
+
dataType: "object date";
|
|
39
|
+
data: Date;
|
|
40
|
+
driverParam: string;
|
|
41
|
+
notNull: true;
|
|
42
|
+
hasDefault: true;
|
|
43
|
+
isPrimaryKey: false;
|
|
44
|
+
isAutoincrement: false;
|
|
45
|
+
hasRuntimeDefault: false;
|
|
46
|
+
enumValues: undefined;
|
|
47
|
+
identity: undefined;
|
|
48
|
+
generated: undefined;
|
|
49
|
+
}>;
|
|
50
|
+
};
|
|
51
|
+
dialect: "pg";
|
|
52
|
+
}>;
|
|
53
|
+
export declare const sampleSchema: {
|
|
54
|
+
sampleTable: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
55
|
+
name: "sample";
|
|
56
|
+
schema: undefined;
|
|
57
|
+
columns: {
|
|
58
|
+
id: import("drizzle-orm/pg-core").PgBuildColumn<"sample", import("drizzle-orm/pg-core").SetHasRuntimeDefault<import("drizzle-orm/pg-core").SetIsPrimaryKey<import("drizzle-orm/pg-core").PgTextBuilder<[string, ...string[]]>>>, {
|
|
59
|
+
name: string;
|
|
60
|
+
tableName: "sample";
|
|
61
|
+
dataType: "string";
|
|
62
|
+
data: string;
|
|
63
|
+
driverParam: string;
|
|
64
|
+
notNull: true;
|
|
65
|
+
hasDefault: true;
|
|
66
|
+
isPrimaryKey: false;
|
|
67
|
+
isAutoincrement: false;
|
|
68
|
+
hasRuntimeDefault: false;
|
|
69
|
+
enumValues: undefined;
|
|
70
|
+
identity: undefined;
|
|
71
|
+
generated: undefined;
|
|
72
|
+
}>;
|
|
73
|
+
userId: import("drizzle-orm/pg-core").PgBuildColumn<"sample", import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgTextBuilder<[string, ...string[]]>>, {
|
|
74
|
+
name: string;
|
|
75
|
+
tableName: "sample";
|
|
76
|
+
dataType: "string";
|
|
77
|
+
data: string;
|
|
78
|
+
driverParam: string;
|
|
79
|
+
notNull: true;
|
|
80
|
+
hasDefault: false;
|
|
81
|
+
isPrimaryKey: false;
|
|
82
|
+
isAutoincrement: false;
|
|
83
|
+
hasRuntimeDefault: false;
|
|
84
|
+
enumValues: undefined;
|
|
85
|
+
identity: undefined;
|
|
86
|
+
generated: undefined;
|
|
87
|
+
}>;
|
|
88
|
+
createdAt: import("drizzle-orm/pg-core").PgBuildColumn<"sample", import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").SetHasDefault<import("drizzle-orm/pg-core").PgTimestampBuilder>>, {
|
|
89
|
+
name: string;
|
|
90
|
+
tableName: "sample";
|
|
91
|
+
dataType: "object date";
|
|
92
|
+
data: Date;
|
|
93
|
+
driverParam: string;
|
|
94
|
+
notNull: true;
|
|
95
|
+
hasDefault: true;
|
|
96
|
+
isPrimaryKey: false;
|
|
97
|
+
isAutoincrement: false;
|
|
98
|
+
hasRuntimeDefault: false;
|
|
99
|
+
enumValues: undefined;
|
|
100
|
+
identity: undefined;
|
|
101
|
+
generated: undefined;
|
|
102
|
+
}>;
|
|
103
|
+
};
|
|
104
|
+
dialect: "pg";
|
|
105
|
+
}>;
|
|
106
|
+
};
|
package/dist/schema.mjs
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { userTable } from "@arch-cadre/core";
|
|
2
|
+
import { pgTable, text, timestamp } from "drizzle-orm/pg-core";
|
|
3
|
+
export const sampleTable = pgTable("sample", {
|
|
4
|
+
id: text("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
|
|
5
|
+
userId: text("user_id").references(() => userTable.id, { onDelete: "cascade" }).notNull(),
|
|
6
|
+
createdAt: timestamp("created_at").defaultNow().notNull()
|
|
7
|
+
});
|
|
8
|
+
export const sampleSchema = {
|
|
9
|
+
sampleTable
|
|
10
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
module.exports = SampleSettingsPage;
|
|
8
|
+
var _intl = require("@arch-cadre/intl");
|
|
9
|
+
var _button = require("@arch-cadre/ui/components/button");
|
|
10
|
+
var _card = require("@arch-cadre/ui/components/card");
|
|
11
|
+
var _input = require("@arch-cadre/ui/components/input");
|
|
12
|
+
var _label = require("@arch-cadre/ui/components/label");
|
|
13
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
14
|
+
var React = _react;
|
|
15
|
+
var _sonner = require("sonner");
|
|
16
|
+
var _settings = require("../actions/settings.cjs");
|
|
17
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
18
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
19
|
+
function SampleSettingsPage() {
|
|
20
|
+
const {
|
|
21
|
+
t
|
|
22
|
+
} = (0, _intl.useTranslation)();
|
|
23
|
+
const [config, setConfig] = (0, _react.useState)({
|
|
24
|
+
defaultVar: ""
|
|
25
|
+
});
|
|
26
|
+
const [loading, setLoading] = (0, _react.useState)(true);
|
|
27
|
+
(0, _react.useEffect)(() => {
|
|
28
|
+
(0, _settings.getSampleConfig)().then(data => {
|
|
29
|
+
setConfig(data);
|
|
30
|
+
setLoading(false);
|
|
31
|
+
});
|
|
32
|
+
}, []);
|
|
33
|
+
const handleSave = async e => {
|
|
34
|
+
e.preventDefault();
|
|
35
|
+
try {
|
|
36
|
+
await (0, _settings.updateSampleConfig)(config);
|
|
37
|
+
_sonner.toast.success(t("Settings saved successfully"));
|
|
38
|
+
} catch {
|
|
39
|
+
_sonner.toast.error(t("Failed to save settings"));
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
if (loading) return /* @__PURE__ */React.createElement("div", null, t("Loading Sample Settings..."));
|
|
43
|
+
return /* @__PURE__ */React.createElement("div", {
|
|
44
|
+
className: "container mx-auto py-10 max-w-2xl"
|
|
45
|
+
}, /* @__PURE__ */React.createElement(_card.Card, null, /* @__PURE__ */React.createElement(_card.CardHeader, null, /* @__PURE__ */React.createElement(_card.CardTitle, null, t("Sample Settings")), /* @__PURE__ */React.createElement(_card.CardDescription, null, t("Configure your Sample Configuration."))), /* @__PURE__ */React.createElement(_card.CardContent, null, /* @__PURE__ */React.createElement("form", {
|
|
46
|
+
onSubmit: handleSave,
|
|
47
|
+
className: "space-y-4"
|
|
48
|
+
}, /* @__PURE__ */React.createElement("div", {
|
|
49
|
+
className: "space-y-2"
|
|
50
|
+
}, /* @__PURE__ */React.createElement(_label.Label, {
|
|
51
|
+
htmlFor: "defaultVar"
|
|
52
|
+
}, t("Default Var")), /* @__PURE__ */React.createElement(_input.Input, {
|
|
53
|
+
id: "defaultVar",
|
|
54
|
+
value: config.defaultVar,
|
|
55
|
+
onChange: e => setConfig({
|
|
56
|
+
...config,
|
|
57
|
+
defaultVar: e.target.value
|
|
58
|
+
}),
|
|
59
|
+
placeholder: ""
|
|
60
|
+
})), /* @__PURE__ */React.createElement(_button.Button, {
|
|
61
|
+
type: "submit",
|
|
62
|
+
className: "w-full"
|
|
63
|
+
}, t("Save Configuration"))))));
|
|
64
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useTranslation } from "@arch-cadre/intl";
|
|
3
|
+
import { Button } from "@arch-cadre/ui/components/button";
|
|
4
|
+
import {
|
|
5
|
+
Card,
|
|
6
|
+
CardContent,
|
|
7
|
+
CardDescription,
|
|
8
|
+
CardHeader,
|
|
9
|
+
CardTitle
|
|
10
|
+
} from "@arch-cadre/ui/components/card";
|
|
11
|
+
import { Input } from "@arch-cadre/ui/components/input";
|
|
12
|
+
import { Label } from "@arch-cadre/ui/components/label";
|
|
13
|
+
import * as React from "react";
|
|
14
|
+
import { useEffect, useState } from "react";
|
|
15
|
+
import { toast } from "sonner";
|
|
16
|
+
import {
|
|
17
|
+
getSampleConfig,
|
|
18
|
+
updateSampleConfig
|
|
19
|
+
} from "../actions/settings.mjs";
|
|
20
|
+
export default function SampleSettingsPage() {
|
|
21
|
+
const { t } = useTranslation();
|
|
22
|
+
const [config, setConfig] = useState({
|
|
23
|
+
defaultVar: ""
|
|
24
|
+
});
|
|
25
|
+
const [loading, setLoading] = useState(true);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
getSampleConfig().then((data) => {
|
|
28
|
+
setConfig(data);
|
|
29
|
+
setLoading(false);
|
|
30
|
+
});
|
|
31
|
+
}, []);
|
|
32
|
+
const handleSave = async (e) => {
|
|
33
|
+
e.preventDefault();
|
|
34
|
+
try {
|
|
35
|
+
await updateSampleConfig(config);
|
|
36
|
+
toast.success(t("Settings saved successfully"));
|
|
37
|
+
} catch {
|
|
38
|
+
toast.error(t("Failed to save settings"));
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
if (loading) return /* @__PURE__ */ React.createElement("div", null, t("Loading Sample Settings..."));
|
|
42
|
+
return /* @__PURE__ */ React.createElement("div", { className: "container mx-auto py-10 max-w-2xl" }, /* @__PURE__ */ React.createElement(Card, null, /* @__PURE__ */ React.createElement(CardHeader, null, /* @__PURE__ */ React.createElement(CardTitle, null, t("Sample Settings")), /* @__PURE__ */ React.createElement(CardDescription, null, t("Configure your Sample Configuration."))), /* @__PURE__ */ React.createElement(CardContent, null, /* @__PURE__ */ React.createElement("form", { onSubmit: handleSave, className: "space-y-4" }, /* @__PURE__ */ React.createElement("div", { className: "space-y-2" }, /* @__PURE__ */ React.createElement(Label, { htmlFor: "defaultVar" }, t("Default Var")), /* @__PURE__ */ React.createElement(
|
|
43
|
+
Input,
|
|
44
|
+
{
|
|
45
|
+
id: "defaultVar",
|
|
46
|
+
value: config.defaultVar,
|
|
47
|
+
onChange: (e) => setConfig({ ...config, defaultVar: e.target.value }),
|
|
48
|
+
placeholder: ""
|
|
49
|
+
}
|
|
50
|
+
)), /* @__PURE__ */ React.createElement(Button, { type: "submit", className: "w-full" }, t("Save Configuration"))))));
|
|
51
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Settings saved successfully": "Settings saved successfully",
|
|
3
|
+
"Failed to save settings": "Failed to save settings",
|
|
4
|
+
"Loading Sample Settings...": "Loading Sample Settings...",
|
|
5
|
+
"Sample Settings": "Sample Settings",
|
|
6
|
+
"Configure your Sample Configuration.": "Configure your Sample Configuration.",
|
|
7
|
+
"Default Var": "Default Var",
|
|
8
|
+
"Save Configuration": "Save Configuration",
|
|
9
|
+
"General": "General",
|
|
10
|
+
"Sample Configuration": "Sample Configuration"
|
|
11
|
+
}
|
package/manifest.json
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@arch-cadre/sample-module",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Sample module for Kryo framework",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
"./package.json": "./package.json",
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.mjs",
|
|
11
|
+
"require": "./dist/index.cjs"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"locales",
|
|
17
|
+
"manifest.json"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"release": "npm publish --access public --no-git-checks",
|
|
21
|
+
"clean": "rm -rf ./dist",
|
|
22
|
+
"switch:dev": "node scripts/switchToSrc.js",
|
|
23
|
+
"switch:prod": "node scripts/switchToDist.js",
|
|
24
|
+
"dev": "unbuild --stub",
|
|
25
|
+
"build": "unbuild"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@hookform/resolvers": "^3.10.0",
|
|
29
|
+
"@arch-cadre/ui": "^0.0.15",
|
|
30
|
+
"@arch-cadre/modules": "^0.0.15",
|
|
31
|
+
"lucide-react": "^0.475.0",
|
|
32
|
+
"react-hook-form": "^7.54.2",
|
|
33
|
+
"drizzle-orm": "1.0.0-beta.15-859cf75",
|
|
34
|
+
"sonner": "^2.0.7",
|
|
35
|
+
"zod": "^3.24.1"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@arch-cadre/core": "^0.0.15",
|
|
39
|
+
"@types/react": "^19",
|
|
40
|
+
"next": "16.1.1",
|
|
41
|
+
"react": "^19.0.0",
|
|
42
|
+
"typescript": "^5.3.3",
|
|
43
|
+
"unbuild": "^3.6.1"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"@arch-cadre/core": "^0.0.15",
|
|
47
|
+
"@arch-cadre/intl": "^0.0.15",
|
|
48
|
+
"@arch-cadre/ui": "^0.0.15",
|
|
49
|
+
"next": ">=13.0.0",
|
|
50
|
+
"react": "^19.0.0"
|
|
51
|
+
},
|
|
52
|
+
"main": "./dist/index.mjs"
|
|
53
|
+
}
|