@opengis/admin 0.2.131 → 0.2.132

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.
@@ -1,21 +1,21 @@
1
- function onCheck(rule, data) {
2
- const val = data[rule[0]];
3
- // console.log(val, rule[1], rule[2])
4
- if (rule[1] === '==') return val === rule[2];
5
- if (rule[1] === '!=') return val !== rule[2];
6
- if (rule[1] === 'in' && rule[2].split) return rule[2].split(',').includes(val);
7
- if (rule[1] === 'in' && rule[2].includes) return rule[2].includes(val);
8
-
9
- if (rule[1] === 'not in' && rule[2].split) return !rule[2].split(',').includes(val);
10
- if (rule[1] === 'not in' && rule[2].includes) return !rule[2].includes(val);
11
-
12
- if (rule[1] === '>') return val > rule[2];
13
- if (rule[1] === '<') return val < rule[2];
14
- }
15
- export default function conditions(rules, data) {
16
- if (!rules?.length) return true;
17
- const result = Array.isArray(rules[0]) ? !rules.filter(el => !onCheck(el, data)).length : onCheck(rules, data)
18
- // console.log(rules, result)
19
- return result;
20
-
1
+ function onCheck(rule, data) {
2
+ const val = data[rule[0]];
3
+ // console.log(val, rule[1], rule[2])
4
+ if (rule[1] === '==') return val === rule[2];
5
+ if (rule[1] === '!=') return val !== rule[2];
6
+ if (rule[1] === 'in' && rule[2].split) return rule[2].split(',').includes(val);
7
+ if (rule[1] === 'in' && rule[2].includes) return rule[2].includes(val);
8
+
9
+ if (rule[1] === 'not in' && rule[2].split) return !rule[2].split(',').includes(val);
10
+ if (rule[1] === 'not in' && rule[2].includes) return !rule[2].includes(val);
11
+
12
+ if (rule[1] === '>') return val > rule[2];
13
+ if (rule[1] === '<') return val < rule[2];
14
+ }
15
+ export default function conditions(rules, data) {
16
+ if (!rules?.length) return true;
17
+ const result = Array.isArray(rules[0]) ? !rules.filter(el => !onCheck(el, data)).length : onCheck(rules, data)
18
+ // console.log(rules, result)
19
+ return result;
20
+
21
21
  }
@@ -1,6 +1,6 @@
1
1
 
2
2
  import { join } from 'path';
3
- import { userTemplateDir, config, pgClients } from '@opengis/fastify-table/utils.js';
3
+ import { userTemplateDir, pgClients, applyHook, config } from '@opengis/fastify-table/utils.js';
4
4
 
5
5
  import { existsSync, readdirSync, readFileSync } from 'fs';
6
6
  const menuCache = [];
@@ -30,11 +30,17 @@ async function readMenu() {
30
30
  return menus;
31
31
  }
32
32
  export default async function adminMenu({ user = {}, session, pg = pgClients.client }) {
33
+ const time = Date.now();
33
34
  if (!user.uid) return { status: 403, message: 'access restricted' }
34
35
 
35
36
  const menus = isProduction && menuCache.length ? menuCache : await readMenu();
36
37
 
38
+ const { rows } = await pgClients.client.query(`select property_key as key,property_text as val from admin.properties where property_key~'^(${config.settingKeys || 'site|map|admin'})'`);
39
+ const settings = rows.reduce((p, { key, val }) => { const [k1, k2] = key.split('.'); p[k1] = p[k1] || {}; p[k1][k2] = val; return p }, {});
37
40
  // update user access
41
+ const { user_name, sur_name, father_name, email, phone, uid } = user;
42
+ const result = { settings, user: { uid, user_name, sur_name, father_name, email, phone } };
43
+ await applyHook('userMenu', result);
38
44
 
39
45
  if (session && user?.uid && !user.user_type?.includes?.('admin') && !user.type?.includes?.('admin') && pg.pk['admin.role_access']) {
40
46
  const { type, gl = [], routes = [] } = await pg.query(`select user_type as type, b.gl,routes from admin.users a
@@ -54,13 +60,15 @@ export default async function adminMenu({ user = {}, session, pg = pgClients.cli
54
60
  session?.set?.('passport', { user });
55
61
  if (type === 'admin') return menus;
56
62
  const userMenus = menus.map(el => (el.menu ? { ...el, menu: el.menu.filter(item => routes?.includes(item.path)) } : el))
57
- return userMenus.filter(el => el.menu?.length || routes?.includes(el.path));
63
+ const menus = userMenus.filter(el => el.menu?.length || routes?.includes(el.path));
64
+ return { time: Date.now() - time, menus, ...result }
58
65
  // .filter((el, idx, arr) => arr.map((el) => el?.ua || el?.en || el?.name).indexOf(el?.ua || el?.en || el?.name) === idx)
59
66
  }
60
67
 
61
68
  // skip dupes?
62
69
  // .filter((el, idx, arr) => arr.map((el) => el?.ua || el?.en || el?.name).indexOf(el?.ua || el?.en || el?.name) === idx)
63
- return menus;
70
+
71
+ return { time: Date.now() - time, menus, ...result };
64
72
 
65
73
 
66
74
  }
@@ -0,0 +1,19 @@
1
+ import { pgClients } from '@opengis/fastify-table/utils.js';
2
+
3
+ export default async function adminMenu({ pg = pgClients.client }) {
4
+ const { rows = [] } = await pg.query(`select route_id, alias, table_name, title, enabled from admin.routes`);
5
+
6
+ const interfaces = rows
7
+ .filter((el, idx, arr) => el.table_name && arr.findIndex(item => item.route_id === el.route_id) === idx)
8
+ .filter(el => pg.pk?.[el.table_name || ''])
9
+ .filter(el => !['log.', 'admin.', 'setting.'].find(item => el.table_name.startsWith(item) ))
10
+ .map(el => ({
11
+ title: el.title,
12
+ alias: el.alias,
13
+ table: el.table_name,
14
+ route: el.route_id,
15
+ enabled: el.enabled,
16
+ }));
17
+
18
+ return interfaces;
19
+ }
@@ -1,5 +1,7 @@
1
1
  import getMenu from './controllers/getMenu.js';
2
+ import interfaces from './controllers/interfaces.js';
2
3
 
3
4
  export default async function (fastify, opts) {
4
5
  fastify.get(`/user-menu`, getMenu);
6
+ fastify.get(`/interfaces`, { config: { policy: ['admin'] } }, interfaces);
5
7
  }
@@ -48,13 +48,14 @@ export default async function printTemplate(req, reply) {
48
48
  const loadTable = await getTemplate('table', table);
49
49
  const { optimizedSQL } = await getFilterSQL({ table, pg });
50
50
 
51
- const where = `${loadTable?.key || pg.pk?.[loadTable?.table || table]}=$1`;
51
+ const where = `${loadTable?.key || pg.pk?.[loadTable?.table || table]}=any($1::text[])`;
52
52
 
53
53
  const q = `select * from (${optimizedSQL})q where ${loadTable?.query || '1=1'} and ${where}`;
54
54
 
55
- const obj = await pg.query(q, [params.id]).then(el => el.rows?.[0] || {});
55
+ const { rows = [] } = await pg.query(q, [params.id.split(',')]);
56
56
 
57
- const html = await handlebars.compile(body)(obj);
57
+ const htmls = await Promise.all(rows.map(async (row) => handlebars.compile(body)(row)));
58
+ const html = htmls.join('<p style="page-break-after: always;">&nbsp;</p>');
58
59
 
59
60
  if (format == 'html') {
60
61
  return reply.headers(headers).send(html);
@@ -1,6 +1,6 @@
1
1
  import { createHash } from 'node:crypto';
2
2
 
3
- import { config, getFilterSQL, getTemplate, handlebars, pgClients } from '@opengis/fastify-table/utils.js';
3
+ import { config, getFilterSQL, getTemplate, handlebars, pgClients, getMeta } from '@opengis/fastify-table/utils.js';
4
4
  import { grpc } from '@opengis/fastify-file/utils.js';
5
5
 
6
6
  const { htmlToPdf } = grpc();
@@ -50,17 +50,21 @@ export default async function printTemplate(req, reply) {
50
50
  return reply.headers(headers).send(buffer);
51
51
  }
52
52
 
53
+ const { alias, table } = await pg.query(`select alias, table_name as table from admin.routes where route_id=$1`, [route])
54
+ .then(el => el.rows?.[0] || {});
55
+
56
+ if (!alias || !table) {
57
+ return reply.status(404).send('route table not found');
58
+ }
59
+
53
60
  if (query?.demo) {
54
- const table = await pg.query(`select alias from admin.routes where route_id=$1`, [route])
55
- .then(el => el.rows?.[0]?.alias);
61
+ const loadTable = await getTemplate('table', alias);
62
+ const { optimizedSQL } = await getFilterSQL({ pg, table: alias });
56
63
 
57
- if (!table) {
58
- return reply.status(404).send('route table not found');
64
+ if (!optimizedSQL) {
65
+ return reply.status(400).send('empty query');
59
66
  }
60
67
 
61
- const loadTable = await getTemplate('table', table);
62
- const { optimizedSQL } = await getFilterSQL({ table, pg });
63
-
64
68
  const q = `select * from (${optimizedSQL})q where ${loadTable?.query || '1=1'} limit 1`;
65
69
 
66
70
  const obj = await pg.query(q).then(el => el.rows?.[0] || {});
@@ -76,6 +80,8 @@ export default async function printTemplate(req, reply) {
76
80
  return reply.headers(headers).send(buffer);
77
81
  }
78
82
 
83
+ const meta = await getMeta({ pg, table });
84
+ const columns = meta.columns?.map(el => ({ name: el.name, title: el.title, type: pg.pgType[el.dataTypeID] || 'text' }));
79
85
  // for body edit
80
- return { name, title, html: body, route };
86
+ return { name, title, html: body, route, alias, table, columns };
81
87
  }
@@ -6,7 +6,7 @@ function prepareResult(res) {
6
6
  const arr = (res.rows || (Array.isArray(res) ? res : Object.values(res || {})));
7
7
  return {
8
8
  command: 'INSERT',
9
- count: arr.filter((el) => el.command === 'INSERT')
9
+ count: res?.rowCount || arr.filter((el) => el.command === 'INSERT')
10
10
  ?.map((el) => ({ result: 'success', count: el.rowCount }))
11
11
  ?.reduce((acc, curr) => acc + curr.count, 0),
12
12
  };
@@ -37,13 +37,13 @@ export default async function refreshData({
37
37
  data?.forEach((el) => Object.assign(el, { id: el.id || randomUUID() }));
38
38
  await client.query('delete from setting.property where object_id=$1 and property_entity=$2', [table, entity]);
39
39
 
40
- const res = dataInsert({
40
+ const res = await dataInsert({
41
41
  pg: client,
42
42
  table: 'setting.property',
43
43
  data: {
44
44
  property_entity: entity,
45
45
  object_id: table,
46
- property_json: JSON.stringify(data)?.replace(/'/g, "''"),
46
+ property_json: JSON.stringify(data), // ?.replace(/'+/g, "'")?.replace(/'/g, "''")
47
47
  },
48
48
  uid,
49
49
  });
@@ -103,7 +103,7 @@ export default async function refreshData({
103
103
  await client.query('delete from setting.custom_field where $1 in (tablename, object_id)', [table]);
104
104
  await client.query('delete from setting.property where object_id=$1 and property_entity=$2', [table, entity]);
105
105
 
106
- const data2 = JSON.stringify(data1?.filter((value, index, array) => array.indexOf(value) === index))?.replace(/'/g, "''");
106
+ const data2 = JSON.stringify(data1?.filter((value, index, array) => array.indexOf(value) === index)); // ?.replace(/'+/g, "'")?.replace(/'/g, "''")
107
107
  const res = await dataInsert({
108
108
  pg: client,
109
109
  table: 'setting.property',
@@ -1,119 +0,0 @@
1
- import { _ as h, u as p, e as u } from "./import-file-C1vBdCEv.js";
2
- import { resolveComponent as d, openBlock as b, createElementBlock as g, createElementVNode as n, createBlock as f, normalizeStyle as x, createCommentVNode as w } from "vue";
3
- const y = {
4
- data() {
5
- return {
6
- formValues: {},
7
- scheme: null,
8
- table: "",
9
- token: "",
10
- api: "",
11
- style: null
12
- };
13
- },
14
- mounted() {
15
- this.getFormScheme();
16
- },
17
- methods: {
18
- flattenMenu(t) {
19
- const e = [];
20
- return t.forEach((o) => {
21
- o.menu ? e.push(...this.flattenMenu(o.menu)) : e.push(o);
22
- }), e;
23
- },
24
- async getFormScheme() {
25
- var i, a;
26
- const t = this.flattenMenu(p.value);
27
- t != null && t.length || this.$router.replace("/404");
28
- const e = t == null ? void 0 : t.find((r) => {
29
- var s, l;
30
- return (r == null ? void 0 : r.path) == ((l = (s = this.$route) == null ? void 0 : s.query) == null ? void 0 : l.table);
31
- });
32
- e || this.$router.replace("/404");
33
- const o = e == null ? void 0 : e.table;
34
- this.table = o;
35
- try {
36
- const r = await u.get(`/api/table-data/${o}`), { data: s } = await u.get(
37
- `/api/template/form/${(i = r == null ? void 0 : r.data) == null ? void 0 : i.form}`
38
- );
39
- this.scheme = (s == null ? void 0 : s.schema) || s, this.style = (s == null ? void 0 : s.style) || null, this.api = (s == null ? void 0 : s.api) || "", this.token = (a = r == null ? void 0 : r.data) == null ? void 0 : a.addToken;
40
- } catch {
41
- }
42
- },
43
- getGroupedErrorNotification(t, e) {
44
- debugger;
45
- if (!t || !e) return "";
46
- const o = {};
47
- return Object.entries(t).forEach(([a, r]) => {
48
- var l;
49
- const s = ((l = e[a]) == null ? void 0 : l.ua) || a;
50
- r.forEach((m) => {
51
- const c = m.message;
52
- o[c] || (o[c] = []), o[c].push(`"${s}"`);
53
- });
54
- }), Object.entries(o).map(([a, r]) => `<b>${a}:</b> ${r.join(", ")}`).join("<br>") || "Сталася помилка валідації";
55
- },
56
- async createObject() {
57
- var e;
58
- const t = this.$refs.form;
59
- try {
60
- await t.doValidation(), await u.post(
61
- this.api || `/api/table/${this.token}`,
62
- this.formValues
63
- ), await this.$router.back(), await this.$notify({
64
- title: "Успішно!",
65
- message: "Об'єкт успішно створено",
66
- type: "success"
67
- });
68
- } catch (o) {
69
- const i = this.getGroupedErrorNotification(
70
- t == null ? void 0 : t.formErrors,
71
- t == null ? void 0 : t.scheme
72
- );
73
- this.$notify({
74
- title: "Помилка!",
75
- message: ((e = o == null ? void 0 : o.response) == null ? void 0 : e.data) || i,
76
- type: "error"
77
- });
78
- }
79
- }
80
- }
81
- }, k = { class: "bg-gray-50 lg:w-[calc(100vw-260px)] w-[100vw]" }, v = { class: "h-[76px] mt-[15px] flex items-center justify-between mx-[20px] px-[20px] bg-white border rounded-xl" }, V = { class: "flex items-center gap-[6px]" }, _ = {
82
- style: { height: "calc(100vh - 165px)" },
83
- class: "bg-gray-50 p-[20px] flex lg:w-[calc(100vw-260px)] w-[100vw]"
84
- }, $ = { class: "bg-white w-full rounded-xl border p-[20px] overflow-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar:horizontal]:h-[8px] [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500" };
85
- function j(t, e, o, i, a, r) {
86
- const s = d("VsForm");
87
- return b(), g("div", k, [
88
- n("div", v, [
89
- e[3] || (e[3] = n("h2", { class: "text-xl font-medium" }, "Створити", -1)),
90
- n("div", V, [
91
- n("button", {
92
- onClick: e[0] || (e[0] = (l) => t.$router.back()),
93
- class: "flex items-center px-3 py-2 text-sm font-medium text-gray-800 duration-300 bg-white border border-gray-100 rounded-lg shadow gap-x-2 focus:outline-none hover:bg-gray-50 hover:border-gray-100"
94
- }, " Скасувати "),
95
- n("button", {
96
- onClick: e[1] || (e[1] = (...l) => r.createObject && r.createObject(...l)),
97
- class: "inline-flex items-center px-3 py-2 text-sm font-medium text-white duration-300 bg-blue-600 border border-transparent rounded-lg gap-x-2 hover:bg-blue-700 hover:text-white"
98
- }, " Зберегти ")
99
- ])
100
- ]),
101
- n("div", _, [
102
- n("div", $, [
103
- a.scheme ? (b(), f(s, {
104
- key: 0,
105
- ref: "form",
106
- scheme: a.scheme,
107
- style: x(a.style),
108
- modelValue: a.formValues,
109
- "onUpdate:modelValue": e[2] || (e[2] = (l) => a.formValues = l),
110
- class: "p-0 mt-[20px]"
111
- }, null, 8, ["scheme", "style", "modelValue"])) : w("", !0)
112
- ])
113
- ])
114
- ]);
115
- }
116
- const O = /* @__PURE__ */ h(y, [["render", j]]);
117
- export {
118
- O as default
119
- };
@@ -1,138 +0,0 @@
1
- import { _ as g, u as f, e as m } from "./import-file-C1vBdCEv.js";
2
- import { resolveComponent as y, openBlock as h, createElementBlock as x, createElementVNode as c, createBlock as w, normalizeStyle as k, createCommentVNode as v } from "vue";
3
- const $ = {
4
- data() {
5
- return {
6
- formValues: {},
7
- scheme: null,
8
- table: "",
9
- token: "",
10
- style: null
11
- };
12
- },
13
- mounted() {
14
- this.getFormScheme();
15
- },
16
- methods: {
17
- flattenMenu(e) {
18
- const t = [];
19
- return e.forEach((r) => {
20
- r.menu ? t.push(...this.flattenMenu(r.menu)) : t.push(r);
21
- }), t;
22
- },
23
- async getFormScheme() {
24
- var i, o;
25
- const e = this.flattenMenu(f.value);
26
- e != null && e.length || this.$router.replace("/404");
27
- const t = e == null ? void 0 : e.find((a) => {
28
- var n, s;
29
- return (a == null ? void 0 : a.path) == ((s = (n = this.$route) == null ? void 0 : n.query) == null ? void 0 : s.table);
30
- });
31
- t || this.$router.replace("/404");
32
- const r = t == null ? void 0 : t.table;
33
- this.table = r;
34
- try {
35
- const {
36
- data: { form: a }
37
- } = await m.get(`/api/template/table/${r}`), { data: n } = await m.get(
38
- `/api/table/${this.table}/${(o = (i = this.$route) == null ? void 0 : i.query) == null ? void 0 : o.id}`
39
- );
40
- this.token = (n == null ? void 0 : n.token) || "", this.formValues = n || {};
41
- const { data: s } = await m.get(`/api/template/form/${a}`);
42
- this.scheme = (s == null ? void 0 : s.schema) || s, this.style = (s == null ? void 0 : s.style) || null;
43
- } catch {
44
- }
45
- },
46
- async onlyEditObject() {
47
- var t, r, i, o, a, n, s, l, u;
48
- const e = this.$refs.form;
49
- try {
50
- await e.doValidation(), await m.put(`/api/table/${this.token}`, this.formValues), await this.$notify({
51
- title: "Успішно!",
52
- message: "Об'єкт успішно створено",
53
- type: "success"
54
- });
55
- } catch (b) {
56
- const d = ((t = b == null ? void 0 : b.response) == null ? void 0 : t.data) || "";
57
- let p = ((a = (o = (i = (r = Object.entries(e == null ? void 0 : e.formErrors)) == null ? void 0 : r[0]) == null ? void 0 : i[1]) == null ? void 0 : o[0]) == null ? void 0 : a.message) === "Це поле обов'язкове" ? "Заповніть обов'язкові поля" : (u = (l = (s = (n = Object.entries(e == null ? void 0 : e.formErrors)) == null ? void 0 : n[0]) == null ? void 0 : s[1]) == null ? void 0 : l[0]) == null ? void 0 : u.message;
58
- this.$notify({
59
- title: "Помилка!",
60
- message: d || p || "Сталася помилка валідаціі",
61
- type: "error"
62
- });
63
- }
64
- },
65
- getGroupedErrorNotification(e, t) {
66
- if (!e || !t) return "";
67
- const r = {};
68
- return Object.entries(e).forEach(([o, a]) => {
69
- var s;
70
- const n = ((s = t[o]) == null ? void 0 : s.ua) || o;
71
- a.forEach((l) => {
72
- const u = l.message;
73
- r[u] || (r[u] = []), r[u].push(`"${n}"`);
74
- });
75
- }), Object.entries(r).map(([o, a]) => `<b>${o}:</b> ${a.join(", ")}`).join("<br>") || "Сталася помилка валідації";
76
- },
77
- async editObjectAndRedirect() {
78
- const e = this.$refs.form;
79
- try {
80
- await e.doValidation(), await m.put(`/api/table/${this.token}`, this.formValues), await this.$router.back(), await this.$notify({
81
- title: "Успішно!",
82
- message: "Об'єкт успішно створено",
83
- type: "success"
84
- });
85
- } catch {
86
- const r = this.getGroupedErrorNotification(
87
- e == null ? void 0 : e.formErrors,
88
- e == null ? void 0 : e.scheme
89
- );
90
- this.$notify({
91
- title: "Помилка!",
92
- message: r,
93
- type: "error"
94
- });
95
- }
96
- }
97
- }
98
- }, V = { class: "bg-gray-50 lg:w-[calc(100vw-260px)] w-[100vw]" }, _ = { class: "h-[76px] mt-[15px] flex items-center justify-between mx-[20px] px-[20px] bg-white border rounded-xl" }, j = { class: "flex items-center gap-[6px]" }, E = {
99
- style: { height: "calc(100vh - 155px)" },
100
- class: "bg-gray-50 p-[20px] flex lg:w-[calc(100vw-260px)] w-[100vw]"
101
- }, O = { class: "bg-white w-full rounded-xl border p-[20px] overflow-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar:horizontal]:h-[8px] [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500" };
102
- function M(e, t, r, i, o, a) {
103
- var s;
104
- const n = y("VsForm");
105
- return h(), x("div", V, [
106
- c("div", _, [
107
- t[3] || (t[3] = c("h2", { class: "text-xl font-medium" }, "Редагувати", -1)),
108
- c("div", j, [
109
- c("button", {
110
- onClick: t[0] || (t[0] = (l) => e.$router.back()),
111
- class: "flex items-center px-3 py-2 text-sm font-medium text-gray-800 duration-300 bg-white border border-gray-100 rounded-lg shadow gap-x-2 focus:outline-none hover:bg-gray-50 hover:border-gray-100"
112
- }, " Скасувати "),
113
- c("button", {
114
- onClick: t[1] || (t[1] = (...l) => a.editObjectAndRedirect && a.editObjectAndRedirect(...l)),
115
- class: "inline-flex items-center px-3 py-2 text-sm font-medium text-white duration-300 bg-blue-600 border border-transparent rounded-lg gap-x-2 hover:bg-blue-700 hover:text-white"
116
- }, " Зберегти ")
117
- ])
118
- ]),
119
- c("div", E, [
120
- c("div", O, [
121
- o.scheme ? (h(), w(n, {
122
- key: 0,
123
- ref: "form",
124
- scheme: o.scheme,
125
- columns: (s = o.style) == null ? void 0 : s.columns,
126
- style: k(o.style),
127
- modelValue: o.formValues,
128
- "onUpdate:modelValue": t[2] || (t[2] = (l) => o.formValues = l),
129
- class: "p-0 mt-[20px]"
130
- }, null, 8, ["scheme", "columns", "style", "modelValue"])) : v("", !0)
131
- ])
132
- ])
133
- ]);
134
- }
135
- const N = /* @__PURE__ */ g($, [["render", M]]);
136
- export {
137
- N as default
138
- };
@@ -1,78 +0,0 @@
1
- import { _ as n, e as m } from "./import-file-C1vBdCEv.js";
2
- import { u as p } from "./user-B_2kh6ic.js";
3
- import { resolveComponent as d, openBlock as u, createElementBlock as f, createElementVNode as o, createBlock as h, createCommentVNode as b } from "vue";
4
- const x = {
5
- data() {
6
- return {
7
- formScheme: null,
8
- formValues: {}
9
- };
10
- },
11
- mounted() {
12
- this.getFormScheme();
13
- },
14
- computed: {
15
- userData() {
16
- return p.value;
17
- }
18
- },
19
- methods: {
20
- async updateUser() {
21
- var r;
22
- try {
23
- await m.put(`/user/${(r = this.userData.user) == null ? void 0 : r.uid}`, this.formValues), await this.$notify({
24
- title: "Успішно!",
25
- message: "Дані успішно оновлені",
26
- type: "success"
27
- });
28
- } catch {
29
- this.$notify({
30
- title: "Помилка!",
31
- message: "Сталася помилка",
32
- type: "error"
33
- });
34
- }
35
- },
36
- async getFormScheme() {
37
- var r, t, a, l;
38
- try {
39
- const { data: e } = await m.get(
40
- "/api/template/form/admin.profile.form"
41
- );
42
- console.log(this.userData);
43
- for (const s in e == null ? void 0 : e.schema)
44
- (t = (r = this.userData) == null ? void 0 : r.user) != null && t[s] && (this.formValues[s] = (l = (a = this.userData) == null ? void 0 : a.user) == null ? void 0 : l[s]);
45
- this.formScheme = e.schema;
46
- } catch (e) {
47
- console.error(e);
48
- }
49
- }
50
- }
51
- }, g = { class: "flex justify-center pt-[20px] pb-[20px] pl-[20px] h-[calc(100vh-58px)]" }, k = { class: "bg-white rounded-xl border p-[20px]" }, y = { class: "flex-1 overflow-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500" }, w = { class: "flex" };
52
- function _(r, t, a, l, e, s) {
53
- const i = d("VsForm");
54
- return u(), f("div", g, [
55
- o("div", k, [
56
- t[2] || (t[2] = o("h2", { class: "mb-[20px] text-center" }, "Профіль", -1)),
57
- o("div", y, [
58
- e.formScheme ? (u(), h(i, {
59
- key: 0,
60
- scheme: e.formScheme,
61
- modelValue: e.formValues,
62
- "onUpdate:modelValue": t[0] || (t[0] = (c) => e.formValues = c),
63
- class: "pb-0"
64
- }, null, 8, ["scheme", "modelValue"])) : b("", !0),
65
- o("div", w, [
66
- o("button", {
67
- onClick: t[1] || (t[1] = (...c) => s.updateUser && s.updateUser(...c)),
68
- class: "ml-auto text-[18px] bg-blue-500 text-white px-[8px] py-[4px] rounded hover:bg-blue-700 duration-300"
69
- }, " Зберегти ")
70
- ])
71
- ])
72
- ])
73
- ]);
74
- }
75
- const D = /* @__PURE__ */ n(x, [["render", _]]);
76
- export {
77
- D as default
78
- };
@@ -1,5 +0,0 @@
1
- import { ref as r } from "vue";
2
- const e = r(null);
3
- export {
4
- e as u
5
- };
@@ -1,6 +0,0 @@
1
- {
2
- "admin.title": {
3
- "type": "Text",
4
- "ua": "Назва"
5
- }
6
- }