Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tf-graduate-credit] 배포를 위한 type 에러 및 eslint 에러 해결 #602

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import {View, ActivityIndicator} from 'react-native';
import {ActivityIndicator} from 'react-native';
import {colors} from '@uoslife/design-system';
import styled from '@emotion/native';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {ApiResponse} from '../types';
import {SUBJECT_BUTTON_LABEL} from '../configs/constants';
import {GraduateCreditNavigationProp} from '../navigators/types/graduateCredit';
import {SubjectCreditListRes} from '../../../../api/services/core/graduateCredit/graduateCreditAPI.type';

type SubjectProps = {
label: keyof typeof SUBJECT_BUTTON_LABEL | string;
// 학과 | 과목 | 교양 세부
Expand All @@ -31,7 +32,7 @@ const SubjectDetailButton = ({
return (
<S.SubjectButton
type={type}
disabled={type === 'major' || type == 'elective'}
disabled={type === 'major' || type === 'elective'}
onPress={handlePressButton}>
<S.ButtonText type={type}>{label}</S.ButtonText>
</S.SubjectButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ import styled from '@emotion/native';
import {Txt, colors, Icon} from '@uoslife/design-system';
import ProgressBar from '../ProgressBar';
import {GraduateCreditStackParamList} from '../../navigators/types/graduateCredit';
import {ApiResponse, CreditDetail} from '../../types';
import {
ApiResponse,
CreditDetail,
GeneralEducationDetailList,
GeneralEducationDetail,
} from '../../types';
import LoadingIndicator from '../LoadingIndicator';
import Header from '../../../../../components/molecules/common/header/Header';
import {SubjectCreditListRes} from '../../../../../api/services/core/graduateCredit/graduateCreditAPI.type';
import {GeneralEducationDetailList, GeneralEducationDetail} from '../../types';
import SubjectDetailButton from '../SubjectDetailButton';

type DetailInformationComponentProps = {
Expand Down Expand Up @@ -46,7 +50,7 @@ const MainMajorDetailComponent = ({
<View>
<S.CreditInfoContainer>
<S.CreditInfoBox>
<Txt label={`전공필수`} color="grey130" typograph="titleMedium" />
<Txt label="전공필수" color="grey130" typograph="titleMedium" />
<S.TextWrapper>
<Txt
label={`${requirementCreditCurrent}`}
Expand All @@ -62,7 +66,7 @@ const MainMajorDetailComponent = ({
</S.CreditInfoBox>
<S.VerticalDivider />
<S.CreditInfoBox>
<Txt label={`전공선택`} color="grey130" typograph="titleMedium" />
<Txt label="전공선택" color="grey130" typograph="titleMedium" />
<S.TextWrapper>
<Txt
label={`${electiveCreditCurrent}`}
Expand Down Expand Up @@ -230,7 +234,7 @@ const SubjectDetailComponent = ({
</S.TextWrapper>
<S.ButtonRowLayout>
{generalRequirementDetailCredit.map(
(item: GeneralEducationDetail, index: number) => {
(item: GeneralEducationDetail) => {
if (item.courseTotal < item.courseRequirement) {
return (
<SubjectDetailButton
Expand All @@ -239,9 +243,8 @@ const SubjectDetailComponent = ({
type="elective"
/>
);
} else {
return null;
}
return null;
},
)}
</S.ButtonRowLayout>
Expand Down Expand Up @@ -331,7 +334,7 @@ const SubjectDetailComponent = ({
</S.TextWrapper>
<S.ButtonRowLayout>
{generalElectiveDetailCredit.map(
(item: GeneralEducationDetail, index: number) => {
(item: GeneralEducationDetail) => {
if (item.courseTotal < item.courseRequirement) {
return (
<SubjectDetailButton
Expand All @@ -340,9 +343,8 @@ const SubjectDetailComponent = ({
type="elective"
/>
);
} else {
return null;
}
return null;
},
)}
</S.ButtonRowLayout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ const GraduateCreditScreen = () => {
queryKey: ['getGraduateCredit'],
queryFn: async () => {
const data = await CoreAPI.getAllGraduateCredit();
setGraduateCreditData(data);
setGraduateCreditData(data as GraduateCreditRes);
return data;
},
},
{
queryKey: ['getNecessaryCredit'],
queryFn: async () => {
const data = await CoreAPI.getNecessarySubjectCredit();
setGeneralEducationInfo(data);
setGeneralEducationInfo(data as SubjectCreditListRes);
return data;
},
},
Expand All @@ -94,7 +94,6 @@ const GraduateCreditScreen = () => {
const isPendingForGetNecessaryCredit = generalDetailCreditData.isLoading;
const isErrorForGetNecessaryCredit = generalDetailCreditData.isError;


const {
isSuccess: isSuccessForCreateCredit,
isPending: isPendingForCreateCredit,
Expand All @@ -103,7 +102,7 @@ const GraduateCreditScreen = () => {
mutationFn: () => CoreAPI.createGraduateCredit(),
onSuccess: data => {
queryClient.invalidateQueries({queryKey: ['getNecessaryCredit']});
setGraduateCreditData(data);
setGraduateCreditData(data as GraduateCreditRes);
},
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// 전공필수/선택, 교양필수/선택 등 field 그룹화 위한 배열
import {ButtonConfig} from '../types';
import {GraduateCreditRes} from '../../../../api/services/core/graduateCredit/graduateCreditAPI.type';

export const LABEL_MAPS: {[key: string]: string} = {
major: '전공',
generalEducation: '교양',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,25 @@ import {
} from '../types';
import {GROUP_FIELDS, LABEL_MAPS, BUTTONS_LABEL} from '../configs/constants';

const isCompletedCreditStatus = (
label: string,
inCompletedSubject: {
label: string;
current: number | null;
total: number | null;
}[],
): boolean => {
return inCompletedSubject.some(subject => subject.label === label);
};

class BusinessLogic {
private apiResponse: ApiResponse;

// 교양 세부정보
private necessarySubjectCredit: GeneralEducationDetailList;

private groupedFields: GroupedFields[];

private labelsMap: LabelsMap;

constructor(
Expand Down Expand Up @@ -101,16 +115,6 @@ class BusinessLogic {
}

// label이 미이수 과목 포함되었는지 확인
private isCompletedCreditStatus(
label: string,
inCompletedSubject: {
label: string;
current: number | null;
total: number | null;
}[],
): boolean {
return inCompletedSubject.some(subject => subject.label === label);
}

public tags() {
const inCompletedSubject = this.getInCompletedSubjects();
Expand All @@ -131,26 +135,23 @@ class BusinessLogic {
switch (baseLabel) {
case 'major':
status =
!this.isCompletedCreditStatus('전공 필수', inCompletedSubject) &&
!this.isCompletedCreditStatus('전공 선택', inCompletedSubject);
!isCompletedCreditStatus('전공 필수', inCompletedSubject) &&
!isCompletedCreditStatus('전공 선택', inCompletedSubject);
break;
case 'doubleMajor':
status =
!this.isCompletedCreditStatus(
'복수전공 필수',
inCompletedSubject,
) &&
!this.isCompletedCreditStatus('복수전공 선택', inCompletedSubject);
!isCompletedCreditStatus('복수전공 필수', inCompletedSubject) &&
!isCompletedCreditStatus('복수전공 선택', inCompletedSubject);
break;
case 'minor':
status =
!this.isCompletedCreditStatus('부전공 필수', inCompletedSubject) &&
!this.isCompletedCreditStatus('부전공 선택', inCompletedSubject);
!isCompletedCreditStatus('부전공 필수', inCompletedSubject) &&
!isCompletedCreditStatus('부전공 선택', inCompletedSubject);
break;
case 'generalEducation':
status =
!this.isCompletedCreditStatus('교양 필수', inCompletedSubject) &&
!this.isCompletedCreditStatus('교양 선택', inCompletedSubject);
!isCompletedCreditStatus('교양 필수', inCompletedSubject) &&
!isCompletedCreditStatus('교양 선택', inCompletedSubject);
break;
default:
status = true;
Expand Down