@opengis/surveyor 0.0.4 → 0.0.6

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.
@@ -0,0 +1,111 @@
1
+ import { t as e } from "./_plugin-vue_export-helper-B3ysoDQm.js";
2
+ import { s as t } from "./surveyor-CDkI2Dcp.js";
3
+ import { t as n } from "./AppIcon-CO70tpMX.js";
4
+ import { computed as r, createCommentVNode as i, createElementBlock as a, createElementVNode as o, createTextVNode as s, createVNode as c, defineComponent as l, openBlock as u, ref as d, toDisplayString as f, vModelText as p, withCtx as m, withDirectives as h, withModifiers as g } from "vue";
5
+ import { RouterLink as _, useRoute as v, useRouter as y } from "vue-router";
6
+ //#region cabinet/src/pages/password/reset.vue?vue&type=script&setup=true&lang.ts
7
+ var b = "Мінімум 8 символів", x = /*@__PURE__*/ l({
8
+ __name: "reset",
9
+ setup(e, { expose: i }) {
10
+ i();
11
+ let a = v(), o = y(), s = d(""), c = d(""), l = d(""), u = d(!1), f = r(() => String(a.params.token ?? "").trim()), p = r(() => /^[A-Za-z0-9_-]{32,256}$/.test(f.value));
12
+ function m(e) {
13
+ let t = e instanceof Error ? e.message : "";
14
+ return /invalid or expired/i.test(t) ? "Посилання недійсне або строк його дії минув" : /does not match/i.test(t) ? "Паролі не збігаються" : /fewer than 8|minLength|at least 8/i.test(t) ? b : t || "Не вдалося змінити пароль";
15
+ }
16
+ function h() {
17
+ return p.value ? s.value.length < 8 ? b : s.value === c.value ? null : "Паролі не збігаються" : "Посилання недійсне: відсутній або некоректний токен";
18
+ }
19
+ async function g() {
20
+ l.value = "";
21
+ let e = h();
22
+ if (e) {
23
+ l.value = e;
24
+ return;
25
+ }
26
+ u.value = !0;
27
+ try {
28
+ await t(f.value, s.value, c.value), await o.push({
29
+ name: "login",
30
+ query: { reset: "1" }
31
+ });
32
+ } catch (e) {
33
+ l.value = m(e);
34
+ } finally {
35
+ u.value = !1;
36
+ }
37
+ }
38
+ let x = {
39
+ route: a,
40
+ router: o,
41
+ password: s,
42
+ passwordConfirmation: c,
43
+ error: l,
44
+ submitting: u,
45
+ token: f,
46
+ tokenValid: p,
47
+ passwordHint: b,
48
+ userMessage: m,
49
+ validate: h,
50
+ submit: g,
51
+ AppIcon: n,
52
+ get RouterLink() {
53
+ return _;
54
+ }
55
+ };
56
+ return Object.defineProperty(x, "__isScriptSetup", {
57
+ enumerable: !1,
58
+ value: !0
59
+ }), x;
60
+ }
61
+ }), S = { class: "flex min-h-screen items-center justify-center bg-gradient-to-br from-brand-50 via-white to-slate-100 px-4" }, C = { class: "w-full max-w-md" }, w = { class: "mb-8 text-center" }, T = { class: "mx-auto mb-4 flex h-14 w-14 items-center justify-center rounded-2xl bg-gradient-to-br from-brand-100 to-brand-200 shadow-lg shadow-brand-600/20 ring-1 ring-brand-200/60" }, E = { class: "block text-sm font-medium text-slate-700" }, D = { class: "mt-4 block text-sm font-medium text-slate-700" }, O = {
62
+ key: 0,
63
+ class: "mt-4 text-sm text-red-600"
64
+ }, k = {
65
+ key: 1,
66
+ class: "mt-4 text-sm text-red-600"
67
+ }, A = ["disabled"], j = { class: "mt-6 text-center text-sm text-slate-500" };
68
+ function M(e, t, n, r, l, d) {
69
+ return u(), a("div", S, [o("div", C, [o("div", w, [
70
+ o("div", T, [c(r.AppIcon, {
71
+ name: "map-pinned",
72
+ class: "h-7 w-7 text-brand-600"
73
+ })]),
74
+ t[2] ||= o("h1", { class: "text-2xl font-semibold text-slate-900" }, "Новий пароль", -1),
75
+ t[3] ||= o("p", { class: "mt-1 text-sm text-slate-500" }, "Встановіть новий пароль для входу в кабінет геодезиста", -1)
76
+ ]), o("form", {
77
+ class: "rounded-2xl border border-slate-200 bg-white p-8 shadow-sm",
78
+ onSubmit: g(r.submit, ["prevent"])
79
+ }, [
80
+ o("label", E, [t[4] ||= s(" Пароль ", -1), h(o("input", {
81
+ "onUpdate:modelValue": t[0] ||= (e) => r.password = e,
82
+ type: "password",
83
+ autocomplete: "new-password",
84
+ placeholder: r.passwordHint,
85
+ class: "mt-1.5 h-10 w-full rounded-lg border border-slate-200 bg-white px-3 text-sm text-slate-700 outline-none transition-colors placeholder:text-slate-400 focus:border-brand-400 focus:ring-1 focus:ring-brand-400"
86
+ }, null, 512), [[p, r.password]])]),
87
+ o("label", D, [t[5] ||= s(" Підтвердження пароля ", -1), h(o("input", {
88
+ "onUpdate:modelValue": t[1] ||= (e) => r.passwordConfirmation = e,
89
+ type: "password",
90
+ autocomplete: "new-password",
91
+ placeholder: "Повторіть пароль",
92
+ class: "mt-1.5 h-10 w-full rounded-lg border border-slate-200 bg-white px-3 text-sm text-slate-700 outline-none transition-colors placeholder:text-slate-400 focus:border-brand-400 focus:ring-1 focus:ring-brand-400"
93
+ }, null, 512), [[p, r.passwordConfirmation]])]),
94
+ r.tokenValid ? r.error ? (u(), a("p", k, f(r.error), 1)) : i("", !0) : (u(), a("p", O, "Посилання недійсне або строк його дії минув")),
95
+ o("button", {
96
+ type: "submit",
97
+ class: "mt-4 w-full rounded-xl bg-brand-600 py-2.5 text-sm font-semibold text-white transition-colors hover:bg-brand-700 disabled:cursor-not-allowed disabled:opacity-60",
98
+ disabled: r.submitting || !r.tokenValid
99
+ }, f(r.submitting ? "Збереження…" : "Зберегти пароль"), 9, A),
100
+ o("p", j, [t[7] ||= s(" Згадали пароль? ", -1), c(r.RouterLink, {
101
+ to: "/login",
102
+ class: "font-medium text-brand-700 hover:text-brand-900 hover:underline"
103
+ }, {
104
+ default: m(() => [...t[6] ||= [s(" Увійти ", -1)]]),
105
+ _: 1
106
+ })])
107
+ ], 32)])]);
108
+ }
109
+ var N = /*#__PURE__*/ e(x, [["render", M], ["__file", "C:/softpro/surveyor/cabinet/src/pages/password/reset.vue"]]);
110
+ //#endregion
111
+ export { N as default };
@@ -0,0 +1,92 @@
1
+ import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
2
+ //#region cabinet/src/api/surveyor.ts
3
+ var t = /* @__PURE__ */ e({
4
+ apiUrl: () => n,
5
+ changeSurveyorPassword: () => i,
6
+ completeSurveyorRegistration: () => s,
7
+ fetchSurveyorUser: () => c,
8
+ loginSurveyor: () => l,
9
+ parseApiError: () => r,
10
+ requestPasswordReset: () => a,
11
+ resetSurveyorPassword: () => o
12
+ });
13
+ function n(e) {
14
+ return `${"".replace(/\/$/, "")}${e}`;
15
+ }
16
+ function r(e, t) {
17
+ let n = e || `HTTP ${t}`;
18
+ try {
19
+ let t = JSON.parse(e);
20
+ n = (typeof t.error == "object" ? t.error.message : void 0) || t.message || (typeof t.error == "string" ? t.error : n);
21
+ } catch {}
22
+ return n;
23
+ }
24
+ async function i(e) {
25
+ let t = await fetch(n(`/api/surveyor/change_password/${encodeURIComponent(e.surveyorId)}`), {
26
+ method: "POST",
27
+ credentials: "include",
28
+ headers: { "Content-Type": "application/json" },
29
+ body: JSON.stringify({
30
+ password: e.password,
31
+ password_confirmation: e.passwordConfirmation
32
+ })
33
+ });
34
+ if (!t.ok) throw Error(r(await t.text(), t.status));
35
+ return t.json();
36
+ }
37
+ async function a(e) {
38
+ let t = await fetch(n("/api/surveyor/password/forgot"), {
39
+ method: "POST",
40
+ credentials: "include",
41
+ headers: { "Content-Type": "application/json" },
42
+ body: JSON.stringify({ email: e.trim().toLowerCase() })
43
+ });
44
+ if (!t.ok) throw Error(r(await t.text(), t.status));
45
+ return t.json();
46
+ }
47
+ async function o(e, t, i) {
48
+ let a = await fetch(n(`/api/surveyor/password/reset/${encodeURIComponent(e)}`), {
49
+ method: "POST",
50
+ credentials: "include",
51
+ headers: { "Content-Type": "application/json" },
52
+ body: JSON.stringify({
53
+ password: t,
54
+ password_confirmation: i
55
+ })
56
+ });
57
+ if (!a.ok) throw Error(r(await a.text(), a.status));
58
+ return a.json();
59
+ }
60
+ async function s(e, t, i) {
61
+ let a = await fetch(n(`/api/surveyor/registration/${encodeURIComponent(e)}/complete`), {
62
+ method: "POST",
63
+ credentials: "include",
64
+ headers: { "Content-Type": "application/json" },
65
+ body: JSON.stringify({
66
+ password: t,
67
+ password_confirmation: i
68
+ })
69
+ });
70
+ if (!a.ok) throw Error(r(await a.text(), a.status));
71
+ return a.json();
72
+ }
73
+ async function c() {
74
+ let e = await fetch(n("/api/surveyor/user"), { credentials: "include" });
75
+ if (!e.ok) throw Error(r(await e.text(), e.status));
76
+ return e.json();
77
+ }
78
+ async function l(e, t) {
79
+ let i = await fetch(n("/api/surveyor/login"), {
80
+ method: "POST",
81
+ credentials: "include",
82
+ headers: { "Content-Type": "application/json" },
83
+ body: JSON.stringify({
84
+ email: e.trim().toLowerCase(),
85
+ password: t
86
+ })
87
+ });
88
+ if (!i.ok) throw Error(r(await i.text(), i.status));
89
+ return i.json();
90
+ }
91
+ //#endregion
92
+ export { r as a, t as c, c as i, i as n, a as o, s as r, o as s, n as t };