Skip to content

Commit f1ca028

Browse files
committed
Create friend request confirmation dialog
1 parent be8d9ce commit f1ca028

3 files changed

Lines changed: 56 additions & 4 deletions

File tree

app/web/features/connections/friends/AddFriendButton.tsx

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
import { useMutation, useQueryClient } from "@tanstack/react-query";
22
import Button from "components/Button";
3+
import {
4+
Dialog,
5+
DialogActions,
6+
DialogContent,
7+
DialogTitle,
8+
} from "components/Dialog";
39
import { PersonAddIcon } from "components/Icons";
410
import ProfileIncompleteDialog from "components/ProfileIncompleteDialog/ProfileIncompleteDialog";
511
import { doAntibot } from "features/antibot/antibot";
612
import useAccountInfo from "features/auth/useAccountInfo";
713
import { userKey } from "features/queryKeys";
814
import { Empty } from "google-protobuf/google/protobuf/empty_pb";
9-
import { PROFILE } from "i18n/namespaces";
10-
import { useTranslation } from "next-i18next";
15+
import { Link } from "@mui/material";
16+
import { Trans, useTranslation } from "i18n";
17+
import { CONNECTIONS, GLOBAL, PROFILE } from "i18n/namespaces";
1118
import { User } from "proto/api_pb";
1219
import React, { useState } from "react";
20+
import { helpCenterFriendRequestsURL } from "routes";
1321
import { service } from "service";
1422

1523
import { SetMutationError } from ".";
@@ -24,9 +32,10 @@ export default function AddFriendButton({
2432
userId,
2533
}: AddFriendButtonProps) {
2634
const queryClient = useQueryClient();
27-
const { t } = useTranslation([PROFILE]);
35+
const { t } = useTranslation([PROFILE, CONNECTIONS, GLOBAL]);
2836
const [showCantFriendDialog, setShowCantFriendDialog] =
2937
useState<boolean>(false);
38+
const [showConfirmDialog, setShowConfirmDialog] = useState<boolean>(false);
3039

3140
const { data: accountInfo, isLoading: isAccountInfoLoading } =
3241
useAccountInfo();
@@ -76,17 +85,53 @@ export default function AddFriendButton({
7685
if (!accountInfo?.profileComplete) {
7786
setShowCantFriendDialog(true);
7887
} else {
79-
sendFriendRequest({ setMutationError, userId });
88+
setShowConfirmDialog(true);
8089
}
8190
};
8291

92+
const onConfirm = () => {
93+
setShowConfirmDialog(false);
94+
sendFriendRequest({ setMutationError, userId });
95+
};
96+
8397
return (
8498
<>
8599
<ProfileIncompleteDialog
86100
open={showCantFriendDialog}
87101
onClose={() => setShowCantFriendDialog(false)}
88102
attempted_action="send_friend_request"
89103
/>
104+
<Dialog
105+
aria-labelledby="add-friend-confirm-dialog"
106+
open={showConfirmDialog}
107+
onClose={() => setShowConfirmDialog(false)}
108+
>
109+
<DialogTitle id="add-friend-confirm-dialog">
110+
{t("connections:add_friend_confirmation_dialog.title")}
111+
</DialogTitle>
112+
<DialogContent>
113+
<Trans
114+
i18nKey="connections:add_friend_confirmation_dialog.message"
115+
components={{
116+
helpCenterLink: (
117+
<Link
118+
href={helpCenterFriendRequestsURL}
119+
target="_blank"
120+
rel="noopener noreferrer"
121+
/>
122+
),
123+
}}
124+
/>
125+
</DialogContent>
126+
<DialogActions>
127+
<Button variant="outlined" onClick={() => setShowConfirmDialog(false)}>
128+
{t("global:cancel")}
129+
</Button>
130+
<Button variant="contained" loading={isPending} onClick={onConfirm}>
131+
{t("connections:add_friend_confirmation_dialog.confirm")}
132+
</Button>
133+
</DialogActions>
134+
</Dialog>
90135
<Button
91136
startIcon={<PersonAddIcon />}
92137
onClick={onClick}

app/web/features/connections/locales/en.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
{
22
"add_friend": "Add friend",
3+
"add_friend_confirmation_dialog": {
4+
"title": "Do you know this person?",
5+
"message": "Please only send friend requests to people you already know or have met during your travels — most people prefer to connect after meeting in person. <helpCenterLink>Read about friend requests in our Help Center.</helpCenterLink>",
6+
"confirm": "Yes, I know them. Send request!"
7+
},
38
"accept": "Accept",
49
"decline": "Decline",
510
"blocked_list_title": "Blocked users",

app/web/routes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@ export const helpCenterHowToLeaveGoodReferenceUrl =
223223
"https://help.couchers.org/hc/couchersorg-help-center/articles/1717360836-how-to";
224224
export const helpCenterCommunityBuilderURL =
225225
"https://help.couchers.org/hc/couchersorg-help-center/articles/1743977410-what-is-a-community-builder";
226+
export const helpCenterFriendRequestsURL =
227+
"https://help.couchers.org/hc/couchersorg-help-center/articles/1715125657-can-i-add-anyone-as-a-friend";
226228
export const communityGuidelinesURL =
227229
"https://help.couchers.org/hc/couchersorg-help-center/articles/1715121703-couchers-org-community-guidelines";
228230
// Note: Url must end with financials year digits

0 commit comments

Comments
 (0)