Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix][마이페이지] 대표타이틀 수정 및 ImagePicker 이슈 보류 #116

Merged
merged 5 commits into from
Mar 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/constants/title/titleData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,30 @@ export const titleMetaArr = [
introduction: '모든 타이틀 달성',
},
];

export const titleNameToId = {
'시작이 반': 1000,
'위대한 첫 도약': 2000,
'초보 기록가': 2001,
'중급 기록가': 2002,
'고급 기록가': 2003,
'인사이트의 신': 2004,
'혼자서도 잘 해요': 2005,
'두근두근 첫만남': 3000,
'자타공인 인기인': 3001,
'피리부는 사나이': 3002,
'정이 많은': 3003,
'참 잘했어요': 4000,
'아낌없이 주는 나무': 4001,
'키위새들의 픽': 4002,
'챌린지 메이커': 5000,
'실패는 성공의 어머니': 5001,
'첫번째 완주': 5002,
'쉬지않고 도전하는': 5003,
'혼자 보기 아까운': 6000,
'인사이트 수집가': 7000,
'간직하고 싶은 인사이트': 7001,
'함께하는 즐거움': 8000,
마당발: 8001,
'Shall We Keewe?': 9000,
};
13 changes: 8 additions & 5 deletions src/screens/Feed/FeedItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,26 @@ import FeedTextContent from './FeedTextContent';
import { REACTIONS } from './constant';
import ReactIconButton from '../../components/emoticons/ReactIconButton';
import { useNavigation } from '@react-navigation/native';
import { getUserId } from '../../utils/hooks/asyncStorage/Login';

interface FeedItemProps {
insight: InsightData;
localId?: string;
onBookMarkClick: (id: number) => void;
}

