Skip to content

Commit

Permalink
Feat: add api for MyPage MyUser 완료
Browse files Browse the repository at this point in the history
  • Loading branch information
yejinleee committed Jul 9, 2022
1 parent 7a8d1b1 commit be14985
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/components/My/MyUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const MyUser: FC<MyUserProps> = ({authentication, email, name, point }) =
</View>
<Text style={[DesignSystem.caption1Lt, styles.userEmail]}>{email}</Text>
</View>
<TouchableOpacity onPress={() => navigation.navigate('MyEditUserInfo', {username: name, auth: statusMessage})}>
<TouchableOpacity onPress={() => navigation.navigate('MyEditUserInfo', {username: name, email: email, auth: statusMessage})}>
<View style={[styles.editUserInfo]}>
<Text style={[DesignSystem.caption1Lt, {color: '#6C69FF'}]}>회원정보 수정</Text>
<Image
Expand Down
20 changes: 8 additions & 12 deletions src/screens/my/MyEditUserInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ type Props = NativeStackScreenProps<MyStackParamList, 'MyEditUserInfo'>;

export const MyEditUserInfo = ({navigation, route}: Props) => {
const [username, setUsername] = useState<string>(route.params.username);
const [email, setEmail] = useState<string>(route.params.email);
const [auth, setAuth] = useState<string>(route.params.auth);
const [email, setEmail] = useState('');
const [focusedEmail, setFocusedEmail] = useState(false);

const goBack = () => {
Expand Down Expand Up @@ -49,22 +49,18 @@ export const MyEditUserInfo = ({navigation, route}: Props) => {
<View style={[styles.userInfoEditContent]}>
<View style={[styles.emailNinput]}>
<Text style={[DesignSystem.title4Md, {color: 'black', marginBottom:8}]}>이메일</Text>
<TextInput
style={[styles.inputText, focusedEmail ? styles.focusBorder : styles.unfocusBorder]}
onChangeText={(text) => {
setEmail(text);
}}
value={email.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')}
onBlur={() => setFocusedEmail(false)}
onFocus={() => setFocusedEmail(true)}
/>
<Text style={[DesignSystem.body1Lt, {marginLeft: 8, color: '#949494'}]}>{email}</Text>
</View>
<View style={[styles.phoneNinput]}>
<Text style={[DesignSystem.title4Md, {color: 'black', marginBottom:8}]}>전화번호</Text>
<Text style={[DesignSystem.title4Md, {color: 'black', marginBottom: 8}]}>
전화번호
</Text>
<View style={[styles.phoneAuth]}>
<Text>🚨전화번호인증🚨</Text>
</View>
<Text style={[DesignSystem.caption1Lt, {color: '#E03D32', marginLeft: 8}]}>{auth}</Text>
<Text style={[DesignSystem.caption1Lt, {color: '#E03D32', marginLeft: 8}]}>
{auth}
</Text>
</View>
</View>
</View>
Expand Down
31 changes: 15 additions & 16 deletions src/screens/my/MyPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ export type MyPageData = {
const MyPage = () => {
const navigation = useNavigation();
const token = useRecoilValue(userToken);
// const getUserInfo = async () => {
// const {data} = await customAxios(token).get('/api/v1/users/me');
// return data.result;
// };
// const {data, isSuccess, isError, error} = useQuery<MyPageData>(['userInfo', token], getUserInfo);
const getUserInfo = async () => {
const {data} = await customAxios(token).get('/api/v1/users/me');
return data.result;
};
const {data, isSuccess, isError, error} = useQuery<MyPageData>(['userInfo', token], getUserInfo);
console.log('ssssssssss', data);
// data.point 로 접근
const storeData = async (value: string) => {
try {
Expand All @@ -45,14 +46,7 @@ const MyPage = () => {
]);
navigation.navigate('Login');
};
console.log(AsyncStorage.getItem('userToken'));

// 서버연결 후 수정
const name = '밥풀이';
const email = '[email protected]';
const point = 2500;
const [authentication, setAuthentication] = useState<boolean>(false);
//
console.log('async userToken', AsyncStorage.getItem('userToken'));

return (
<>
Expand All @@ -63,9 +57,14 @@ const MyPage = () => {
<Text style={[styles.headerText, DesignSystem.h2SB]}>마이페이지</Text>
</View>
</View>
<MyUser authentication={authentication} email={email} name={name} point={point} />
{/* 서버연결 예시 */}
{/* <MyUser authentication={data.authentication} email={data.email} name={data.name} point={data.point} /> */}
{data !== undefined && (
<MyUser
authentication={data.authentication}
email={data.email}
name={data.name}
point={data.point}
/>
)}
<TouchableOpacity onPress={() => navigation.navigate('MyReview')}>
<View style={[styles.myMenuWrap]}>
<Text style={[DesignSystem.body1Lt, {color: '#111111', marginLeft: 22}]}>
Expand Down
2 changes: 1 addition & 1 deletion src/screens/my/MyPoint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export const MyPoint = ({navigation, route}: Props) => {
<View>
<Text style={[DesignSystem.body2Lt, {color: '#616161'}]}>내 포인트</Text>
<Text style={[DesignSystem.h1SB, {color: '#111111'}]}>
{data?.pages[0].data.result.totalPoints.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')}P
{data?.pages[0].data.result.totalPoints.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')} P
{/* {DataPointsList.totalPoints.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')}P */}
</Text>
</View>
Expand Down

0 comments on commit be14985

Please sign in to comment.