Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
baynt1 committed Oct 15, 2024
1 parent afde7b9 commit f39ca7c
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/features/settings/new-user/new-user.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,32 @@ export const NewUser: FC<INewUserProps> = ({ open, handleModal, item, refetch })
try {
const axiosInstance = await getAxiosInstance()
if (item && item.id) {
const posts = data.posts
? data.posts.map((post) => {
return {
post: post,
user: item.id,
}
})
: []

await axiosInstance
.patch(`/users/${item.id}`, {
...data,
name: data.name.trim(),
email: data.email.trim(),
password: data.password.trim(),
password: data.password ? data.password.trim() : undefined,
})
.then(() => {
openNotification('Пользователь изменен', 'success')
handleModal()
refetch()
setLoading(false)
})
await axiosInstance.post('/posts-users-access', posts)
await axiosInstance.patch(`/posts-users-access/user/${item.id}`, {
posts: data.posts?.map((pst) => pst.value),
})
} else {
await axiosInstance
.post('/users', {
...data,
name: data.name.trim(),
email: data.email.trim(),
password: data.password.trim(),
password: data.password ? data.password.trim() : undefined,
})
.then(() => {
.then((res) => {
console.log(res)
openNotification('Пользователь создан', 'success')
handleModal()
refetch()
Expand Down

0 comments on commit f39ca7c

Please sign in to comment.