diff --git a/Context/CheckListByServer.tsx b/Context/CheckListByServer.tsx index ae6acff..04d5569 100644 --- a/Context/CheckListByServer.tsx +++ b/Context/CheckListByServer.tsx @@ -1,5 +1,6 @@ import React, { createContext, Dispatch, SetStateAction, useState } from 'react'; import { choseCheckListByServerType, deletedCheckListByServerType } from '../types/checkListTypes'; +import axios from 'axios'; interface contextType { deletedCheckListByServer: deletedCheckListByServerType; @@ -8,6 +9,8 @@ interface contextType { setChoseCheckListByServer: Dispatch>; checkListId: number | false; setCheckListId: Dispatch>; + onChoseCheckListHandler: () => void; + onDeleteCheckListHandler: (data: deletedCheckListByServerType) => void; } export const checkListCtx = createContext(null); @@ -22,6 +25,21 @@ const CheckListStore: React.FC = (props) => { typeM: {}, }); const [checkListId, setCheckListId] = useState(false); + const onDeleteCheckListHandler = (data: deletedCheckListByServerType) => { + axios + .put(`/api/check-list/${checkListId}/common/question/status`, data) + .then(() => setDeletedCheckListByServer({ question: [] })); + }; + const onChoseCheckListHandler = () => { + axios.put(`/api/check-list/${checkListId}/common/question`, choseCheckListByServer).then(() => { + setChoseCheckListByServer({ + typeA: [], + typeB: [], + typeD: [], + typeM: {}, + }); + }); + }; return ( { setChoseCheckListByServer, checkListId, setCheckListId, + onChoseCheckListHandler, + onDeleteCheckListHandler, }} > {props.children} diff --git a/assets/images/checkList/checkLIstDefaultImg.png b/assets/images/checkList/checkLIstDefaultImg.png new file mode 100644 index 0000000..b46c755 Binary files /dev/null and b/assets/images/checkList/checkLIstDefaultImg.png differ diff --git a/components/CheckListComponent/BottomSheetsOfDeletedCheckList.tsx b/components/CheckListComponent/BottomSheetsOfDeletedCheckList.tsx index b54c923..7de2fee 100644 --- a/components/CheckListComponent/BottomSheetsOfDeletedCheckList.tsx +++ b/components/CheckListComponent/BottomSheetsOfDeletedCheckList.tsx @@ -47,7 +47,7 @@ function BottomSheetsOfDeletedCheckList({ deletedCheckLists.filter((CheckLists: checkListTypes) => !CheckLists.visibility) ); setCheckLists([...checkLists.filter((item) => item.visibility), ...deletedCheckLists]); - checkListContext?.setDeletedCheckListByServer({ + checkListContext?.onDeleteCheckListHandler({ question: [ ...checkListContext?.deletedCheckListByServer.question, ...deletedCheckLists.map((item) => ({ questionId: item.questionId, visibility: true })), diff --git a/components/CheckListComponent/ButtonOfGoToTrash.tsx b/components/CheckListComponent/ButtonOfGoToTrash.tsx index 4f838fb..9601cee 100644 --- a/components/CheckListComponent/ButtonOfGoToTrash.tsx +++ b/components/CheckListComponent/ButtonOfGoToTrash.tsx @@ -36,18 +36,18 @@ function ButtonOfGoToTrash({ isEdit && deletedCheckLists && setTimeout(async () => { - await checkListContext?.setDeletedCheckListByServer({ + await checkListContext?.onDeleteCheckListHandler({ question: [ ...checkListContext?.deletedCheckListByServer.question, { questionId: checkList.questionId, visibility: false }, ], }); - await setCheckLists( + setCheckLists( checkLists.map((item) => item.questionId === checkList.questionId ? { ...item, visibility: false } : { ...item } ) ); - await setDeletedCheckLists([...deletedCheckLists, { ...checkList, visibility: false }]); + setDeletedCheckLists([...deletedCheckLists, { ...checkList, visibility: false }]); }, 500); }; diff --git a/components/CheckListComponent/CheckListSummaryComponenet.tsx b/components/CheckListComponent/CheckListSummaryComponenet.tsx index a1616c6..663c5a4 100644 --- a/components/CheckListComponent/CheckListSummaryComponenet.tsx +++ b/components/CheckListComponent/CheckListSummaryComponenet.tsx @@ -20,7 +20,7 @@ function CheckListSummaryComponenet({ checkListSummary }: IProps) { return ( <> - + diff --git a/components/CheckListComponent/styles.tsx b/components/CheckListComponent/styles.tsx index 79edc94..5921eb6 100644 --- a/components/CheckListComponent/styles.tsx +++ b/components/CheckListComponent/styles.tsx @@ -4,13 +4,23 @@ import { mainBlue, mainLightBlue, mainOrange } from '../../color'; const windowWidth = Dimensions.get('window').width; const styles = StyleSheet.create({ + summaryImageWrapper: { + justifyContent: 'center', + alignItems: 'center', + backgroundColor: '#CFCFCF', + width: windowWidth - 34, + height: 260, + borderRadius: 10, + marginTop: 15, + marginBottom: 15, + }, textWrap: { flexDirection: 'row', flexWrap: 'wrap', }, textWrapWrapper: { flexDirection: 'row', flexWrap: 'wrap' }, summaryPinImg: { position: 'absolute', zIndex: 1000, top: 30, right: 15 }, - summaryMainImg: { width: windowWidth - 34, height: 260, borderRadius: 10, marginTop: 15 }, + summaryMainImg: { marginBottom: 25 }, summaryContentImg: { marginRight: 5 }, distanceImg: { marginRight: 9 }, summaryRightContents: { flexDirection: 'row' }, diff --git a/components/Home/CheckListHome.tsx b/components/Home/CheckListHome.tsx index 3318d7c..1a124d5 100644 --- a/components/Home/CheckListHome.tsx +++ b/components/Home/CheckListHome.tsx @@ -24,8 +24,9 @@ function CheckListHome({ homeCheckList, refreshing, onRefresh }: IProps) { } > - πŸ“Œ κ³ μ •λœ 리슀트 - + {homeCheckList.some((item) => item.pinned) ? ( + πŸ“Œ κ³ μ •λœ 리슀트 + ) : null} {homeCheckList .filter((item) => item.pinned) diff --git a/components/Home/PinnedCheckList.tsx b/components/Home/PinnedCheckList.tsx index 78772eb..62e753a 100644 --- a/components/Home/PinnedCheckList.tsx +++ b/components/Home/PinnedCheckList.tsx @@ -33,11 +33,12 @@ function PinnedCheckList({ pinnedCheckList }: iProps) { resizeMode="cover" /> ) : ( - + + + )} diff --git a/components/Home/UnPinnedCheckList.tsx b/components/Home/UnPinnedCheckList.tsx index a247365..e354cd9 100644 --- a/components/Home/UnPinnedCheckList.tsx +++ b/components/Home/UnPinnedCheckList.tsx @@ -33,11 +33,13 @@ function UnPinnedCheckList({ unPinnedCheckList }: iProps) { resizeMode="cover" /> ) : ( - + + + )} @@ -66,10 +68,14 @@ function UnPinnedCheckList({ unPinnedCheckList }: iProps) { )} - - - {unPinnedCheckList.distance && unPinnedCheckList.distance} - + {unPinnedCheckList.distance && ( + <> + + + {unPinnedCheckList.distance} + + + )} diff --git a/components/Home/styles.tsx b/components/Home/styles.tsx index f0969f6..cf03fb1 100644 --- a/components/Home/styles.tsx +++ b/components/Home/styles.tsx @@ -2,6 +2,17 @@ import { Platform, StyleSheet } from 'react-native'; import { mainBlue, mainLightBlue } from '../../color'; const styles = StyleSheet.create({ + unpinnedDefaultImgWrapper: { backgroundColor: '#F1F1F6', borderRadius: 6 }, + pinnedDefaultImg: { width: 150, height: 100 }, + pinnedDefaultImgWrapper: { + justifyContent: 'center', + alignItems: 'center', + paddingBottom: 45, + backgroundColor: '#CFCFCF', + width: 240, + height: 180, + borderRadius: 10, + }, fullScreenWrapper: { flex: 1, backgroundColor: 'white' }, welcomeTitle: Platform.OS === 'ios' @@ -31,7 +42,7 @@ const styles = StyleSheet.create({ pinnedChecklistWrapper: { height: 260, marginLeft: 17 }, pinnedChecklistCard: { marginRight: 14 }, - pinnedChecklistImg: { width: 240, height: 180, borderRadius: 10 }, + pinnedChecklistImg: {}, pinnedChecklistSummaryCard: { width: 240, height: 110, diff --git a/components/camera/CameraAndGallery.tsx b/components/camera/CameraAndGallery.tsx index c50cbc3..490e7fa 100644 --- a/components/camera/CameraAndGallery.tsx +++ b/components/camera/CameraAndGallery.tsx @@ -26,11 +26,9 @@ function CameraAndGallery({ setOnModal, onModal }: IProps) { await axios .post(`/api/check-list/${checkListContext?.checkListId}/image`, imageData) .then((e) => { - console.log('t'); console.log(e); }) .catch((e) => { - console.log('c'); console.log(e); }); }; diff --git a/navigation/Main/StackNavigation/BasicCheckList/BasiclCheckList.tsx b/navigation/Main/StackNavigation/BasicCheckList/BasiclCheckList.tsx index 53acfdc..0ea7d43 100644 --- a/navigation/Main/StackNavigation/BasicCheckList/BasiclCheckList.tsx +++ b/navigation/Main/StackNavigation/BasicCheckList/BasiclCheckList.tsx @@ -14,13 +14,12 @@ const Tab = createMaterialTopTabNavigator(); interface IProps { setIsEdit: Dispatch>; isEdit: boolean; - onSubmitHandler: () => void; } -function BasicCheckList({ setIsEdit, isEdit, onSubmitHandler }: IProps) { +function BasicCheckList({ setIsEdit, isEdit }: IProps) { const [isBottomSheet, setIsBottomSheet] = useState(true); const [onModal, setOnModal] = useState(false); - const onEditHandler = () => { + const onEditHandler = async () => { setIsEdit(true); }; @@ -28,10 +27,6 @@ function BasicCheckList({ setIsEdit, isEdit, onSubmitHandler }: IProps) { setOnModal(!onModal); }; - setInterval(() => { - onSubmitHandler(); - }, 100000); - return ( <> { - axios - .put( - `/api/check-list/${checkListContext?.checkListId}/common/question/status`, - checkListContext?.deletedCheckListByServer - ) - .then(() => checkListContext?.setDeletedCheckListByServer({ question: [] })); - - axios - .put( - `/api/check-list/${checkListContext?.checkListId}/common/question`, - checkListContext?.choseCheckListByServer - ) - .then(() => { - checkListContext?.setChoseCheckListByServer({ - typeA: [], - typeB: [], - typeD: [], - typeM: {}, - }); - }); - + checkListContext?.onChoseCheckListHandler(); setIsEdit(false); }; @@ -87,6 +66,12 @@ function CheckListStackNav({ setIsLogin }: IProps) { headerShadowVisible: false, }; + useEffect(() => { + setInterval(() => { + onSubmitHandler(); + }, 100000); + }, []); + return ( <> @@ -100,13 +85,7 @@ function CheckListStackNav({ setIsLogin }: IProps) { /> ( - - )} + children={() => } options={() => ({ animationTypeForReplace: 'pop', animation: 'slide_from_bottom', diff --git a/screens/BasicCheckList/BasicInfoOfBasicCheckList.tsx b/screens/BasicCheckList/BasicInfoOfBasicCheckList.tsx index d89ef5f..ae5a0a3 100644 --- a/screens/BasicCheckList/BasicInfoOfBasicCheckList.tsx +++ b/screens/BasicCheckList/BasicInfoOfBasicCheckList.tsx @@ -1,6 +1,7 @@ import React, { Dispatch, SetStateAction, + useCallback, useContext, useEffect, useMemo, @@ -24,6 +25,7 @@ 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'; +import { useFocusEffect } from '@react-navigation/native'; interface IProps { isEdit: boolean; @@ -40,7 +42,6 @@ function BasicInfoOfBasicCheckList({ isEdit, setIsBottomSheet }: IProps) { const [checkListSummary, setCheckListSummary] = useState({}); const getServerData = async () => { - console.log(checkListContext?.checkListId); try { const serverResponse = await axios.get( `/api/check-list/${checkListContext?.checkListId}/common?mainCategory=기본정보` @@ -63,6 +64,11 @@ function BasicInfoOfBasicCheckList({ isEdit, setIsBottomSheet }: IProps) { useEffect(() => { getServerData(); }, [modal]); + useFocusEffect( + useCallback(() => { + getServerData(); + }, [modal]) + ); // setCheckLists(response.data); // λ°”ν…€μ‹œνŠΈ λ™μž‘μ„ μœ„ν•œ μ½”λ“œ const bottomSheetModalRef = useRef(null); diff --git a/screens/bottomTab/Home.tsx b/screens/bottomTab/Home.tsx index e026768..f01eca2 100644 --- a/screens/bottomTab/Home.tsx +++ b/screens/bottomTab/Home.tsx @@ -4,6 +4,7 @@ import EmptyHome from '../../components/Home/EmptyHome'; import CheckListHome from '../../components/Home/CheckListHome'; import axios from 'axios'; import { ActivityIndicator, RefreshControl, ScrollView } from 'react-native'; +import { useFocusEffect } from '@react-navigation/native'; function Home() { const [loading, setLoading] = useState(false); @@ -32,7 +33,11 @@ function Home() { useEffect(() => { getHomeDataHandler(); }, []); - + useFocusEffect( + useCallback(() => { + getHomeDataHandler(); + }, []) + ); return ( <> {loading ? (