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 { 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 {
|
||||
Button,
|
||||
Group,
|
||||
Input,
|
||||
PasswordInput,
|
||||
Stack,
|
||||
Switch,
|
||||
|
@ -51,7 +50,7 @@ const Body = ({
|
|||
<Stack>
|
||||
<form
|
||||
onSubmit={form.onSubmit(async (values) => {
|
||||
console.log(values)
|
||||
console.log(values);
|
||||
userService
|
||||
.create(values)
|
||||
.then(() => {
|
||||
|
@ -72,10 +71,12 @@ const Body = ({
|
|||
label="New password"
|
||||
{...form.getInputProps("password")}
|
||||
/>
|
||||
|
||||
|
||||
<Switch labelPosition="left" label="Admin privileges" {...form.getInputProps("isAdmin")} />
|
||||
|
||||
<Switch
|
||||
mt="xs"
|
||||
labelPosition="left"
|
||||
label="Admin privileges"
|
||||
{...form.getInputProps("isAdmin", { type: "checkbox" })}
|
||||
/>
|
||||
<Group position="right">
|
||||
<Button type="submit">Create</Button>
|
||||
</Group>
|
||||
|
|
|
@ -4,6 +4,7 @@ import {
|
|||
Group,
|
||||
PasswordInput,
|
||||
Stack,
|
||||
Switch,
|
||||
TextInput,
|
||||
Title,
|
||||
} from "@mantine/core";
|
||||
|
@ -36,8 +37,9 @@ const Body = ({
|
|||
}) => {
|
||||
const accountForm = useForm({
|
||||
initialValues: {
|
||||
username: user?.username,
|
||||
email: user?.email,
|
||||
username: user.username,
|
||||
email: user.email,
|
||||
isAdmin: user.isAdmin,
|
||||
},
|
||||
validate: yupResolver(
|
||||
yup.object().shape({
|
||||
|
@ -64,10 +66,7 @@ const Body = ({
|
|||
id="accountForm"
|
||||
onSubmit={accountForm.onSubmit(async (values) => {
|
||||
userService
|
||||
.update(user.id, {
|
||||
email: values.email,
|
||||
username: values.username,
|
||||
})
|
||||
.update(user.id, values)
|
||||
.then(() => {
|
||||
getUsers();
|
||||
modals.closeAll();
|
||||
|
@ -85,11 +84,17 @@ const Body = ({
|
|||
label="Email"
|
||||
{...accountForm.getInputProps("email")}
|
||||
/>
|
||||
<Switch
|
||||
mt="xs"
|
||||
labelPosition="left"
|
||||
label="Admin privileges"
|
||||
{...accountForm.getInputProps("isAdmin", {type: "checkbox"})}
|
||||
/>
|
||||
</Stack>
|
||||
</form>
|
||||
<Accordion>
|
||||
<Accordion.Item sx={{ borderBottom: "none" }} value="changePassword">
|
||||
<Accordion.Control>Passwort ändern</Accordion.Control>
|
||||
<Accordion.Control>Change password</Accordion.Control>
|
||||
<Accordion.Panel>
|
||||
<form
|
||||
onSubmit={passwordForm.onSubmit(async (values) => {
|
||||
|
|
Loading…
Add table
Reference in a new issue