Skip to content

Commit

Permalink
Fix/connect improvements: 커넥트 요청 모달 삭제, 커넥트 버튼 텍스트 오류 수정 (#166)
Browse files Browse the repository at this point in the history
* chore: 커넥트 요청 모달 삭제

* fix: 커넥트 버튼 텍스트가 올바르게 표시되지 않는 문제 해결

수정사항
- HomeCardBack.jsx, ConnectProfilePage.js
  - 상태 조회 함수(getConnectStatus)를 커넥트 관련 요청 후 호출하여 상태 변화가 반영되도록 수정
  • Loading branch information
nnyouung authored Oct 31, 2024
1 parent 294c513 commit 90a24a7
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 56 deletions.
17 changes: 2 additions & 15 deletions src/components/connect/ConnectProfileChatRequest.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,22 @@
import React, { useState } from "react";
import React from "react";
import { View, Text, TouchableOpacity, StyleSheet } from "react-native";
import { useTranslation } from "react-i18next";

import { CustomTheme } from "@styles/CustomTheme";

import ModalRequest from "@components/common/ModalRequest";

const { fontSub16 } = CustomTheme;

const ConnectProfileChatRequest = () => {
const { t } = useTranslation();
const [modalVisible, setModalVisible] = useState(false);

const pressButton = () => {
setModalVisible(true);
};

return (
<View style={styles.rectangle}>
<TouchableOpacity style={styles.chat}>
<Text style={styles.textChat}>{t("chat")}</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.request} onPress={pressButton}>
<TouchableOpacity style={styles.request}>
<Text style={styles.textRequest}>{t("requestButtonText")}</Text>
</TouchableOpacity>
<ModalRequest
modalVisible={modalVisible}
setModalVisible={setModalVisible}
textLoading={t("connectRequestInProgress")}
textComplete={t("connectRequestComplete")}
/>
</View>
);
};
Expand Down
23 changes: 8 additions & 15 deletions src/components/home/HomeCardBack.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@ import { getMyMemberId } from "util/secureStoreUtils";

import HomecardDifeB from "@components/home/HomecardDifeB";
import HomeProfile from "@components/home/HomeProfile";
import HomecardBackBtn from "@components/home/HomecardBackBtn.js";
import ModalRequest from "@components/common/ModalRequest";
import HomecardBackBtn from "@components/home/HomecardBackBtn";

const { fontCaption } = CustomTheme;

