Skip to content

Commit

Permalink
fix: QA
Browse files Browse the repository at this point in the history
checkList 디폴트 사진, 삭제 및 복구 로직 수정, 자동 저장 로직 수정
#70
  • Loading branch information
11t518s committed Apr 4, 2022
1 parent 4adcf33 commit 90fbe4d
Show file tree
Hide file tree
Showing 15 changed files with 97 additions and 65 deletions.
20 changes: 20 additions & 0 deletions Context/CheckListByServer.tsx
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -8,6 +9,8 @@ interface contextType {
setChoseCheckListByServer: Dispatch<SetStateAction<choseCheckListByServerType>>;
checkListId: number | false;
setCheckListId: Dispatch<SetStateAction<number | false>>;
onChoseCheckListHandler: () => void;
onDeleteCheckListHandler: (data: deletedCheckListByServerType) => void;
}

export const checkListCtx = createContext<contextType | null>(null);
Expand All @@ -22,6 +25,21 @@ const CheckListStore: React.FC = (props) => {
typeM: {},
});
const [checkListId, setCheckListId] = useState<number | false>(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 (
<checkListCtx.Provider
Expand All @@ -32,6 +50,8 @@ const CheckListStore: React.FC = (props) => {
setChoseCheckListByServer,
checkListId,
setCheckListId,
onChoseCheckListHandler,
onDeleteCheckListHandler,
}}
>
{props.children}
Expand Down
Binary file added assets/images/checkList/checkLIstDefaultImg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -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 })),
Expand Down
6 changes: 3 additions & 3 deletions components/CheckListComponent/ButtonOfGoToTrash.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand Down
4 changes: 2 additions & 2 deletions components/CheckListComponent/CheckListSummaryComponenet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function CheckListSummaryComponenet({ checkListSummary }: IProps) {
return (
<>
<View style={styles.summaryWrapper}>
<Pressable onPress={pinCheckListHandler}>
<Pressable onPress={pinCheckListHandler} style={styles.summaryImageWrapper}>
<Image
style={styles.summaryPinImg}
source={
Expand All @@ -35,7 +35,7 @@ function CheckListSummaryComponenet({ checkListSummary }: IProps) {
source={
checkListSummary.imgUri
? { uri: checkListSummary.imgUri }
: require('../../assets/images/home/homeMainImg.png')
: require('../../assets/images/checkList/checkLIstDefaultImg.png')
}
/>
</Pressable>
Expand Down
12 changes: 11 additions & 1 deletion components/CheckListComponent/styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand Down
5 changes: 3 additions & 2 deletions components/Home/CheckListHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ function CheckListHome({ homeCheckList, refreshing, onRefresh }: IProps) {
<ScrollView
refreshControl={<RefreshControl refreshing={refreshing} onRefresh={onRefresh} />}
>
<DefaultText style={[styles.pinnedText]}>📌 고정된 리스트</DefaultText>

{homeCheckList.some((item) => item.pinned) ? (
<DefaultText style={[styles.pinnedText]}>📌 고정된 리스트</DefaultText>
) : null}
<ScrollView horizontal={true}>
{homeCheckList
.filter((item) => item.pinned)
Expand Down
11 changes: 6 additions & 5 deletions components/Home/PinnedCheckList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ function PinnedCheckList({ pinnedCheckList }: iProps) {
resizeMode="cover"
/>
) : (
<Image
style={[styles.pinnedChecklistImg]}
source={require('../../assets/images/home/mainLogo.png')}
resizeMode="contain"
/>
<View style={styles.pinnedDefaultImgWrapper}>
<Image
style={styles.pinnedDefaultImg}
source={require('../../assets/images/checkList/checkLIstDefaultImg.png')}
/>
</View>
)}
<View style={styles.pinnedChecklistSummaryCard}>
<View>
Expand Down
24 changes: 15 additions & 9 deletions components/Home/UnPinnedCheckList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ function UnPinnedCheckList({ unPinnedCheckList }: iProps) {
resizeMode="cover"
/>
) : (
<Image
style={[styles.unpinnedChecklistImg]}
source={require('../../assets/images/home/mainLogo.png')}
resizeMode="contain"
/>
<View style={styles.unpinnedDefaultImgWrapper}>
<Image
style={[styles.unpinnedChecklistImg]}
source={require('../../assets/images/checkList/checkLIstDefaultImg.png')}
resizeMode="contain"
/>
</View>
)}
<View style={styles.unpinnedChecklistSummaryCard}>
<View>
Expand Down Expand Up @@ -66,10 +68,14 @@ function UnPinnedCheckList({ unPinnedCheckList }: iProps) {
</View>
)}
<View style={[styles.bottomElement]}>
<Image source={require('../../assets/images/home/distanceImg.png')} />
<DefaultText style={[styles.blueText, styles.bottomElementText]}>
{unPinnedCheckList.distance && unPinnedCheckList.distance}
</DefaultText>
{unPinnedCheckList.distance && (
<>
<Image source={require('../../assets/images/home/distanceImg.png')} />
<DefaultText style={[styles.blueText, styles.bottomElementText]}>
{unPinnedCheckList.distance}
</DefaultText>
</>
)}
</View>
</View>
</View>
Expand Down
13 changes: 12 additions & 1 deletion components/Home/styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions components/camera/CameraAndGallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,19 @@ const Tab = createMaterialTopTabNavigator();
interface IProps {
setIsEdit: Dispatch<SetStateAction<boolean>>;
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);
};

const onCameraHandler = () => {
setOnModal(!onModal);
};

setInterval(() => {
onSubmitHandler();
}, 100000);

return (
<>
<Tab.Navigator
Expand Down
39 changes: 9 additions & 30 deletions navigation/Main/StackNavigation/StackNavigationOfCheckList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Dispatch, SetStateAction, useContext, useState } from 'react';
import React, { Dispatch, SetStateAction, useContext, useEffect, useState } from 'react';
import { Image, Pressable, Share } from 'react-native';

import BasicCheckList from './BasicCheckList/BasiclCheckList';
Expand All @@ -12,7 +12,6 @@ import {
NativeStackNavigationOptions,
} from '@react-navigation/native-stack';
import { checkListCtx } from '../../../Context/CheckListByServer';
import axios from 'axios';
import { useNavigation } from '@react-navigation/native';
import Map from '../../../screens/bottomTab/Map';

Expand Down Expand Up @@ -47,27 +46,7 @@ function CheckListStackNav({ setIsLogin }: IProps) {
};

const onSubmitHandler = async () => {
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);
};

Expand All @@ -87,6 +66,12 @@ function CheckListStackNav({ setIsLogin }: IProps) {
headerShadowVisible: false,
};

useEffect(() => {
setInterval(() => {
onSubmitHandler();
}, 100000);
}, []);

return (
<>
<NativeStack.Navigator screenOptions={screenOptions}>
Expand All @@ -100,13 +85,7 @@ function CheckListStackNav({ setIsLogin }: IProps) {
/>
<NativeStack.Screen
name="basicCheckList"
children={() => (
<BasicCheckList
isEdit={isEdit}
setIsEdit={setIsEdit}
onSubmitHandler={onSubmitHandler}
/>
)}
children={() => <BasicCheckList isEdit={isEdit} setIsEdit={setIsEdit} />}
options={() => ({
animationTypeForReplace: 'pop',
animation: 'slide_from_bottom',
Expand Down
8 changes: 7 additions & 1 deletion screens/BasicCheckList/BasicInfoOfBasicCheckList.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, {
Dispatch,
SetStateAction,
useCallback,
useContext,
useEffect,
useMemo,
Expand All @@ -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;
Expand All @@ -40,7 +42,6 @@ function BasicInfoOfBasicCheckList({ isEdit, setIsBottomSheet }: IProps) {
const [checkListSummary, setCheckListSummary] = useState<any>({});

const getServerData = async () => {
console.log(checkListContext?.checkListId);
try {
const serverResponse = await axios.get(
`/api/check-list/${checkListContext?.checkListId}/common?mainCategory=기본정보`
Expand All @@ -63,6 +64,11 @@ function BasicInfoOfBasicCheckList({ isEdit, setIsBottomSheet }: IProps) {
useEffect(() => {
getServerData();
}, [modal]);
useFocusEffect(
useCallback(() => {
getServerData();
}, [modal])
);
// setCheckLists(response.data);
// 바텀시트 동작을 위한 코드
const bottomSheetModalRef = useRef<BottomSheetModal>(null);
Expand Down
7 changes: 6 additions & 1 deletion screens/bottomTab/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -32,7 +33,11 @@ function Home() {
useEffect(() => {
getHomeDataHandler();
}, []);

useFocusEffect(
useCallback(() => {
getHomeDataHandler();
}, [])
);
return (
<>
{loading ? (
Expand Down

0 comments on commit 90fbe4d

Please sign in to comment.