transcriptor-web/bootstrap/ssr/assets/UpdatePasswordForm-B_100APE.js
2025-04-05 15:58:14 +02:00

121 lines
4.3 KiB
JavaScript

import { jsxs, jsx, Fragment } from "react/jsx-runtime";
import { useForm } from "@inertiajs/react";
import classNames from "classnames";
import { useRef } from "react";
import { u as useRoute } from "../app.js";
import { A as ActionMessage } from "./ActionMessage-s_mcCJ3s.js";
import { F as FormSection } from "./FormSection-DI6t3wFC.js";
import { T as TextInput, I as InputError } from "./TextInput-CMJy2hIv.js";
import { I as InputLabel } from "./InputLabel-DhqxoV6M.js";
import { P as PrimaryButton } from "./PrimaryButton-C2B8UWiv.js";
import "axios";
import "lodash";
import "react-dom/client";
import "@headlessui/react";
import "./SectionTitle-DnuUNpyS.js";
function UpdatePasswordForm() {
const route = useRoute();
const form = useForm({
current_password: "",
password: "",
password_confirmation: ""
});
const passwordRef = useRef(null);
const currentPasswordRef = useRef(null);
function updatePassword() {
form.put(route("user-password.update"), {
errorBag: "updatePassword",
preserveScroll: true,
onSuccess: () => form.reset(),
onError: () => {
var _a, _b;
if (form.errors.password) {
form.reset("password", "password_confirmation");
(_a = passwordRef.current) == null ? void 0 : _a.focus();
}
if (form.errors.current_password) {
form.reset("current_password");
(_b = currentPasswordRef.current) == null ? void 0 : _b.focus();
}
}
});
}
return /* @__PURE__ */ jsxs(
FormSection,
{
onSubmit: updatePassword,
title: "Update Password",
description: "Ensure your account is using a long, random password to stay secure.",
renderActions: () => /* @__PURE__ */ jsxs(Fragment, { children: [
/* @__PURE__ */ jsx(ActionMessage, { on: form.recentlySuccessful, className: "mr-3", children: "Saved." }),
/* @__PURE__ */ jsx(
PrimaryButton,
{
className: classNames({ "opacity-25": form.processing }),
disabled: form.processing,
children: "Save"
}
)
] }),
children: [
/* @__PURE__ */ jsxs("div", { className: "col-span-6 sm:col-span-4", children: [
/* @__PURE__ */ jsx(InputLabel, { htmlFor: "current_password", children: "Current Password" }),
/* @__PURE__ */ jsx(
TextInput,
{
id: "current_password",
type: "password",
className: "mt-1 block w-full",
ref: currentPasswordRef,
value: form.data.current_password,
onChange: (e) => form.setData("current_password", e.currentTarget.value),
autoComplete: "current-password"
}
),
/* @__PURE__ */ jsx(InputError, { message: form.errors.current_password, className: "mt-2" })
] }),
/* @__PURE__ */ jsxs("div", { className: "col-span-6 sm:col-span-4", children: [
/* @__PURE__ */ jsx(InputLabel, { htmlFor: "password", children: "New Password" }),
/* @__PURE__ */ jsx(
TextInput,
{
id: "password",
type: "password",
className: "mt-1 block w-full",
value: form.data.password,
onChange: (e) => form.setData("password", e.currentTarget.value),
autoComplete: "new-password",
ref: passwordRef
}
),
/* @__PURE__ */ jsx(InputError, { message: form.errors.password, className: "mt-2" })
] }),
/* @__PURE__ */ jsxs("div", { className: "col-span-6 sm:col-span-4", children: [
/* @__PURE__ */ jsx(InputLabel, { htmlFor: "password_confirmation", children: "Confirm Password" }),
/* @__PURE__ */ jsx(
TextInput,
{
id: "password_confirmation",
type: "password",
className: "mt-1 block w-full",
value: form.data.password_confirmation,
onChange: (e) => form.setData("password_confirmation", e.currentTarget.value),
autoComplete: "new-password"
}
),
/* @__PURE__ */ jsx(
InputError,
{
message: form.errors.password_confirmation,
className: "mt-2"
}
)
] })
]
}
);
}
export {
UpdatePasswordForm as default
};