Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | 3x 3x 3x 3x 3x 3x 3x 19x 25x 25x 25x 25x 25x 3x 1x 2x | import Button from "components/Button";
import ProfileIncompleteDialog from "components/ProfileIncompleteDialog/ProfileIncompleteDialog";
import useAccountInfo from "features/auth/useAccountInfo";
import useMessageUser from "features/profile/hooks/useMessageUser";
import { useTranslation } from "i18n";
import { PROFILE } from "i18n/namespaces";
import { User } from "proto/api_pb";
import { useState } from "react";
export default function MessageUserButton({
user,
setMutationError,
setIsMessaging,
}: {
user: User.AsObject;
setMutationError: (value: string) => void;
setIsMessaging: (value: boolean) => void;
}) {
const { t } = useTranslation(PROFILE);
const { mutate, isPending } = useMessageUser({
userId: user.userId,
setMutationError,
setIsMessaging,
});
const [showCantMessageDialog, setShowCantMessageDialog] =
useState<boolean>(false);
const { data: accountInfo, isLoading: isAccountInfoLoading } =
useAccountInfo();
const onClick = () => {
if (!accountInfo?.profileComplete) {
setShowCantMessageDialog(true);
} else {
mutate();
}
};
return (
<>
<ProfileIncompleteDialog
open={showCantMessageDialog}
onClose={() => setShowCantMessageDialog(false)}
attempted_action="send_message"
/>
<Button
loading={isPending}
onClick={onClick}
disabled={isAccountInfoLoading}
>
{t("actions.message_label")}
</Button>
</>
);
}
|