Skip to content

Commit

Permalink
Merge pull request #25 from luciancah/develop
Browse files Browse the repository at this point in the history
v1.0.1
  • Loading branch information
luciancah authored Sep 1, 2022
2 parents 1033835 + 2a52972 commit 15d7b5c
Show file tree
Hide file tree
Showing 13 changed files with 120 additions and 125 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,5 @@ LOGIN_METHOD=PortalSSOToken
STUDENT_ID_KEY=whateveryouwant
COURSES_KEY=whateveryouwant
```
## Thanks to
[jeongbinboo🎾](https://github.com/jeongbinboo)
9 changes: 6 additions & 3 deletions SejongAttendanceV1/components/attendance/AttendanceCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,23 @@ const AttendanceCard = ({
const [lectureData, setLectureData] = useState([]);

useEffect(() => {
parseXlsxData(deptId, courseId, classId, studentId)
parseXlsxData(deptId, courseId, classId, studentId, setIsParse)
.then(data => {
console.log(courseId);
console.log(data);
setLectureData(data);
})
.then(() => setUnpassCount(checkStatusCounter(lectureData)))
.catch(error => {
console.log('error');
console.log(error);
setIsParse(data => data + 1);
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [setLectureData, setUnpassCount, isParse, refreshing]);
}, [isParse, refreshing]);

useEffect(() => {
setUnpassCount(checkStatusCounter(lectureData));
}, [lectureData]);

return (
<View style={styles.component}>
Expand Down
23 changes: 13 additions & 10 deletions SejongAttendanceV1/components/course/UnPassCourseCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,51 @@ import {StyleSheet, View, Text} from 'react-native';
import parseXlsxData from '../../utils/parseXlsxData';
import CourseCard from './CourseCard';
import {height, scale} from '../../config/globalStyles';
import {useDispatch, useSelector} from 'react-redux';
import {setIsChecked} from '../../redux/Actions';

const UnPassCourseCard = ({
deptId,
courseId,
classId,
studentId,
isThere,
setIsThere,
refreshing,
}) => {
const [lectureData, setLectureData] = useState([]);
const [isParse, setIsParse] = useState(0);
const [flag, setFlag] = useState(false);
const courseList = useSelector(state => state.courseList);
const dispatch = useDispatch();
const mounted = useRef(false);

useEffect(() => {
setFlag(false);
}, [courseList]);

useEffect(() => {
if (!mounted.current) {
mounted.current = true;
} else {
if (flag === false) {
setIsThere(true);
if (flag === true) {
dispatch(setIsChecked(1));
}
}
}, [isThere]);
}, [courseList, flag]);

useEffect(() => {
console.log('unpasscoursecard');
parseXlsxData(deptId, courseId, classId, studentId)
parseXlsxData(deptId, courseId, classId, studentId, setIsParse)
.then(data => {
console.log(data);
setLectureData([...data]);
console.log(lectureData);
})
.catch(error => {
console.log('error');
console.log(error);
setIsParse(data => data + 1);
});
console.log('lecture');
console.log(lectureData);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [setLectureData, isParse, refreshing]);
}, [setLectureData, isParse, refreshing, setFlag]);

return (
<View>
Expand Down
6 changes: 6 additions & 0 deletions SejongAttendanceV1/components/profile/CourseTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {height, width, scale} from '../../config/globalStyles';

import Config from 'react-native-config';
import AsyncStorage from '@react-native-async-storage/async-storage';
import {useDispatch} from 'react-redux';
import {setCourseList, setIsChecked} from '../../redux/Actions';

const delCourse = async newCourses => {
try {
Expand All @@ -25,6 +27,8 @@ const CourseTable = ({
navigation,
setDelCourse,
}) => {
const dispatch = useDispatch();

return (
<Cell
contentContainerStyle={styles.cell}
Expand All @@ -48,6 +52,8 @@ const CourseTable = ({
if (buttonIndex === 1) {
courses.splice(course_idx, 1);
delCourse(courses);
dispatch(setCourseList(courses));
dispatch(setIsChecked(0));
setDelCourse(data => data + 1);
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,14 +528,15 @@
CODE_SIGN_ENTITLEMENTS = SejongAttendanceV1/SejongAttendanceV1.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 1.0.1;
DEVELOPMENT_TEAM = PL3MPVK83S;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = SejongAttendanceV1/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.1;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand All @@ -561,13 +562,14 @@
CODE_SIGN_ENTITLEMENTS = SejongAttendanceV1/SejongAttendanceV1.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 1.0.1;
DEVELOPMENT_TEAM = PL3MPVK83S;
INFOPLIST_FILE = SejongAttendanceV1/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.1;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down
15 changes: 1 addition & 14 deletions SejongAttendanceV1/ios/SejongAttendanceV1/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,13 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<!-- <key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
<key>NSLocationWhenInUseUsageDescription</key>
<string></string> -->
<key>UIAppFonts</key>
<array>
<string>AntDesign.ttf</string>
Expand Down
8 changes: 6 additions & 2 deletions SejongAttendanceV1/navigation/profile/ProfileStackNavi.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import CreditScreen from '../../screens/profile/CreditScreen';
import HelpScreen from '../../screens/profile/HelpScreen';
import AsyncStorage from '@react-native-async-storage/async-storage';
//Redux
import {useSelector} from 'react-redux';
import {useSelector, useDispatch} from 'react-redux';
import {setCourseList} from '../../redux/Actions';

const Stack = createNativeStackNavigator();

Expand All @@ -24,6 +25,7 @@ const ProfileStackNavi = ({navigation}) => {
let checkCourseNumber = /^\d{6}$/;
let checkClassNumber = /^\d{3}$/;
let courseData = [];
const dispatch = useDispatch();

const pushCourseToStorage = (
courseName,
Expand All @@ -47,8 +49,10 @@ const ProfileStackNavi = ({navigation}) => {
curValue = JSON.parse(oldValue).courses;
curValue.push(courseData[0]);
}
dispatch(setCourseList(curValue));
const courses = JSON.stringify({courses: curValue});
await AsyncStorage.setItem(Config.COURSES_KEY, courses);
return courses;
} catch (error) {
console.log('저장 실패');
Alert.alert('저장 실패', '죄송합니다.\n다시 시도해주세요...죄송', [
Expand Down Expand Up @@ -128,7 +132,7 @@ const ProfileStackNavi = ({navigation}) => {
courseAddStorage();
Alert.alert(
'강의 추가',
`${courseName}(${courseNum}-${courseClass})\강의를 추가했어요.👻`,
`${courseName}(${courseNum}-${courseClass})\n강의를 추가했어요.👻`,
[
{
text: '오키',
Expand Down
5 changes: 5 additions & 0 deletions SejongAttendanceV1/redux/Actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,8 @@ export const setStudentId = data => ({
type: 'SET_STUDENT_ID',
payload: data,
});

export const setIsChecked = data => ({
type: 'SET_IS_CHECKED',
payload: data,
});
6 changes: 6 additions & 0 deletions SejongAttendanceV1/redux/RootReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const initialState = {
courseCollegeName: '',
courseDeptName: '',
courseList: [],
isChecked: 0,
};

const rootReducer = (state = initialState, action) => {
Expand Down Expand Up @@ -56,6 +57,11 @@ const rootReducer = (state = initialState, action) => {
...state,
studentId: action.payload,
};
case 'SET_IS_CHECKED':
return {
...state,
isChecked: action.payload,
};
default:
return state;
}
Expand Down
39 changes: 11 additions & 28 deletions SejongAttendanceV1/screens/analysis/AnalysisScreen.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,26 @@
import React, {useState} from 'react';
import {
StyleSheet,
View,
Text,
ScrollView,
StatusBar,
RefreshControl,
} from 'react-native';
import React, {useEffect, useState} from 'react';
import {StyleSheet, View, Text, ScrollView, StatusBar} from 'react-native';
import {height, width, scale} from '../../config/globalStyles';
import UnPassCourseCard from '../../components/course/UnPassCourseCard';
import {useSelector} from 'react-redux';

const wait = timeout => {
return new Promise(resolve => setTimeout(resolve, timeout));
};
import {useIsFocused} from '@react-navigation/native';

const AnalysisScreen = () => {
const isFocused = useIsFocused();
const studentId = useSelector(state => state.studentId);
const courseList = useSelector(state => state.courseList);
const [isThere, setIsThere] = useState(false);
const isChecked = useSelector(state => state.isChecked);
const [flag, setFlag] = useState(false);

const [refreshing, setRefreshing] = React.useState(false);
const onRefresh = React.useCallback(() => {
setRefreshing(true);
wait(1000).then(() => setRefreshing(false));
}, []);
useEffect(() => {
setFlag(false);
}, [courseList]);

return (
<View style={styles.container}>
<StatusBar barStyle={'dark-content'} />
<Text style={styles.title}>급한거🔥</Text>
<ScrollView
showsVerticalScrollIndicator={false}
refreshControl={
<RefreshControl refreshing={refreshing} onRefresh={onRefresh} />
}>
<ScrollView showsVerticalScrollIndicator={false}>
{courseList.length > 0 ? (
courseList.map((course, idx) => {
return (
Expand All @@ -45,9 +30,7 @@ const AnalysisScreen = () => {
courseId={course.course_id}
classId={course.class_id}
studentId={studentId}
isThere={isThere}
setIsThere={setIsThere}
refreshing={refreshing}
isFocused={isFocused}
/>
);
})
Expand All @@ -57,7 +40,7 @@ const AnalysisScreen = () => {
<Text style={styles.emptyAttendanceText}>과목을 추가해주세요.</Text>
</View>
)}
{!isThere && !flag ? (
{isChecked === 0 && !flag ? (
<View style={styles.emptyAttendanceContainer}>
<Text style={styles.emptyAttendanceText}>모두 완료했어요 :)</Text>
</View>
Expand Down
9 changes: 4 additions & 5 deletions SejongAttendanceV1/screens/attendance/AttendanceScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,16 @@ const AttendanceScreen = ({navigation}) => {
const [courses, setCourses] = useState([]);
const dispatch = useDispatch();

const [refreshCount, setRefreshCount] = useState(0);
const [refreshing, setRefreshing] = React.useState(false);
const onRefresh = React.useCallback(() => {
setRefreshing(true);
setRefreshCount(value => value + 1);
wait(1000).then(() => setRefreshing(false));
}, []);

useEffect(() => {
getAsyncStudendtId();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

useEffect(() => {
getAsyncCourses();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isFocused]);
Expand Down Expand Up @@ -112,7 +110,8 @@ const AttendanceScreen = ({navigation}) => {
studentId={id}
thisWeek={thisWeek}
navigation={navigation}
refreshing={refreshing}
refreshing={refreshCount}
isFocused={isFocused}
/>
);
})}
Expand Down
2 changes: 1 addition & 1 deletion SejongAttendanceV1/screens/profile/ProfileScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const ProfileScreen = ({navigation}) => {
options: ['취소', '강의 초기화하기'],
destructiveButtonIndex: 1,
cancelButtonIndex: 0,
title: `저장된 데이터가 모두 삭제됩니다.\강의 정보를 삭제하시겠습니까?`,
title: `저장된 데이터가 모두 삭제됩니다.\n강의 정보를 삭제하시겠습니까?`,
},
buttonIndex => {
if (buttonIndex === 1) {
Expand Down
Loading

0 comments on commit 15d7b5c

Please sign in to comment.