mirror of
https://github.com/Radiquum/AniX.git
synced 2025-04-27 16:39:38 +05:00
feat: mutate profile page if successful change
This commit is contained in:
parent
61eb728442
commit
2d200b84f2
4 changed files with 17 additions and 2 deletions
|
@ -3,6 +3,7 @@
|
|||
import { Button, Modal, Textarea } from "flowbite-react";
|
||||
import { ENDPOINTS } from "#/api/config";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useSWRConfig } from "swr";
|
||||
|
||||
export const ProfileEditStatusModal = (props: {
|
||||
isOpen: boolean;
|
||||
|
@ -10,10 +11,12 @@ export const ProfileEditStatusModal = (props: {
|
|||
token: string;
|
||||
status: string;
|
||||
setStatus: (status: string) => void;
|
||||
profile_id: number;
|
||||
}) => {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [_status, _setStatus] = useState("");
|
||||
const [_stringLength, _setStringLength] = useState(0);
|
||||
const { mutate } = useSWRConfig();
|
||||
|
||||
useEffect(() => {
|
||||
_setStatus(props.status);
|
||||
|
@ -38,6 +41,9 @@ export const ProfileEditStatusModal = (props: {
|
|||
})
|
||||
.then((res) => {
|
||||
if (res.ok) {
|
||||
mutate(
|
||||
`${ENDPOINTS.user.profile}/${props.profile_id}?token=${props.token}`
|
||||
);
|
||||
setLoading(false);
|
||||
props.setStatus(_status);
|
||||
props.setIsOpen(false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue