(
-
-
-
-
-
-
- {t("whatsapp_number_same_as_phone_number")}
-
-
-
- )}
- />
-
-
();
const { t } = useTranslation();
const authUser = useAuthUser();
+ const { goBack } = useAppHistory();
if (!username) {
username = authUser.username;
}
const loggedInUser = username === authUser.username;
- const { loading, refetch: refetchUserDetails } = useTanStackQueryInstead(
- routes.getUserDetails,
- {
+ const {
+ data: userData,
+ isLoading,
+ isError,
+ } = useQuery({
+ queryKey: ["getUserDetails", username],
+ queryFn: query(routes.getUserDetails, {
pathParams: {
username: username,
},
- onResponse: ({ res, data, error }) => {
- if (res?.status === 200 && data) {
- setUserData(data);
- } else if (res?.status === 400) {
- navigate("/users");
- } else if (error) {
- toast.error(
- t("error_fetching_user_details") + (error?.message || ""),
- );
- }
- },
- },
- );
+ }),
+ });
+
+ if (isError) {
+ goBack("/");
+ }
- if (loading || !userData) {
+ if (isLoading || !userData) {
return ;
}
@@ -124,7 +122,7 @@ export default function UserHome(props: UserHomeProps) {
return (