-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from Selleo/jw/user-management
feat: user management view
- Loading branch information
Showing
21 changed files
with
498 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
examples/common_nestjs_remix/apps/web/app/api/mutations/useChangePassword.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { useMutation } from "@tanstack/react-query"; | ||
import { AxiosError } from "axios"; | ||
import { toast } from "sonner"; | ||
import { ApiClient } from "../api-client"; | ||
import { ChangePasswordBody } from "../generated-api"; | ||
import { useCurrentUserSuspense } from "../queries/useCurrentUser"; | ||
|
||
type ChangePasswordOptions = { | ||
data: ChangePasswordBody; | ||
}; | ||
|
||
export function useChangePassword() { | ||
const { data: currentUser } = useCurrentUserSuspense(); | ||
|
||
return useMutation({ | ||
mutationFn: async (options: ChangePasswordOptions) => { | ||
const response = await ApiClient.users.usersControllerChangePassword( | ||
currentUser.id, | ||
options.data | ||
); | ||
|
||
return response.data; | ||
}, | ||
onSuccess: () => { | ||
toast.success("Password updated successfully"); | ||
}, | ||
onError: (error) => { | ||
if (error instanceof AxiosError) { | ||
return toast.error(error.response?.data.message); | ||
} | ||
toast.error(error.message); | ||
}, | ||
}); | ||
} |
9 changes: 5 additions & 4 deletions
9
examples/common_nestjs_remix/apps/web/app/api/mutations/useLoginUser.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.