diff --git a/README.md b/README.md index af9c1ac..0625fd9 100644 --- a/README.md +++ b/README.md @@ -52,8 +52,7 @@ Dieser Client ist ein React Hook und kann in jeder React Komponente verwendet we import {usePB} from "@/lib/pocketbase" import {useQuery} from "@tanstack/react-query"; -const {pb} = usePB() -const user = useUser() +const {pb,user} = usePB() const query = useQuery({ queryKey: ["collection", id], diff --git a/src/components/auth/LdapUserInput.tsx b/src/components/auth/UserInput.tsx similarity index 80% rename from src/components/auth/LdapUserInput.tsx rename to src/components/auth/UserInput.tsx index 711890b..17e4b13 100644 --- a/src/components/auth/LdapUserInput.tsx +++ b/src/components/auth/UserInput.tsx @@ -1,17 +1,17 @@ import {useMutation} from "@tanstack/react-query"; import {IconUsers} from "@tabler/icons-react"; import {usePB} from "@/lib/pocketbase.tsx"; -import {LdapUserModel} from "@/models/AuthTypes.ts"; +import {UserModal} from "@/models/AuthTypes.ts"; import RecordSearchInput, {GenericRecordSearchInputProps} from "../input/RecordSearchInput.tsx"; -export default function LdapUserInput(props: GenericRecordSearchInputProps) { +export default function UserInput(props: GenericRecordSearchInputProps) { const {pb} = usePB() return ( + recordToString={(user) => ({displayName: `${user.givenName} ${user.sn}`})} {...props} placeholder={props.placeholder || "Suche nach Personen..."} @@ -23,7 +23,7 @@ export default function LdapUserInput(props: GenericRecordSearchInputProps s.trim()).join(".") }%")`, diff --git a/src/components/auth/LdapUsersDisplay.tsx b/src/components/auth/UsersDisplay.tsx similarity index 51% rename from src/components/auth/LdapUsersDisplay.tsx rename to src/components/auth/UsersDisplay.tsx index 69fc7dc..e2dd226 100644 --- a/src/components/auth/LdapUsersDisplay.tsx +++ b/src/components/auth/UsersDisplay.tsx @@ -1,18 +1,18 @@ -import {LdapUserModel} from "@/models/AuthTypes.ts"; +import {UserModal} from "@/models/AuthTypes.ts"; import {List} from "@mantine/core"; import {IconUser} from "@tabler/icons-react"; import {usePB} from "@/lib/pocketbase.tsx"; -export default function LdapUsersDisplay({users}: { users: LdapUserModel[] }) { +export default function UsersDisplay({users}: { users: UserModal[] }) { - const {ldapUser} = usePB() + const {user} = usePB() return <> }> { users.map((u) => ( - - {u.givenName} {u.sn} + + {u.username} )) } diff --git a/src/components/auth/modals/ChangeEmailModal.tsx b/src/components/auth/modals/ChangeEmailModal.tsx index 2de6495..14f0a99 100644 --- a/src/components/auth/modals/ChangeEmailModal.tsx +++ b/src/components/auth/modals/ChangeEmailModal.tsx @@ -8,7 +8,6 @@ import {showSuccessNotification} from "@/components/util.tsx"; import {useSearchParams} from "react-router-dom"; import EmailSVG from "@/illustrations/email.svg?react" -import {useUser} from "@/lib/user.ts"; import PromptLoginModal from "@/components/auth/modals/PromptLoginModal.tsx"; export const CHANGE_EMAIL_TOKEN_KEY = "changeEmailToken" @@ -31,7 +30,7 @@ const RequestEmailChangeModal = ({open, onClose}: { const mutation = useMutation({ mutationFn: async () => { - await pb.collection("guest_users").requestEmailChange(formValues.values.email) + await pb.collection("users").requestEmailChange(formValues.values.email) }, onSuccess: () => { formValues.reset() @@ -96,7 +95,7 @@ const ConfirmEmailChangeModal = ({open, onClose, token}: { const mutation = useMutation({ mutationFn: async () => { - await pb.collection("guest_users").confirmEmailChange( + await pb.collection("users").confirmEmailChange( token, formValues.values.password, ) @@ -115,7 +114,7 @@ const ConfirmEmailChangeModal = ({open, onClose, token}: {
mutation.mutate())}>
- +
@@ -153,7 +152,7 @@ const ConfirmEmailChangeModal = ({open, onClose, token}: { export default function ChangeEmailModal() { const {value, handler} = useChangeEmail() - const user = useUser() + const {user} = usePB() const [searchParams] = useSearchParams() diff --git a/src/components/auth/modals/EmailTokenVerification.tsx b/src/components/auth/modals/EmailTokenVerification.tsx index c14827b..1835b35 100644 --- a/src/components/auth/modals/EmailTokenVerification.tsx +++ b/src/components/auth/modals/EmailTokenVerification.tsx @@ -6,7 +6,6 @@ import {showErrorNotification, showSuccessNotification} from "@/components/util. import {Alert, Button, Group, Modal, TextInput, Title} from "@mantine/core"; import {IconAt} from "@tabler/icons-react"; import {useLogin} from "@/components/auth/modals/hooks.ts"; -import {useUser} from "@/lib/user.ts"; export const EMAIL_TOKEN_KEY = "emailVerificationToken" @@ -29,13 +28,11 @@ export default function EmailTokenVerification() { const [email, setEmail] = useState("") - const {pb, refreshUser} = usePB() - - const user = useUser() + const {pb, user, refreshUser} = usePB() const verifyTokenMutation = useMutation({ mutationFn: async (token: string) => { - await pb.collection("guest_users").confirmVerification(token) + await pb.collection("users").confirmVerification(token) }, onSuccess: () => { showSuccessNotification("E-Mail erfolgreich verifiziert") @@ -77,7 +74,7 @@ export default function EmailTokenVerification() {