mirror of
https://github.com/stonith404/pingvin-share.git
synced 2025-01-15 01:14:27 -05:00
fix: unable to update user privileges
This commit is contained in:
parent
c795b988df
commit
d4a0f1a4f1
3 changed files with 21 additions and 15 deletions
|
@ -1,4 +1,4 @@
|
||||||
import { PartialType } from "@nestjs/mapped-types";
|
import { PartialType } from "@nestjs/mapped-types";
|
||||||
import { UserDTO } from "./user.dto";
|
import { CreateUserDTO } from "./createUser.dto";
|
||||||
|
|
||||||
export class UpdateUserDto extends PartialType(UserDTO) {}
|
export class UpdateUserDto extends PartialType(CreateUserDTO) {}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Group,
|
Group,
|
||||||
Input,
|
|
||||||
PasswordInput,
|
PasswordInput,
|
||||||
Stack,
|
Stack,
|
||||||
Switch,
|
Switch,
|
||||||
|
@ -51,7 +50,7 @@ const Body = ({
|
||||||
<Stack>
|
<Stack>
|
||||||
<form
|
<form
|
||||||
onSubmit={form.onSubmit(async (values) => {
|
onSubmit={form.onSubmit(async (values) => {
|
||||||
console.log(values)
|
console.log(values);
|
||||||
userService
|
userService
|
||||||
.create(values)
|
.create(values)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
@ -72,10 +71,12 @@ const Body = ({
|
||||||
label="New password"
|
label="New password"
|
||||||
{...form.getInputProps("password")}
|
{...form.getInputProps("password")}
|
||||||
/>
|
/>
|
||||||
|
<Switch
|
||||||
|
mt="xs"
|
||||||
<Switch labelPosition="left" label="Admin privileges" {...form.getInputProps("isAdmin")} />
|
labelPosition="left"
|
||||||
|
label="Admin privileges"
|
||||||
|
{...form.getInputProps("isAdmin", { type: "checkbox" })}
|
||||||
|
/>
|
||||||
<Group position="right">
|
<Group position="right">
|
||||||
<Button type="submit">Create</Button>
|
<Button type="submit">Create</Button>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
|
@ -4,6 +4,7 @@ import {
|
||||||
Group,
|
Group,
|
||||||
PasswordInput,
|
PasswordInput,
|
||||||
Stack,
|
Stack,
|
||||||
|
Switch,
|
||||||
TextInput,
|
TextInput,
|
||||||
Title,
|
Title,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
|
@ -36,8 +37,9 @@ const Body = ({
|
||||||
}) => {
|
}) => {
|
||||||
const accountForm = useForm({
|
const accountForm = useForm({
|
||||||
initialValues: {
|
initialValues: {
|
||||||
username: user?.username,
|
username: user.username,
|
||||||
email: user?.email,
|
email: user.email,
|
||||||
|
isAdmin: user.isAdmin,
|
||||||
},
|
},
|
||||||
validate: yupResolver(
|
validate: yupResolver(
|
||||||
yup.object().shape({
|
yup.object().shape({
|
||||||
|
@ -64,10 +66,7 @@ const Body = ({
|
||||||
id="accountForm"
|
id="accountForm"
|
||||||
onSubmit={accountForm.onSubmit(async (values) => {
|
onSubmit={accountForm.onSubmit(async (values) => {
|
||||||
userService
|
userService
|
||||||
.update(user.id, {
|
.update(user.id, values)
|
||||||
email: values.email,
|
|
||||||
username: values.username,
|
|
||||||
})
|
|
||||||
.then(() => {
|
.then(() => {
|
||||||
getUsers();
|
getUsers();
|
||||||
modals.closeAll();
|
modals.closeAll();
|
||||||
|
@ -85,11 +84,17 @@ const Body = ({
|
||||||
label="Email"
|
label="Email"
|
||||||
{...accountForm.getInputProps("email")}
|
{...accountForm.getInputProps("email")}
|
||||||
/>
|
/>
|
||||||
|
<Switch
|
||||||
|
mt="xs"
|
||||||
|
labelPosition="left"
|
||||||
|
label="Admin privileges"
|
||||||
|
{...accountForm.getInputProps("isAdmin", {type: "checkbox"})}
|
||||||
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</form>
|
</form>
|
||||||
<Accordion>
|
<Accordion>
|
||||||
<Accordion.Item sx={{ borderBottom: "none" }} value="changePassword">
|
<Accordion.Item sx={{ borderBottom: "none" }} value="changePassword">
|
||||||
<Accordion.Control>Passwort ändern</Accordion.Control>
|
<Accordion.Control>Change password</Accordion.Control>
|
||||||
<Accordion.Panel>
|
<Accordion.Panel>
|
||||||
<form
|
<form
|
||||||
onSubmit={passwordForm.onSubmit(async (values) => {
|
onSubmit={passwordForm.onSubmit(async (values) => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue