diff --git a/App.tsx b/App.tsx index b272e33..c2cc5b5 100644 --- a/App.tsx +++ b/App.tsx @@ -5,11 +5,9 @@ import 'react-native-gesture-handler'; import RootNav from './navigation/Main/RootNav'; import OnBoardingStack from './navigation/OnBoarding/StackNavigationOfOnBoarding'; import { BottomSheetModalProvider } from '@gorhom/bottom-sheet'; -import { getAccessToken, getRefreshToken, isLoggedIn } from 'react-native-axios-jwt'; +import { getAccessToken, isLoggedIn } from 'react-native-axios-jwt'; import { QueryClient, QueryClientProvider } from 'react-query'; import CheckListStore from './Context/CheckListByServer'; -import AsyncStorage from '@react-native-async-storage/async-storage'; -import KakaoLoginBtn from './components/Login/KakaoLoginBtn'; import axios from 'axios'; const queryClient = new QueryClient(); @@ -39,7 +37,11 @@ function App() { - {isLogin ? : } + {isLogin ? ( + + ) : ( + + )} diff --git a/assets/images/checkList/pinnedCheckList.png b/assets/images/checkList/pinnedCheckList.png new file mode 100644 index 0000000..5e2f04b Binary files /dev/null and b/assets/images/checkList/pinnedCheckList.png differ diff --git a/assets/images/checkList/unPinnedCheckList.png b/assets/images/checkList/unPinnedCheckList.png new file mode 100644 index 0000000..1d1ea1b Binary files /dev/null and b/assets/images/checkList/unPinnedCheckList.png differ diff --git a/components/CheckListComponent/ButtonsOfTypeB.tsx b/components/CheckListComponent/ButtonsOfTypeB.tsx index f335dff..79afbac 100644 --- a/components/CheckListComponent/ButtonsOfTypeB.tsx +++ b/components/CheckListComponent/ButtonsOfTypeB.tsx @@ -98,6 +98,7 @@ function ButtonsOfTypeB({ isEdit, checkList, setCheckLists, checkLists }: IProps onChangeText={onChangeText} onEndEditing={() => onEndEditing(answer)} placeholder={answer.type ? answer.type : '직접 입력'} + placeholderTextColor={'#D6D4D4'} style={[styles.typeDBtnWrapper]} /> diff --git a/components/CheckListComponent/ButtonsOfTypeC.tsx b/components/CheckListComponent/ButtonsOfTypeC.tsx index 7bd1ee8..960906e 100644 --- a/components/CheckListComponent/ButtonsOfTypeC.tsx +++ b/components/CheckListComponent/ButtonsOfTypeC.tsx @@ -1,4 +1,4 @@ -import React, { Dispatch, SetStateAction } from 'react'; +import React, { Dispatch, SetStateAction, useState } from 'react'; import { DefaultText } from '../../CustomText'; import { checkListTypes } from '../../types/checkListTypes'; import { Image, Pressable, View } from 'react-native'; @@ -12,6 +12,7 @@ interface IProps { } function ButtonsOfTypeC({ setModal, modal, checkList }: IProps) { + const [order, setOrder] = useState(0); return ( <> @@ -21,6 +22,7 @@ function ButtonsOfTypeC({ setModal, modal, checkList }: IProps) { key={item.id} onPress={() => { setModal ? setModal(true) : null; + setOrder(item.order); }} > {checkList?.answer?.some((item) => item.id) ? ( - + ) : null} ); diff --git a/components/CheckListComponent/ButtonsOfTypeD.tsx b/components/CheckListComponent/ButtonsOfTypeD.tsx index 2043245..dbe36d6 100644 --- a/components/CheckListComponent/ButtonsOfTypeD.tsx +++ b/components/CheckListComponent/ButtonsOfTypeD.tsx @@ -157,6 +157,7 @@ function ButtonsOfTypeD({ isEdit, checkList, setCheckLists, checkLists }: IProps onChangeText={onChangeTextHandler} onEndEditing={onEndEditing} placeholder={'+ 직접 입력'} + placeholderTextColor={'#D6D4D4'} value={newCheckListElement} style={[styles.typeDBtnWrapper, styles.typeDInputBtnWrapper]} /> diff --git a/components/CheckListComponent/CheckListComponent.tsx b/components/CheckListComponent/CheckListComponent.tsx index bf760bd..4efa167 100644 --- a/components/CheckListComponent/CheckListComponent.tsx +++ b/components/CheckListComponent/CheckListComponent.tsx @@ -1,5 +1,5 @@ -import React, { Dispatch, SetStateAction, useEffect } from 'react'; -import { View } from 'react-native'; +import React, { Dispatch, SetStateAction, useEffect, useState } from 'react'; +import { Pressable, View } from 'react-native'; import { checkListTypes } from '../../types/checkListTypes'; import styles from './styles'; import ButtonsOfTypeA from './ButtonsOfTypeA'; @@ -30,6 +30,10 @@ interface IProps { setCheckLists: Dispatch>; onBoarding: boolean; } +type ContextType = { + translateX: number; + translateY: number; +}; function CheckListComponent({ modal, @@ -43,10 +47,20 @@ function CheckListComponent({ onBoarding, }: IProps) { const translateX = useSharedValue(0); + const translateY = useSharedValue(0); - const panGesture = useAnimatedGestureHandler({ - onActive: (event) => { - translateX.value = event.translationX; + const panGesture = useAnimatedGestureHandler({ + onStart: (event, context) => { + context.translateX = translateX.value; + context.translateY = translateY.value; + }, + onActive: (event, context) => { + translateX.value = event.translationX + context.translateX; + translateY.value = event.translationY; + + if (event.translationX + context.translateX > 0) { + translateX.value = 0; + } }, onEnd: () => { const shouldBeDismissed = translateX.value > -40; @@ -67,18 +81,18 @@ function CheckListComponent({ })); useEffect(() => { - translateX.value = 0; - }, [isEdit]); + translateX.value = withTiming(0); + }); return ( - + {checkList.question} {checkList.rule ? ( @@ -133,7 +147,7 @@ function CheckListComponent({ /> ) : null} - + >; modal?: boolean; + order: number | undefined; } const windowWidth = Dimensions.get('window').width; -function CheckListImage({ checkList, setModal, modal }: IProps) { +function CheckListImage({ checkList, setModal, modal, order }: IProps) { const checkListContext = useContext(checkListCtx); - const [index, setIndex] = useState(0); const isCarousel = useRef(null); const mainImageHandler = async (item: answerButtonType) => { @@ -38,6 +38,9 @@ function CheckListImage({ checkList, setModal, modal }: IProps) { return ( + + {item.order + 1} / {checkList.length} + mainImageHandler(item)}> 대표 사진으로 설정 @@ -57,6 +60,8 @@ function CheckListImage({ checkList, setModal, modal }: IProps) { item.toString()} + firstItem={order} ref={isCarousel} data={checkList} sliderWidth={windowWidth} diff --git a/components/CheckListComponent/CheckListSummaryComponenet.tsx b/components/CheckListComponent/CheckListSummaryComponenet.tsx new file mode 100644 index 0000000..a1616c6 --- /dev/null +++ b/components/CheckListComponent/CheckListSummaryComponenet.tsx @@ -0,0 +1,89 @@ +import React, { useContext, useState } from 'react'; +import { Image, Pressable, View } from 'react-native'; +import { DefaultText } from '../../CustomText'; +import styles from './styles'; +import axios from 'axios'; +import { checkListCtx } from '../../Context/CheckListByServer'; +interface IProps { + checkListSummary: any; +} +function CheckListSummaryComponenet({ checkListSummary }: IProps) { + const checkListContext = useContext(checkListCtx); + + const [pin, setPin] = useState(checkListSummary.pinned); + const pinCheckListHandler = () => { + axios + .put(`api/check-list/main`, { checkListId: checkListContext?.checkListId, pinned: !pin }) + .then(() => setPin(!pin)) + .catch((e) => console.error(e)); + }; + return ( + <> + + + + + + + + + {checkListSummary.title + ? checkListSummary.title.length > 20 + ? `${checkListSummary.title.slice(0, 20)}...` + : checkListSummary.title + : '체크리스트 이름을 정해주세요!'} + + + {checkListSummary.address + ? checkListSummary.address.length > 20 + ? `${checkListSummary.address.slice(0, 20)}...` + : checkListSummary.address + : '해당 매물 위치를 입력해주세요!'} + + + + {checkListSummary.address} + {checkListSummary.roomType && checkListSummary.area && checkListSummary.form ? ( + + + + {checkListSummary.roomType} / {checkListSummary.area} / {checkListSummary.form} + + + ) : null} + {checkListSummary.distance ? ( + + + + {checkListSummary.distance} + + + ) : null} + + + + + ); +} +export default CheckListSummaryComponenet; diff --git a/components/CheckListComponent/myItem/MyItemElement.tsx b/components/CheckListComponent/myItem/MyItemElement.tsx index 638a15b..64959d2 100644 --- a/components/CheckListComponent/myItem/MyItemElement.tsx +++ b/components/CheckListComponent/myItem/MyItemElement.tsx @@ -18,8 +18,6 @@ interface IProps { } function MyItemElement({ myItemElement, elementClickedHandler, myItem, isEdit }: IProps) { - const checkListContext = useContext(checkListCtx); - const myItemElementOnPressHandler = () => { isEdit && elementClickedHandler({ myItem, myItemElement }); }; diff --git a/components/CheckListComponent/myItem/MyItemOfBottomSheets.tsx b/components/CheckListComponent/myItem/MyItemOfBottomSheets.tsx index 26fa8a1..466316c 100644 --- a/components/CheckListComponent/myItem/MyItemOfBottomSheets.tsx +++ b/components/CheckListComponent/myItem/MyItemOfBottomSheets.tsx @@ -81,6 +81,7 @@ function MyItemOfBottomSheets({ onCategoryNameHandler(newCategoryName)} @@ -98,6 +99,7 @@ function MyItemOfBottomSheets({ onCreateQuestionElementTextHandler(elementText)} diff --git a/components/CheckListComponent/styles.tsx b/components/CheckListComponent/styles.tsx index 76db312..5e64a86 100644 --- a/components/CheckListComponent/styles.tsx +++ b/components/CheckListComponent/styles.tsx @@ -4,6 +4,31 @@ import { mainBlue, mainLightBlue, mainOrange } from '../../color'; const windowWidth = Dimensions.get('window').width; const styles = StyleSheet.create({ + summaryPinImg: { position: 'absolute', zIndex: 1000, top: 30, right: 15 }, + summaryMainImg: { width: windowWidth - 34, height: 260, borderRadius: 10, marginTop: 15 }, + summaryContentImg: { marginRight: 5 }, + distanceImg: { marginRight: 9 }, + summaryRightContents: { flexDirection: 'row' }, + summaryWrapper: { justifyContent: 'center', alignItems: 'center' }, + summaryContentAddress: { color: '#8C8CA1' }, + summaryContentTitle: { fontSize: 18 }, + summaryWhiteCardWrapper: { + position: 'relative', + marginBottom: -30, + backgroundColor: 'white', + width: windowWidth - 68, + bottom: 50, + padding: 19, + borderRadius: 10, + justifyContent: 'space-between', + flexDirection: 'row', + }, + summaryContentText: { fontSize: 12, lineHeight: 18 }, + summayWhiteCardContentWrapper: { + justifyContent: 'space-between', + height: 50, + lineHeight: 18, + }, selectMainImageText: { fontSize: 16, color: mainBlue, fontFamily: 'AppleSDGothicNeoEB00' }, imageModal: { position: 'absolute', right: -17 }, selectedimageCancleButton: { @@ -17,7 +42,7 @@ const styles = StyleSheet.create({ imageSelectButtonWrapper: { marginHorizontal: 17, backgroundColor: 'white', - marginTop: 100, + marginTop: 80, paddingVertical: 20, width: windowWidth - 34, alignItems: 'center', @@ -65,7 +90,7 @@ const styles = StyleSheet.create({ width: windowWidth - 34, borderRadius: 14, }, - checkListMainTitle: { fontSize: 20 }, + checkListMainTitle: { fontSize: 20, lineHeight: 32 }, buttonsOfCheckList: { marginTop: 40, flexDirection: 'row', @@ -79,7 +104,7 @@ const styles = StyleSheet.create({ }, subTitles: { marginTop: 14 }, - checkListSubTitle: { flexDirection: 'row' }, + checkListSubTitle: { flexDirection: 'row', marginRight: 15 }, checkListGrayText: { color: '#7C7C7C', lineHeight: 24 }, checkListWhiteText: { color: 'white', lineHeight: 24 }, typeABtnWrapper: { diff --git a/components/Home/CheckListHome.tsx b/components/Home/CheckListHome.tsx index 7a0cba5..3318d7c 100644 --- a/components/Home/CheckListHome.tsx +++ b/components/Home/CheckListHome.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { ScrollView, View } from 'react-native'; +import { RefreshControl, ScrollView, View } from 'react-native'; import { DefaultText } from '../../CustomText'; import styles from './styles'; @@ -9,9 +9,11 @@ import { homeScreenTypes } from '../../types/homeScreenTypes'; interface IProps { homeCheckList: homeScreenTypes[]; + onRefresh: any; + refreshing: boolean; } -function CheckListHome({ homeCheckList }: IProps) { +function CheckListHome({ homeCheckList, refreshing, onRefresh }: IProps) { return ( @@ -19,7 +21,11 @@ function CheckListHome({ homeCheckList }: IProps) { home sweet home 🏠 - + } + > + 📌 고정된 리스트 + {homeCheckList .filter((item) => item.pinned) diff --git a/components/Home/PinnedCheckList.tsx b/components/Home/PinnedCheckList.tsx index eb7b261..78772eb 100644 --- a/components/Home/PinnedCheckList.tsx +++ b/components/Home/PinnedCheckList.tsx @@ -20,7 +20,6 @@ function PinnedCheckList({ pinnedCheckList }: iProps) { }; return ( <> - 📌 고정된 리스트 {pinnedCheckList ? ( { const onAppleLoginHandler = async () => { + const onLoginSuccess = (res: any) => { + const res_data = res.data.data; + let accessToken: string = ''; + if (Object.keys(res_data).includes('token')) { + // 재접속 + accessToken = res_data.token; + setAccessToken(accessToken); + } else { + // 처음 호출 + accessToken = res_data.accessToken; + setAuthTokens({ + accessToken: accessToken, + refreshToken: res_data.refreshToken, + }); + } + axios.defaults.headers.common['Authorization'] = `Bearer ${accessToken}`; + setIsLogin(true); + }; try { // performs login request const appleAuthRequestResponse = await appleAuth.performRequest({ @@ -48,10 +67,7 @@ const AppleLoginBtn = ({ setIsLogin }: any) => { email: decodedToken.email, user: user, }) - .then((res) => { - axios.defaults.headers.common['Authorization'] = `Bearer ${res.data.data.accessToken}`; - setIsLogin(true); - }) + .then(onLoginSuccess) .catch((e) => { console.log(e); }); diff --git a/components/Login/KakaoLoginBtn.tsx b/components/Login/KakaoLoginBtn.tsx index 5741fd9..2aa6429 100644 --- a/components/Login/KakaoLoginBtn.tsx +++ b/components/Login/KakaoLoginBtn.tsx @@ -58,9 +58,9 @@ const KakaoLoginBtn = ({ setIsLogin }: Props) => { } axios.defaults.headers.common['Authorization'] = `Bearer ${accessToken}`; setIsLogin(true); - const refreshToken = getRefreshToken().then((refreshToken) => console.log(refreshToken)); + // const refreshToken = getRefreshToken().then((refreshToken) => console.log(refreshToken)); // accessToken 만료하기 1분 전에 로그인 연장 - setTimeout(() => requestRefresh(refreshToken), acessTokenExpiresIn - 60000); + // setTimeout(() => requestRefresh(refreshToken), acessTokenExpiresIn - 60000); }; const catchError = (err: any) => { diff --git a/components/ProfileSetting/ProfileSettingComponent.tsx b/components/ProfileSetting/ProfileSettingComponent.tsx index 74c4953..2f44733 100644 --- a/components/ProfileSetting/ProfileSettingComponent.tsx +++ b/components/ProfileSetting/ProfileSettingComponent.tsx @@ -1,24 +1,26 @@ -import React from 'react'; +import React, { Dispatch, SetStateAction } from 'react'; import { View, Image, Pressable, Linking, ScrollView } from 'react-native'; import { DefaultText } from '../../CustomText'; import styles from './styles'; +import { clearAuthTokens } from 'react-native-axios-jwt'; +interface IProps { + setIsLogin: Dispatch>; +} -function ProfileSettingComponent() { - +function ProfileSettingComponent({ setIsLogin }: IProps) { + const onLogoutHandler = () => { + clearAuthTokens(); + setIsLogin(false); + }; return ( <> - name: 최봉수 - - - - 고객센터 Linking.openURL('https://www.naver.com')} + onPress={() => Linking.openURL('http://pf.kakao.com/_Numxeb')} style={styles.profileSettingEachElementWrapper} > @@ -26,8 +28,9 @@ function ProfileSettingComponent() { + Linking.openURL('https://www.naver.com')} + onPress={() => Linking.openURL('https://www.instagram.com/a_ma_ttang/')} style={styles.profileSettingEachElementWrapper} > @@ -35,11 +38,15 @@ function ProfileSettingComponent() { + 고객센터 + Linking.openURL('https://www.naver.com')} + onPress={() => + Linking.openURL('https://www.notion.so/2caa1719b6f74f228137d662d32dd374') + } style={styles.profileSettingEachElementWrapper} > @@ -48,7 +55,9 @@ function ProfileSettingComponent() { Linking.openURL('https://www.naver.com')} + onPress={() => + Linking.openURL('https://www.notion.so/85d38b79533142c9afa20a92614d9803') + } style={styles.profileSettingEachElementWrapper} > @@ -56,22 +65,27 @@ function ProfileSettingComponent() { - Linking.openURL('https://www.naver.com')} - style={styles.profileSettingEachElementWrapper} - > - - 오픈소스 라이선스 - - - + {/* Linking.openURL('https://www.naver.com')}*/} + {/* style={styles.profileSettingEachElementWrapper}*/} + {/*>*/} + {/* */} + {/* 오픈소스 라이선스*/} + {/* */} + {/* */} + {/**/} + + 버전정보 1.0 - + 로그아웃 diff --git a/components/ProfileSetting/styles.ts b/components/ProfileSetting/styles.ts index 00de6c2..019f44b 100644 --- a/components/ProfileSetting/styles.ts +++ b/components/ProfileSetting/styles.ts @@ -1,8 +1,10 @@ -import { StyleSheet } from 'react-native'; +import { Dimensions, StyleSheet } from 'react-native'; import { mainBlue, mainLightBlue, mainOrange } from '../../color'; +const windowHeight = Dimensions.get('window').height; + const styles = StyleSheet.create({ - profileSettingOuterWrapper: { backgroundColor: 'white', flex: 1 }, + profileSettingOuterWrapper: { backgroundColor: 'white', flex: 1, height: windowHeight }, profileSettingName: { color: mainBlue, @@ -14,7 +16,6 @@ const styles = StyleSheet.create({ profileSettingInnerWrapper: { backgroundColor: mainLightBlue, margin: 17, - flex: 1, borderRadius: 16, }, profileSettingTitle: { @@ -46,7 +47,7 @@ const styles = StyleSheet.create({ fontSize: 18, }, profileSettingBottomElements: { - marginTop: 30, + marginTop: 15, marginBottom: 30, }, redText: { diff --git a/ios/amattang.xcodeproj/project.pbxproj b/ios/amattang.xcodeproj/project.pbxproj index d1a1b4e..507ff2c 100644 --- a/ios/amattang.xcodeproj/project.pbxproj +++ b/ios/amattang.xcodeproj/project.pbxproj @@ -471,7 +471,17 @@ baseConfigurationReference = EF69AFFC09A3127FB3EBDA9A /* Pods-amattang-amattangTests.debug.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + ALWAYS_SEARCH_USER_PATHS = NO; BUNDLE_LOADER = "$(TEST_HOST)"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "\"${PODS_ROOT}/Flipper-DoubleConversion/Frameworks\"", + "\"${PODS_ROOT}/GoogleMaps/Base/Frameworks\"", + "\"${PODS_ROOT}/GoogleMaps/Maps/Frameworks\"", + "\"${PODS_ROOT}/OpenSSL-Universal/Frameworks\"", + "\"${PODS_XCFRAMEWORKS_BUILD_DIR}/Flipper-DoubleConversion\"", + "\"${PODS_XCFRAMEWORKS_BUILD_DIR}/OpenSSL-Universal\"", + ); GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", @@ -499,8 +509,14 @@ baseConfigurationReference = 350968AEFD941C314C4A290C /* Pods-amattang-amattangTests.release.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + ALWAYS_SEARCH_USER_PATHS = NO; BUNDLE_LOADER = "$(TEST_HOST)"; COPY_PHASE_STRIP = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "\"${PODS_ROOT}/GoogleMaps/Base/Frameworks\"", + "\"${PODS_ROOT}/GoogleMaps/Maps/Frameworks\"", + ); INFOPLIST_FILE = amattangTests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( @@ -624,7 +640,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; LD_RUNPATH_SEARCH_PATHS = ( /usr/lib/swift, "$(inherited)", @@ -682,7 +698,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; LD_RUNPATH_SEARCH_PATHS = ( /usr/lib/swift, "$(inherited)", diff --git a/ios/amattang/Info.plist b/ios/amattang/Info.plist index 708ece4..69a34b1 100644 --- a/ios/amattang/Info.plist +++ b/ios/amattang/Info.plist @@ -35,12 +35,6 @@ 1 KAKAO_APP_KEY 3d5254ebc91a92469dde7bc04f9c74b1 - LSApplicationQueriesSchemes - - kakaokompassauth - storykompassauth - kakaolink - LSRequiresIPhoneOS NSAppTransportSecurity diff --git a/navigation/Main/RootNav.tsx b/navigation/Main/RootNav.tsx index 2490d14..06f5ef1 100644 --- a/navigation/Main/RootNav.tsx +++ b/navigation/Main/RootNav.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { Dispatch, SetStateAction } from 'react'; import { createNativeStackNavigator } from '@react-navigation/native-stack'; import BottomNavigation from './BottomNavigation/BottomNavigation'; @@ -7,10 +7,14 @@ import { RootStackProps } from '../../types/navigationTypes'; const RootNav = createNativeStackNavigator(); -const Root = () => ( +interface IProps { + setIsLogin: Dispatch>; +} + +const Root = ({ setIsLogin }: IProps) => ( - + } /> ); export default Root; diff --git a/navigation/Main/StackNavigation/StackNavigationOfCheckList.tsx b/navigation/Main/StackNavigation/StackNavigationOfCheckList.tsx index 7e05fb0..5637aff 100644 --- a/navigation/Main/StackNavigation/StackNavigationOfCheckList.tsx +++ b/navigation/Main/StackNavigation/StackNavigationOfCheckList.tsx @@ -1,4 +1,4 @@ -import React, { useContext, useState } from 'react'; +import React, { Dispatch, SetStateAction, useContext, useState } from 'react'; import { Image, Pressable, Share } from 'react-native'; import BasicCheckList from './BasicCheckList/BasiclCheckList'; @@ -13,10 +13,16 @@ import { } from '@react-navigation/native-stack'; import { checkListCtx } from '../../../Context/CheckListByServer'; import axios from 'axios'; +import { useNavigation } from '@react-navigation/native'; const NativeStack = createNativeStackNavigator(); -function CheckListStackNav({ navigation }: CheckListStackProps) { +interface IProps { + setIsLogin: Dispatch>; +} + +function CheckListStackNav({ setIsLogin }: IProps) { + const navigation = useNavigation(); const checkListContext = useContext(checkListCtx); const [isEdit, setIsEdit] = useState(true); @@ -40,21 +46,27 @@ function CheckListStackNav({ navigation }: CheckListStackProps) { }; const onSubmitHandler = async () => { - try { - await axios.put( - `/api/check-list/${checkListContext?.checkListId}/common/question`, - checkListContext?.choseCheckListByServer - ); - await axios.put( + await axios + .put( `/api/check-list/${checkListContext?.checkListId}/common/question/status`, checkListContext?.deletedCheckListByServer + ) + .then(() => checkListContext?.setDeletedCheckListByServer({ question: [] })); + + await axios + .put( + `/api/check-list/${checkListContext?.checkListId}/common/question`, + checkListContext?.choseCheckListByServer + ) + .then(() => + checkListContext?.setChoseCheckListByServer({ + typeA: [], + typeB: [], + typeD: [], + typeM: {}, + }) ); - } catch (error) { - console.error(error); - } - checkListContext?.setDeletedCheckListByServer({ question: [] }); - checkListContext?.setChoseCheckListByServer({ typeA: [], typeB: [], typeD: [], typeM: {} }); setIsEdit(false); }; @@ -79,7 +91,7 @@ function CheckListStackNav({ navigation }: CheckListStackProps) { } options={() => ({ title: '설정', headerStyle: { backgroundColor: 'white' }, diff --git a/screens/BasicCheckList/BasicInfoOfBasicCheckList.tsx b/screens/BasicCheckList/BasicInfoOfBasicCheckList.tsx index 6e9a684..626e167 100644 --- a/screens/BasicCheckList/BasicInfoOfBasicCheckList.tsx +++ b/screens/BasicCheckList/BasicInfoOfBasicCheckList.tsx @@ -23,6 +23,7 @@ import axios from 'axios'; import { ActivityIndicator, View } from 'react-native'; import { checkListCtx } from '../../Context/CheckListByServer'; import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view'; +import CheckListSummaryComponenet from '../../components/CheckListComponent/CheckListSummaryComponenet'; interface IProps { isEdit: boolean; @@ -36,12 +37,14 @@ function BasicInfoOfBasicCheckList({ isEdit, setIsBottomSheet }: IProps) { const [onServerData, setOnServerData] = useState(false); const [checkLists, setCheckLists] = useState([]); const [deletedCheckLists, setDeletedCheckLists] = useState([]); + const [checkListSummary, setCheckListSummary] = useState({}); const getServerData = async () => { try { const serverResponse = await axios.get( `/api/check-list/${checkListContext?.checkListId}/common?mainCategory=기본정보` ); + setCheckListSummary(serverResponse.data.data.information); setCheckLists([ ...serverResponse.data.data.questionList.map((item: checkListTypes) => ({ ...item, @@ -85,30 +88,29 @@ function BasicInfoOfBasicCheckList({ isEdit, setIsBottomSheet }: IProps) { - - {checkLists - .filter((item) => item.visibility) - .map((mainQuestionItem: checkListTypes) => ( - - ))} - - {deletedCheckLists.length !== 0 && ( - + {checkLists + .filter((item) => item.visibility) + .map((mainQuestionItem: checkListTypes) => ( + - )} - + ))} + + {deletedCheckLists.length !== 0 && ( + + )} {onServerData ? ( - - {checkLists - .filter((item) => item.visibility) - .map((mainQuestionItem: checkListTypes) => ( - + + {checkLists + .filter((item) => item.visibility) + .map((mainQuestionItem: checkListTypes) => ( + + ))} + + {deletedCheckLists.length !== 0 && ( + - ))} - - {deletedCheckLists.length !== 0 && ( - - )} - + )} + + + {onServerData ? ( - - {checkLists - .filter((item) => item.visibility) - .map((mainQuestionItem: checkListTypes) => ( - + + {checkLists + .filter((item) => item.visibility) + .map((mainQuestionItem: checkListTypes) => ( + + ))} + + {deletedCheckLists.length !== 0 && ( + - ))} - - {deletedCheckLists.length !== 0 && ( - - )} - + )} + + + {onServerData ? ( - - {checkLists - .filter((item) => item.visibility) - .map((mainQuestionItem: checkListTypes) => ( - + + {checkLists + .filter((item) => item.visibility) + .map((mainQuestionItem: checkListTypes) => ( + + ))} + + {deletedCheckLists.length !== 0 && ( + - ))} - - {deletedCheckLists.length !== 0 && ( - - )} - + )} + + + {onServerData ? ( - - {checkLists - .filter((item) => item.visibility) - .map((mainQuestionItem: checkListTypes) => ( - + + {checkLists + .filter((item) => item.visibility) + .map((mainQuestionItem: checkListTypes) => ( + + ))} + + {deletedCheckLists.length !== 0 && ( + - ))} - - {deletedCheckLists.length !== 0 && ( - - )} - + )} + + + {onServerData ? ( - - {checkLists - .filter((item) => item.visibility) - .map((mainQuestionItem: checkListTypes) => ( - + + {checkLists + .filter((item) => item.visibility) + .map((mainQuestionItem: checkListTypes) => ( + + ))} + + {deletedCheckLists.length !== 0 && ( + - ))} - - {deletedCheckLists.length !== 0 && ( - - )} - + )} + + + {onServerData ? ( - - {checkLists - .filter((item) => item.visibility) - .map((mainQuestionItem: checkListTypes) => ( - + + {checkLists + .filter((item) => item.visibility) + .map((mainQuestionItem: checkListTypes) => ( + + ))} + + {deletedCheckLists.length !== 0 && ( + - ))} - - {deletedCheckLists.length !== 0 && ( - - )} - + )} + + + {onServerData ? ( - - {checkLists - .filter((item) => item.visibility) - .map((mainQuestionItem: checkListTypes) => ( - + + {checkLists + .filter((item) => item.visibility) + .map((mainQuestionItem: checkListTypes) => ( + + ))} + + {deletedCheckLists.length !== 0 && ( + - ))} - - {deletedCheckLists.length !== 0 && ( - - )} - + )} + + {myItems.map((myItem) => ( {onServerData ? ( - - {checkLists - .filter((item) => item.visibility) - .map((mainQuestionItem: checkListTypes) => ( - + + {checkLists + .filter((item) => item.visibility) + .map((mainQuestionItem: checkListTypes) => ( + + ))} + + {deletedCheckLists.length !== 0 && ( + - ))} - - {deletedCheckLists.length !== 0 && ( - - )} - + )} + + ; +interface IProps { + setIsLogin: Dispatch>; +} + +function ProfileSetting({ setIsLogin }: IProps) { + return ; } export default ProfileSetting; diff --git a/screens/bottomTab/Home.tsx b/screens/bottomTab/Home.tsx index 9e89a94..623071d 100644 --- a/screens/bottomTab/Home.tsx +++ b/screens/bottomTab/Home.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react'; +import React, { useCallback, useEffect, useState } from 'react'; import EmptyHome from '../../components/Home/EmptyHome'; import CheckListHome from '../../components/Home/CheckListHome'; @@ -9,6 +9,14 @@ function Home() { const [loading, setLoading] = useState(false); const [isCheckList, setIsCheckList] = useState(false); const [homeCheckList, setHomeCheckList] = useState([]); + const [refreshing, setRefreshing] = useState(false); + + //refreshcontrol을 호출할 때 실행되는 callback함수 + const onRefresh = useCallback(async () => { + setRefreshing(true); + await getHomeDataHandler(); + setRefreshing(false); + }, []); const getHomeDataHandler = async () => { try { @@ -29,7 +37,11 @@ function Home() { <> {loading ? ( isCheckList ? ( - + ) : ( ) diff --git a/types/checkListTypes.ts b/types/checkListTypes.ts index a712507..ba0fc44 100644 --- a/types/checkListTypes.ts +++ b/types/checkListTypes.ts @@ -6,6 +6,7 @@ export interface answerButtonType { id?: number; main?: boolean; url?: string; + order?: number; } export interface answerListType {