const FeedItem = ({ insight, onBookMarkClick }: FeedItemProps) => {
const FeedItem = ({ insight, localId, onBookMarkClick }: FeedItemProps) => {
const { id, contents, createdAt, link, reaction, writer, bookmark } = insight;
const navigation = useNavigation();
const handleOnBookMarkPress = () => {
onBookMarkClick(id);
};

const handleProfilePress = async () => {
const localId = await getUserId();
if (localId === '' + writer.writerId)
const handleProfilePress = () => {
if (localId === null || localId === undefined) {
alert('잠시 후 다시 시도하세요.');
return;
}
if (localId === String(writer.writerId))
navigation.navigate('MyPage', { userId: localId, enteredByTab: false });
else navigation.navigate('Profile', { userId: writer.writerId });
};
Expand Down
18 changes: 14 additions & 4 deletions src/screens/Feed/FeedList.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { RefreshControl, StyleSheet, Text, View } from 'react-native';
import { RefreshControl, StyleSheet } from 'react-native';
import React, { Fragment, useState } from 'react';
import { InfiniteData, QueryClient, UseMutateFunction } from '@tanstack/react-query';
import { InsightData } from '../../types/Feed/Feedinsights';
import { IOScrollView, InView } from 'react-native-intersection-observer';
import FeedItem from './FeedItem';
import { FeedQueryKeys } from '../../utils/api/FeedAPI';
import { UserSpecificChallengeQueryKeys } from '../../utils/api/UserSpecificChallenge';
import { useGetUserId } from '../../utils/hooks/useGetUserId';

interface FeedListProps {
feedList: InfiniteData<InsightData[] | undefined> | undefined;
Expand All @@ -28,7 +29,7 @@ const FeedList = ({
writer,
}: FeedListProps) => {
const [pageRefreshing, setPageRefreshing] = useState(false);

const userId = useGetUserId();
const onRefresh = () => {
setPageRefreshing(true);
feedListQueryClient.invalidateQueries(FeedQueryKeys.getFeed());
Expand Down Expand Up @@ -60,13 +61,22 @@ const FeedList = ({
if (group.length - 1 === idx && feedList.pages.length - 1 === i) {
return (
<InView key={insight.id} onChange={() => fetchNextPage()}>
<FeedItem onBookMarkClick={touchBookMark} insight={insight} />
<FeedItem
onBookMarkClick={touchBookMark}
insight={insight}
localId={String(userId)}
/>
</InView>
);
}
return (
<Fragment key={insight.id}>
<FeedItem onBookMarkClick={touchBookMark} key={insight.id} insight={insight} />
<FeedItem
onBookMarkClick={touchBookMark}
key={insight.id}
insight={insight}
localId={String(userId)}
/>
</Fragment>
);
})}
Expand Down
4 changes: 2 additions & 2 deletions src/screens/Feed/FeedScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { useEffect, useRef } from 'react';
import React, { useRef } from 'react';
import FeedList from './FeedList';
import { useInfiniteFeed } from '../../utils/hooks/feedInifiniteScroll/useInfiniteFeed';
import FeedScreenChallenge from '../../components/challenge/FeedScreenChallenge';
import { useFocusEffect, useScrollToTop } from '@react-navigation/native';
import { useScrollToTop } from '@react-navigation/native';
import GoToUploadButton from '../../components/buttons/GoToUploadButton';
import { useQueryClient } from '@tanstack/react-query';
import { FeedQueryKeys } from '../../utils/api/FeedAPI';
Expand Down
1 change: 0 additions & 1 deletion src/screens/Main/mypage/MyPageScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import GoToUploadButton from '../../../components/buttons/GoToUploadButton';
import { IOScrollView } from 'react-native-intersection-observer';
import HeaderBackButton from '../../../components/header/HeaderBackButton';
import { useScrollToTop } from '@react-navigation/native';
//import RNFadedScrollView from 'rn-faded-scrollview';

const MyPageScreen = ({ navigation, route }) => {
const { userId } = route.params;
Expand Down
33 changes: 17 additions & 16 deletions src/screens/Main/mypage/ProfileEditScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import * as ImagePicker from 'expo-image-picker';
import { getAccessToken } from '../../../utils/hooks/asyncStorage/Login';
import axios from 'axios';
import mime from 'mime';
import { titleNameToId } from '../../../constants/title/titleData';

const ProfileEditScreen = ({ navigation, route }) => {
const theme = useTheme();
Expand Down Expand Up @@ -131,11 +132,12 @@ const ProfileEditScreen = ({ navigation, route }) => {
const handleShotPress = () => openCamera();

const pickImage = async () => {
const permissionResult = await ImagePicker.requestMediaLibraryPermissionsAsync();
if (permissionResult.granted === false) {
changePermission();
return;
}
// BUG: Android에 권한 부여 원할하지 않음
// const permissionResult = await ImagePicker.requestMediaLibraryPermissionsAsync();
// if (permissionResult.granted === false) {
// changePermission();
// return;
// }

const result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.Images,
Expand All @@ -154,12 +156,12 @@ const ProfileEditScreen = ({ navigation, route }) => {
};

const openCamera = async () => {
const permissionResult = await ImagePicker.requestCameraPermissionsAsync();

if (permissionResult.granted === false) {
changePermission();
return;
}
// BUG: Android에 권한 부여 원할하지 않음
// const permissionResult = await ImagePicker.requestCameraPermissionsAsync();
// if (permissionResult.granted === false) {
// changePermission();
// return;
// }

const result = await ImagePicker.launchCameraAsync({
base64: true,
Expand Down Expand Up @@ -191,11 +193,10 @@ const ProfileEditScreen = ({ navigation, route }) => {
for (const inter of selectedCategory) {
formData.append('interests', inter);
}
formData.append('repTitleId', '2000');
// alert(introduction);
formData.append('repTitleId', titleNameToId[title] ?? '');
// formData.append('repTitleId', '');
formData.append('introduction', introduction);
formData.append('updatePhoto', 'true');
// console.log('image', image);

async function patchProfileEditInfo(formData: any) {
const token = await getAccessToken();
Expand All @@ -206,12 +207,12 @@ const ProfileEditScreen = ({ navigation, route }) => {
'Content-Type': 'multipart/form-data',
},
});
console.log('🚀 ~ file: ProfileEditScreen.tsx:193 ~ patchProfileEditInfo ~ res', res.data);
console.log('🚀 ~ file: ProfileEditScreen.tsx:193 ~ patchProfileEditInfo ~ res', res);

return res.data;
} catch (err) {
alert(`에러 발생 : ${err}`);
console.log(err);
console.log('에러:', err);
}
}

Expand Down