Skip to content

Commit

Permalink
Merge pull request #169 from LM-channel-team-project/feature/loadComp…
Browse files Browse the repository at this point in the history
…onent

graphql api loading시 load Component 설정
  • Loading branch information
lhk3337 authored Sep 4, 2021
2 parents 7c831b7 + 0734c97 commit 208f8d7
Show file tree
Hide file tree
Showing 17 changed files with 56 additions and 105 deletions.
4 changes: 1 addition & 3 deletions client/src/page/BaseTemplate/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ const BaseTemplate = ({ children, Modal, closeModal }: TemplateProps) => {

return (
<S.Template>
<S.Nav>
<MenuBar />
</S.Nav>
<MenuBar />
<S.Body>{children}</S.Body>
{Modal && ModalSection}
</S.Template>
Expand Down
2 changes: 0 additions & 2 deletions client/src/page/BaseTemplate/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ export const Template = styled.section`
width: 100%;
`;

export const Nav = styled.nav``;

export const Body = styled.section``;

export const ModalContainer = styled.div`
Expand Down
10 changes: 2 additions & 8 deletions client/src/page/Dashboard/Personal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import BaseTemplate from 'page/BaseTemplate';
import PersonalDetailModal, {
PersonalModalProps,
} from 'component/orgamisms/DetailModal/Personal';
import LoadingPage from 'page/Loading';
import * as S from './style';

type ExtractType<O, K> = K extends keyof O ? O[K] : never;
Expand All @@ -30,14 +31,7 @@ const PersonalDashboardPage = ({ className }: any) => {
${listUser}
`,
);

if (loading) {
return (
<S.LoadContainer>
<S.LoadingComponent />
</S.LoadContainer>
);
}
if (loading) return <LoadingPage />;

const { items } = data.listUser;
const users = items.reduce((obj: any, user: any) => {
Expand Down
9 changes: 0 additions & 9 deletions client/src/page/Dashboard/Personal/style.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import styled from 'styled-components';
import Floating from 'component/atoms/FloatingButton';
import _TextLabel from 'component/atoms/TextLabel';
import Loading from 'component/atoms/Loading';

export const Container = styled.div`
display: flex;
Expand Down Expand Up @@ -273,12 +272,4 @@ export const PersonState = styled((props: { text: string }) =>

export const FloatingButton = styled(Floating)``;

export const LoadContainer = styled.div`
display: flex;
justify-content: center;
margin-top: 20%;
`;

export const LoadingComponent = styled(Loading)``;

export default {};
17 changes: 8 additions & 9 deletions client/src/page/Dashboard/Team/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import makeTeamIdByUserId from 'utils/setTeamId';
import BaseTemplate from 'page/BaseTemplate';
import { useHistory } from 'react-router-dom';
import ConfirmModal from 'component/orgamisms/ConfirmModal';
import LoadingPage from 'page/Loading';
import TeamDetailModal, {
TeamModalProps,
} from 'component/orgamisms/DetailModal/Team';
Expand Down Expand Up @@ -47,13 +48,7 @@ const TeamDashboardPage = ({ className, isLoggedIn }: any) => {
{ skip: !userData?.getUser.items[0]?.id },
);

if (loading) {
return (
<Team.LoadContainer>
<Team.LoadingComponent />
</Team.LoadContainer>
);
}
if (loading) return <LoadingPage />;

const { items } = data.listTeamDashboard;
const skills = (team: any) =>
Expand Down Expand Up @@ -122,7 +117,9 @@ const TeamDashboardPage = ({ className, isLoggedIn }: any) => {
const onCloseModal = () => setModal({});

const onClickUpdate = async () => {
const res = await refetch({ id: makeTeamIdByUserId(userData.getUser.items[0].id) });
const res = await refetch({
id: makeTeamIdByUserId(userData.getUser.items[0].id),
});
if (modal?.type === 'update') {
setModal({ type: 'detail', data: res?.data.getTeamDashboard });
} else {
Expand Down Expand Up @@ -165,7 +162,9 @@ const TeamDashboardPage = ({ className, isLoggedIn }: any) => {
return (
<Team.FloatingButton
onClick={async () => {
const res = await refetch({ id: makeTeamIdByUserId(userData.getUser.items[0].id) });
const res = await refetch({
id: makeTeamIdByUserId(userData.getUser.items[0].id),
});
setModal({ type: 'detail', data: res?.data.getTeamDashboard });
}}
>
Expand Down
9 changes: 0 additions & 9 deletions client/src/page/Dashboard/Team/style.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import styled from 'styled-components';
import globalTheme from 'style/theme';
import TextLabel from 'component/atoms/TextLabel';
import Loading from 'component/atoms/Loading';
import Floating from 'component/atoms/FloatingButton';

export const TeamDashboardPage = styled.div`
Expand Down Expand Up @@ -286,12 +285,4 @@ export const State = styled((props: { text: string }) =>
}
`;

export const LoadContainer = styled.div`
display: flex;
justify-content: center;
margin-top: 20%;
`;

export const LoadingComponent = styled(Loading)``;

export default {};
7 changes: 2 additions & 5 deletions client/src/page/Home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Link } from 'react-router-dom';
import { gql, useQuery } from '@apollo/client';
import { Auth } from 'aws-amplify';
import BaseTemplate from 'page/BaseTemplate';
import LoadingPage from 'page/Loading';
import * as S from './style';

const googleLoginOnClick = () =>
Expand All @@ -20,11 +21,7 @@ const Home = ({ className, isLoggedIn }: any) => {
);
if (isLoggedIn) {
if (loading) {
return (
<S.LoadContainer>
<S.LoadingComponent />
</S.LoadContainer>
);
return <LoadingPage />;
}
}
// 8월 13일 초대 주소 get, 30일 마다 갱신
Expand Down
9 changes: 0 additions & 9 deletions client/src/page/Home/style.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import styled from 'styled-components';
import Loading from 'component/atoms/Loading';

export const Home = styled.div`
position: relative;
Expand Down Expand Up @@ -106,11 +105,3 @@ export const WhiteButton = styled.button`
margin-left: 1rem;
}
`;

export const LoadContainer = styled.div`
display: flex;
justify-content: center;
margin-top: 20%;
`;

export const LoadingComponent = styled(Loading)``;
12 changes: 12 additions & 0 deletions client/src/page/Loading/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import BaseTemplate from 'page/BaseTemplate';
import { LoadContainer, LoadingComponent } from './style';

const LoadingPage = () => (
<BaseTemplate>
<LoadContainer>
<LoadingComponent />
</LoadContainer>
</BaseTemplate>
);
export default LoadingPage;
10 changes: 10 additions & 0 deletions client/src/page/Loading/style.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import styled from 'styled-components';
import Loading from 'component/atoms/Loading';

export const LoadContainer = styled.div`
display: flex;
justify-content: center;
margin-top: 20%;
`;

export const LoadingComponent = styled(Loading)``;
7 changes: 2 additions & 5 deletions client/src/page/Mail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { gql, useQuery } from '@apollo/client';
import MailDetailModal, {
MailModalProps,
} from 'component/orgamisms/DetailModal/Mail';
import LoadingPage from 'page/Loading';
import * as S from './style';

type ExtractType<O, K> = K extends keyof O ? O[K] : never;
Expand All @@ -33,11 +34,7 @@ const Mail = ({ className, isLoggedIn }: any) => {
}, [isLoggedIn]);

if (loading) {
return (
<S.LoadContainer>
<S.LoadingComponent />
</S.LoadContainer>
);
return <LoadingPage />;
}
const mail = data && data.getUser.items?.length !== 0 ? data.getUser.items[0].mail : [];
const mailList = mail.map((el: any) => {
Expand Down
9 changes: 0 additions & 9 deletions client/src/page/Mail/style.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import styled from 'styled-components';
import Loading from 'component/atoms/Loading';

export const Container = styled.div`
display: flex;
Expand Down Expand Up @@ -155,11 +154,3 @@ export const Name = styled.h1`
export const Content = styled.div`
display: flex;
`;

export const LoadContainer = styled.div`
display: flex;
justify-content: center;
margin-top: 20%;
`;

export const LoadingComponent = styled(Loading)``;
7 changes: 2 additions & 5 deletions client/src/page/Notice/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import NoticeDetailModal, {
NoticeModalProps,
} from 'component/orgamisms/DetailModal/Notice';
import NoticeAddForm from 'component/orgamisms/DetailModal/NoticeAddForm';
import LoadingPage from 'page/Loading';
import * as S from './style';

type ExtractType<O, K> = K extends keyof O ? O[K] : never;
Expand Down Expand Up @@ -43,11 +44,7 @@ const Notice = ({ className }: any) => {
}
}, [data]);
if (loading) {
return (
<S.LoadContainer>
<S.LoadingComponent />
</S.LoadContainer>
);
return <LoadingPage />;
}

const { items } = noticeData?.listNotice;
Expand Down
12 changes: 2 additions & 10 deletions client/src/page/Notice/style.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import styled from 'styled-components';
import Loading from 'component/atoms/Loading';

export const Container = styled.div`
display: flex;
Expand Down Expand Up @@ -29,6 +28,7 @@ export const CreateBtn = styled.button`
cursor: pointer;
width: 20rem;
height: 6rem;
margin-top: 2rem;
font-size: 2rem;
border-radius: 0.5rem;
`;
Expand All @@ -51,7 +51,7 @@ export const NoticeList = styled.div`
}
padding-top: 1em;
width: 124rem;
height: 68rem;
height: 66vh;
@media screen and (max-width: 1290px) {
width: 108rem;
}
Expand Down Expand Up @@ -163,11 +163,3 @@ export const Name = styled.h1`
export const Content = styled.div`
display: flex;
`;

export const LoadContainer = styled.div`
display: flex;
justify-content: center;
margin-top: 20%;
`;

export const LoadingComponent = styled(Loading)``;
2 changes: 1 addition & 1 deletion client/src/page/Result/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const ResultPage = styled.div`
align-items: center;
background-color: #e9e9e9;
border-radius: 1em;
z-index:100;
z-index: 100;
width: 130rem;
height: 70rem;
@media screen and (max-width: 85rem) {
Expand Down
26 changes: 14 additions & 12 deletions client/src/page/Survey/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { gql, useQuery, useMutation } from '@apollo/client';
import { listQuestionnaires, getUser } from 'graphql/queries';
import { createUser } from 'graphql/mutations';
import BaseTemplate from 'page/BaseTemplate';
import LoadingPage from 'page/Loading';
import { IAnswers } from 'component/molecules/QuestionRespond';
import Questionnaire from 'component/orgamisms/Questionnaire';
import ResultComponent from '../Result';
Expand Down Expand Up @@ -43,8 +44,11 @@ const Survey = ({ className, isLoggedIn }: any) => {

const bUserUpdating = useRef<boolean>(false);
const [page, setPage] = useState<number>(0);
const [answerRespond, setanswerRespond] = useState<IAnswers[]>(userData?.getUser.items[0]
? userData.getUser.items[0].question : firstInput);
const [answerRespond, setanswerRespond] = useState<IAnswers[]>(
userData?.getUser.items[0]
? userData.getUser.items[0].question
: firstInput,
);
const [resultOpen, setResultOpen] = useState<boolean>(false);

if (userError) {
Expand All @@ -55,11 +59,7 @@ const Survey = ({ className, isLoggedIn }: any) => {
}

if (userLoading || loading || bUserUpdating.current || !userData?.getUser) {
return (
<S.LoadContainer>
<S.LoadingComponent />
</S.LoadContainer>
);
return <LoadingPage />;
}

if (!userLoading && !userError) {
Expand Down Expand Up @@ -194,13 +194,15 @@ const Survey = ({ className, isLoggedIn }: any) => {

return (
<BaseTemplate>
{resultOpen
? <ResultComponent
{resultOpen ? (
<ResultComponent
userId={userData?.getUser.items[0].id}
surveyCompleted={userData?.getUser.items[0].surveyCompleted}
answerRespond={answerRespond}
onCloseResult={onCloseResult}/>
: <S.SurveyWrapper>
onCloseResult={onCloseResult}
/>
) : (
<S.SurveyWrapper>
<S.SurveyPage>
<Questionnaire
key={nowQuestionnaire.id}
Expand All @@ -217,7 +219,7 @@ const Survey = ({ className, isLoggedIn }: any) => {
/>
</S.SurveyPage>
</S.SurveyWrapper>
}
)}
</BaseTemplate>
);
};
Expand Down
9 changes: 0 additions & 9 deletions client/src/page/Survey/style.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import styled from 'styled-components';
import Loading from 'component/atoms/Loading';

export const SurveyPage = styled.div`
display: flex;
Expand All @@ -15,11 +14,3 @@ export const SurveyWrapper = styled.div`
left: 50%;
transform: translate(-50%, -50%);
`;

export const LoadContainer = styled.div`
display: flex;
justify-content: center;
margin-top: 20%;
`;

export const LoadingComponent = styled(Loading)``;

0 comments on commit 208f8d7

Please sign in to comment.