fix: profile fields are not updated after modifying the profile (#291)

This commit is contained in:
Suemor 2024-09-08 09:55:56 +08:00 committed by GitHub
parent a73b4abe22
commit b7653494b7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 3 deletions

View File

@ -1,5 +1,5 @@
import { zodResolver } from "@hookform/resolvers/zod"
import { useWhoami } from "@renderer/atoms/user"
import { setWhoami, useWhoami } from "@renderer/atoms/user"
import { Button } from "@renderer/components/ui/button"
import {
Form,
@ -51,7 +51,10 @@ export function Component() {
apiClient["auth-app"]["update-account"].$patch({
json: values,
}),
onSuccess: () => {
onSuccess: (_, variables) => {
if (user && variables) {
setWhoami({ ...user, ...variables })
}
toast("Profile updated.", {
duration: 3000,
})
@ -109,7 +112,12 @@ export function Component() {
)}
/>
<div className="text-right">
<Button type="submit">Submit</Button>
<Button
type="submit"
isLoading={updateMutation.isPending}
>
Submit
</Button>
</div>
</form>
</Form>