const HomeCardBack = ({ memberId, fileId, name, onPress }) => {
const { t } = useTranslation();
const navigation = useNavigation();

const [modalVisible, setModalVisible] = useState(false);
const [connectStatus, setConnectStatus] = useState(undefined);
const [connectId, setConnectId] = useState();
const [requestSent, setRequestSent] = useState(false);
Expand All @@ -35,7 +33,7 @@ const HomeCardBack = ({ memberId, fileId, name, onPress }) => {
setConnectId(response.data.id);

const myMebmberId = await getMyMemberId();
setRequestSent(response.data.from_member.id == myMebmberId);
setRequestSent(response.data.from_member.id === myMebmberId);
} catch (error) {
Sentry.captureException(error);
console.error(
Expand All @@ -45,10 +43,15 @@ const HomeCardBack = ({ memberId, fileId, name, onPress }) => {
}
};

useEffect(() => {
getConnectStatus();
}, []);

const requestConnect = async () => {
try {
const response = await requestConnectById(memberId);
setConnectStatus(response.data.status);
getConnectStatus();
} catch (error) {
Sentry.captureException(error);
console.error(
Expand All @@ -58,14 +61,11 @@ const HomeCardBack = ({ memberId, fileId, name, onPress }) => {
}
};

useEffect(() => {
getConnectStatus();
}, [connectStatus]);

const deleteConnect = async () => {
try {
await rejectedConnectByConnectId(connectId);
setConnectStatus(undefined);
getConnectStatus();
} catch (error) {
Sentry.captureException(error);
console.error(
Expand All @@ -77,7 +77,6 @@ const HomeCardBack = ({ memberId, fileId, name, onPress }) => {

const pressButton = () => {
if (connectStatus === undefined) {
setModalVisible(true);
requestConnect();
} else {
deleteConnect();
Expand Down Expand Up @@ -147,12 +146,6 @@ const HomeCardBack = ({ memberId, fileId, name, onPress }) => {
onPress={pressButton}
/>
</View>
<ModalRequest
modalVisible={modalVisible}
setModalVisible={setModalVisible}
textLoading={t("connectRequestInProgress")}
textComplete={t("connectRequestComplete")}
/>
</View>
);
};
Expand Down
15 changes: 4 additions & 11 deletions src/pages/connect/ConnectProfilePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import ConnectProfileIntroduction from "@components/connect/ConnectProfileIntrod
import ConnectProfileTag from "@components/connect/ConnectProfileTag";
import BottomTwoButtons from "@components/common/BottomTwoButtons";
import ConnectProfileLanguage from "@components/connect/ConnectProfileLanguage";
import ModalRequest from "@components/common/ModalRequest";
import * as Sentry from "@sentry/react-native";

const ConnectProfilePage = ({ route }) => {
Expand All @@ -32,7 +31,6 @@ const ConnectProfilePage = ({ route }) => {
const [connectStatus, setConnectStatus] = useState(undefined);
const [connectId, setConnectId] = useState();
const [requestSent, setRequestSent] = useState(false);
const [modalConnectVisible, setModalConnectVisible] = useState(false);
const [heart, setHeart] = useState(false);

const getConnectProfile = async () => {
Expand Down Expand Up @@ -73,12 +71,13 @@ const ConnectProfilePage = ({ route }) => {

useEffect(() => {
getConnectStatus();
}, [connectStatus]);
}, []);

const requestConnect = async () => {
try {
const response = await requestConnectById(memberId);
setConnectStatus(response.data.status);
getConnectStatus();
} catch (error) {
Sentry.captureException(error);
console.error(
Expand All @@ -91,6 +90,7 @@ const ConnectProfilePage = ({ route }) => {
const handleAcceptedConnect = async () => {
try {
await acceptedConnectByMemberId(memberId);
getConnectStatus();
} catch (error) {
console.error(
"커넥트 수락 오류:",
Expand All @@ -103,6 +103,7 @@ const ConnectProfilePage = ({ route }) => {
try {
await rejectedConnectByConnectId(connectId);
setConnectStatus(undefined);
getConnectStatus();
} catch (error) {
Sentry.captureException(error);
console.error(
Expand All @@ -114,7 +115,6 @@ const ConnectProfilePage = ({ route }) => {

const handleConnect = () => {
if (connectStatus === undefined) {
setModalConnectVisible(true);
requestConnect();
} else if (connectStatus === "PENDING") {
if (requestSent) {
Expand All @@ -125,7 +125,6 @@ const ConnectProfilePage = ({ route }) => {
} else {
handleConnectAlert();
}
getConnectStatus();
};

const handleConnectAlert = () => {
Expand Down Expand Up @@ -250,12 +249,6 @@ const ConnectProfilePage = ({ route }) => {
/>
</BottomTwoButtons>
</View>
<ModalRequest
modalVisible={modalConnectVisible}
setModalVisible={setModalConnectVisible}
textLoading={t("connectRequestInProgress")}
textComplete={t("connectRequestComplete")}
/>
</SafeAreaView>
);
};
Expand Down
3 changes: 0 additions & 3 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,6 @@
"checkInfo": "Please check if the information is correct",
"createGroupButton": "Create Group",

"connectRequestInProgress": "Connect request in progress",
"connectRequestComplete": "Connect request complete!",

"max3Selection": "Up to 3 selections allowed",
"mbti": "MBTI",
"hobby": "Hobby/Interest",
Expand Down
3 changes: 0 additions & 3 deletions src/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,6 @@
"checkInfo": "Por favor, verifica si la información es correcta",
"createGroupButton": "Crear Grupo",

"connectRequestInProgress": "Solicitud de conexión en progreso",
"connectRequestComplete": "¡Solicitud de conexión completada!",

"max3Selection": "Se permiten hasta 3 selecciones",
"mbti": "MBTI",
"hobby": "Pasatiempos/Intereses",
Expand Down
3 changes: 0 additions & 3 deletions src/translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,6 @@
"checkInfo": "入力した情報が正しいか確認してください",
"createGroupButton": "グループ作成",

"connectRequestInProgress": "接続リクエスト中",
"connectRequestComplete": "接続リクエスト完了!",

"max3Selection": "最大3つまで選択可能",
"mbti": "MBTI",
"hobby": "趣味/関心",
Expand Down
3 changes: 0 additions & 3 deletions src/translations/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,6 @@
"checkInfo": "입력한 정보가 맞는지 확인해주세요",
"createGroupButton": "그룹 생성하기",

"connectRequestInProgress": "커넥트 요청중",
"connectRequestComplete": "커넥트 요청 완료!",

"max3Selection": "최대 3개까지 선택 가능",
"mbti": "MBTI",
"hobby": "취미/관심사",
Expand Down
3 changes: 0 additions & 3 deletions src/translations/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,6 @@
"checkInfo": "请检查信息是否正确",
"createGroupButton": "创建群组",

"connectRequestInProgress": "连接请求处理中",
"connectRequestComplete": "连接请求完成!",

"max3Selection": "最多选择3个",
"mbti": "MBTI",
"hobby": "爱好/兴趣",
Expand Down

0 comments on commit 90a24a7

Please sign in to comment.