diff --git a/src/components/ManageList.jsx b/src/components/ManageList.jsx index 15f7e87..928719e 100644 --- a/src/components/ManageList.jsx +++ b/src/components/ManageList.jsx @@ -2,7 +2,8 @@ import styled from '@emotion/native'; import { COLORS } from '../shared/color'; import { TouchableOpacity } from 'react-native'; -const ManageList = ({ pillName, id }) => { +const ManageList = ({ pillName, time, id, navigate }) => { + // console.log(pillName, time); return ( {pillName} @@ -11,7 +12,12 @@ const ManageList = ({ pillName, id }) => { // 클릭하면 페이지 이동 buttonColor={COLORS.BLACK} buttonText="편집" - onPress={() => console.log('편집', id)} + onPress={() => + navigate('Stacks', { + screen: '수정 페이지', + params: { isEdit: true, eachPillName: pillName, eachTime: time }, + }) + } /> {/* 약 이름 인풋 */} {/* 약 복용시간 인풋 */} - 저장 + {isEdit ? '수정' : '저장'} {/* 취소 / 돌아가기 버튼 */} - navigate('Tabs', { screen: 'My' })}> + navigate('Tabs', { screen: '마이 페이지' })} + > 취소 diff --git a/src/screen/MyPage.jsx b/src/screen/MyPage.jsx index d374363..5dafbb7 100644 --- a/src/screen/MyPage.jsx +++ b/src/screen/MyPage.jsx @@ -1,7 +1,14 @@ import styled from '@emotion/native'; -import { Text, View } from 'react-native'; +import { ScrollView, Text, View } from 'react-native'; import { useQuery, useMutation, useQueryClient } from 'react-query'; -import { getDocs, query, collection, orderBy, where } from 'firebase/firestore'; +import { + getDocs, + query, + collection, + orderBy, + where, + doc, +} from 'firebase/firestore'; import { createUserWithEmailAndPassword, signInWithEmailAndPassword, @@ -59,21 +66,46 @@ const MyPage = ({ navigation: { navigate } }) => { return getDocs(selectedDocs); }; + // 기존 로직 // 의존적 쿼리입니다. 사용자의 UID를 얻은 후에 통신이 가능합니다. + // const { + // isLoading, + // isError, + // error, + // data: pillList, + // } = useQuery('pill-list', () => getUsersPillList(uid), { + // enabled: !!uid, + // select: (data) => { + // return data.docs.map((doc) => ({ ...doc.data(), id: doc.id })); + // }, + // }); + + // const renderPillList = pillList?.map(({ id, pillName }) => ( + // + // )); + + // 임시 로직 + const sampleUid = 'ALsTlRugmucb8QA1i8CVMNkSQgR2'; const { isLoading, isError, error, data: pillList, - } = useQuery('pill-list', () => getUsersPillList(uid), { - enabled: !!uid, + } = useQuery('pill-list', () => getUsersPillList(sampleUid), { + enabled: !!sampleUid, select: (data) => { return data.docs.map((doc) => ({ ...doc.data(), id: doc.id })); }, }); - const renderPillList = pillList?.map(({ id, pillName }) => ( - + const renderPillList = pillList?.map(({ id, pillName, time }) => ( + )); // 에러 핸들링: 통신 실패의 경우 보여주는 화면입니다. @@ -108,10 +140,17 @@ const MyPage = ({ navigation: { navigate } }) => { handleLogin()}> 임시 로그인 - navigate('Stacks', { screen: '수정 페이지' })}> + {renderPillList} + + navigate('Stacks', { + screen: '수정 페이지', + params: { isEdit: false, eachPillName: '', eachTime: '' }, + }) + } + > 약추가 - {renderPillList} {/* TODO: 하단 tabs */} ); diff --git a/src/shared/firebase.js b/src/shared/firebase.js index 14d8648..d72afea 100644 --- a/src/shared/firebase.js +++ b/src/shared/firebase.js @@ -26,4 +26,3 @@ const firebaseConfig = { export const app = initializeApp(firebaseConfig); export const auth = getAuth(app); export const dbService = getFirestore(app); -export const authService = getAuth(app);