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

콜백 요청 및 안부전화 요청 서비스 신청 목록 #152

Merged
merged 33 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
8798d43
Feat(router): 시니또 서비스 이용내역 페이지 경로 추가
Dobbymin Nov 7, 2024
aced1ee
Feat(router): 시니또 서비스 이용내역 페이지 경로 상수화 및 보고서 쓰기 경로 수정
Dobbymin Nov 7, 2024
0190ed2
Feat(main): 시니또 서비스 이용내역 페이지 이동 버튼 추가
Dobbymin Nov 7, 2024
e4a24f7
Remove: 사용하지 않는 api 호출 및 hook 파일 제거
Dobbymin Nov 7, 2024
ac64fdc
Feat(main): 시니또 서비스 이용내역 페이지 이동 버튼 추가
Dobbymin Nov 7, 2024
66298af
Feat(main): 시니또 서비스 이용내역 페이지 이동 버튼 기능 구현
Dobbymin Nov 7, 2024
9b0c412
Feat(service-history): 안부전화 서비스 신청 기록 요청 api 호출 기능 구현
Dobbymin Nov 7, 2024
3131669
Feat(service-history): 안부전화 서비스 신청 기록 요청 hook 구현
Dobbymin Nov 7, 2024
08cb082
Feat(service-history): 안부전화 서비스 신청 기록 요청 type 작성
Dobbymin Nov 7, 2024
b89d68e
Feat(service-history): 안부전화 서비스 취소 api 호출 기능 구현
Dobbymin Nov 7, 2024
18546e0
Feat(service-history): 안부전화 서비스 취소 hook 구현
Dobbymin Nov 7, 2024
23d8f2c
Feat(service-history): 안부전화 서비스 취소 type 작성
Dobbymin Nov 7, 2024
834cf0c
Feat(service-history): 콜백 서비스 기록 불러오기 api 요청 기능 구현
Dobbymin Nov 7, 2024
3158a60
Feat(service-history): 콜백 서비스 기록 불러오기 hook 구현
Dobbymin Nov 7, 2024
0134329
Feat(service-history): 콜백 서비스 기록 불러오기 type 작성
Dobbymin Nov 7, 2024
feae12c
Feat(service-history): 콜백 서비스 기록 리스트 구현
Dobbymin Nov 7, 2024
75cc6d2
Feat(service-history): 안부전화 서비스 기록 리스트 구현
Dobbymin Nov 7, 2024
0556305
Feat(service-history): 서비스 리스트 설명 글 기능 구현
Dobbymin Nov 7, 2024
85cc969
Feat(service-history): 서비스 리스트 설명 글 배열로 변경 hook 구현
Dobbymin Nov 7, 2024
829dfb7
Feat(service-history): 날짜 포맷팅 변경 hook 구현
Dobbymin Nov 7, 2024
402b18c
Feat(service-history): status에 따른 Dynamic Button 구현
Dobbymin Nov 7, 2024
b8d548d
Feat(service-history): 날짜 schema 구현
Dobbymin Nov 7, 2024
91a5bad
Feat(main): 시니또 이름 컴포넌트 margin 값 변경
Dobbymin Nov 7, 2024
7a264e2
Feat(service-history): text schema 구현
Dobbymin Nov 7, 2024
1a418e5
Feat(service-history): 시니또 진행중인 서비스 기록 페이지 구현
Dobbymin Nov 7, 2024
6673d64
Feat(hello-call-report): 보고서 작성 및 상태변경 api 호출 기능 구현
Dobbymin Nov 7, 2024
9c6195d
Feat(hello-call-report): 보고서 작성 및 상태변경 type 작성
Dobbymin Nov 7, 2024
7d73550
Feat(hello-call-report): 보고서 제출 api 기능 구현
Dobbymin Nov 7, 2024
0bf9dc7
Feat(hello-call-report): 보고서 제출 hook 구현
Dobbymin Nov 7, 2024
267b98a
Feat(hello-call-report): 보고서 제출 기능 구현
Dobbymin Nov 7, 2024
f7b9306
Feat(service-history): helloCallId LocalStorage 저장 기능 구현
Dobbymin Nov 7, 2024
71e47a3
Feat(hello-call-report): 요청 성공 시 helloCallId 제거 및 이전 페이지로 이동
Dobbymin Nov 7, 2024
c979b3e
Remove: 사용하지 않는 코드 제거
Dobbymin Nov 7, 2024
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
3 changes: 2 additions & 1 deletion src/app/routes/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ export const RouterPath = {
SERVICE_HISTORY: `service-history`,
HELLO_CALL: `hello-call`,
HELLO_CALL_SERVICE: `:helloCallId`,
HELLO_CALL_REPORT: `:helloCallId/report`,
HELLO_CALL_REPORT: `report/:helloCallId`,
HELLO_CALL_GUARD_APPLY: `apply`,
CALL_BACK_LIST: `call-back`,
CALL_BACK_DETAIL: `:callBackId`,
CALL_BACK_GUID_LINE: `:guideLineId`,
SENIOR_REGISTER: `/senior-register`,
SINITTO_REVIEW: `review`,
SINITTO_SERVICE_HISTORY: `service-history`,

DUMMY_LOGIN: `/dummy`,
};
16 changes: 16 additions & 0 deletions src/app/routes/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
GuardMainPage,
SinittoMainPage,
DummyRedirectPage,
SinittoServiceHistoryPage,
} from '@/pages';
import { Layout } from '@/shared/components';

Expand Down Expand Up @@ -144,6 +145,21 @@ export const router = createBrowserRouter([
},
],
},
{
path: RouterPath.SINITTO_SERVICE_HISTORY,
children: [
{
path: '',
element: <Layout title='서비스 이용내역' />,
children: [
{
index: true,
element: <SinittoServiceHistoryPage />,
},
],
},
],
},
{
path: RouterPath.CALL_BACK_LIST,
children: [
Expand Down
5 changes: 3 additions & 2 deletions src/pages/common/main/MainPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ const MainPageLayout = styled.div<PageProps>`
transition: background 0.3s ease;

.swiper-pagination-bullet-active {
background-color: ${(props) =>
props.page === 0 ? 'var(--color-secondary)' : 'var(--color-primary)'};;
background-color: ${(props) =>
props.page === 0 ? 'var(--color-secondary)' : 'var(--color-primary)'};
}
`;

const Wrapper = styled.div`
Expand Down
10 changes: 0 additions & 10 deletions src/pages/guard/hello-call-report/api/apply-call-list.api.ts

This file was deleted.

12 changes: 0 additions & 12 deletions src/pages/guard/hello-call-report/api/hooks/useGetApplyCallList.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/pages/guard/hello-call-report/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export { getReport } from './report.api';
export { getTimeLog } from './time-log.api';
export { getAcceptCallList } from './accept-call-list.api';
export { getApplyCallList } from './apply-call-list.api';

export * from './hooks';
export * from './types';

This file was deleted.

1 change: 0 additions & 1 deletion src/pages/guard/hello-call-report/api/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export type { ReportResponse } from './report.response';
export type { TimeLog, TimeLogResponse } from './time-log.response';
export type { AcceptCallListResponse } from './accept-call-list.response';
export type { ApplyCallListResponse } from './apply-call-list.response';
1 change: 1 addition & 0 deletions src/pages/sinitto/hello-call-report/api/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { usePostWriteReport } from './usePostWriteReport.ts';
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { WriteReportRequest } from '../types';
import { postWriteReport } from '../write-report.api';
import { useMutation, UseMutationResult } from '@tanstack/react-query';

export const usePostWriteReport = (): UseMutationResult<
WriteReportRequest,
Error,
WriteReportRequest
> => {
return useMutation<WriteReportRequest, Error, WriteReportRequest>({
mutationFn: (requestPayload: WriteReportRequest) =>
postWriteReport(requestPayload),
onSuccess: () => {
alert('보고서가 작성되었습니다.');
},
onError: (error) => {
console.error('보고서 작성에 실패했습니다.', error);
alert('보고서 작성에 실패했습니다.');
},
});
};
2 changes: 2 additions & 0 deletions src/pages/sinitto/hello-call-report/api/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './hooks';
export * from './types';
1 change: 1 addition & 0 deletions src/pages/sinitto/hello-call-report/api/types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type { WriteReportRequest } from './write-report.request';
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export type WriteReportRequest = {
helloCallId: number;
report: string;
};
14 changes: 14 additions & 0 deletions src/pages/sinitto/hello-call-report/api/write-report.api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { WriteReportRequest } from './types';
import { fetchInstance } from '@/shared/api/instance';

export const postWriteReportPath = () => `/api/hellocalls/reports`;

export const postWriteReport = async (
data: WriteReportRequest
): Promise<WriteReportRequest> => {
const response = await fetchInstance.post<WriteReportRequest>(
postWriteReportPath(),
data
);
return response.data;
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { useState } from 'react';
import { useNavigate } from 'react-router-dom';

import { usePostWriteReport, WriteReportRequest } from '../../api';
import IconCalendar from '../../assets/calendar.svg';
import IconClock from '../../assets/clock.svg';
import IconFile from '../../assets/file.svg';
Expand All @@ -9,10 +11,29 @@ import { Box, Button, Divider, Image, Text, Textarea } from '@chakra-ui/react';
import styled from '@emotion/styled';

const ReportDetail = () => {
const [submitted, setSubmitted] = useState(false);
const [reportContent, setReportContent] = useState('');

const handlerSubmit = () => {
setSubmitted(true);
const { mutate: postWriteReport } = usePostWriteReport();

const navigate = useNavigate();

const helloCallId = localStorage.getItem('helloCallId');

const handleContentChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
setReportContent(e.target.value);
};

const handlerSubmit = (helloCallId: number) => {
const requestPayload: WriteReportRequest = {
helloCallId,
report: reportContent,
};
postWriteReport(requestPayload, {
onSuccess: () => {
localStorage.removeItem('helloCallId');
navigate(-1);
},
});
};

return (
Expand Down Expand Up @@ -85,15 +106,17 @@ const ReportDetail = () => {
어떤 이야기를 나누었나요?
</Text>
</TitleBox>
<ReportTextArea />
<Textarea
border='none'
height='full'
onChange={(e) => handleContentChange(e)}
/>
</InfoBox>
</Box>
<Divider />
{!submitted ? (
<SubmitButton onClick={handlerSubmit}>보고서 제출하기</SubmitButton>
) : (
<SubmitButton>서비스 완료 확인하기</SubmitButton>
)}
<SubmitButton onClick={() => handlerSubmit(Number(helloCallId))}>
보고서 제출하기
</SubmitButton>
</>
);
};
Expand All @@ -117,11 +140,6 @@ const TitleBox = styled(Box)`
gap: 0.5rem;
`;

const ReportTextArea = styled(Textarea)`
border: none;
height: 100%;
`;

const SubmitButton = styled(Button)`
background-color: var(--color-primary);
color: var(--color-white);
Expand Down
1 change: 0 additions & 1 deletion src/pages/sinitto/hello-call-service/api/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export { useGetServiceDetail } from './useGetServiceDetail';
export { usePutAcceptHelloCall } from './usePutAcceptHelloCall';
export { usePutCancelHelloCall } from './usePutCancelHelloCall';

This file was deleted.

1 change: 1 addition & 0 deletions src/pages/sinitto/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export * from './hello-call-report';
export * from './hello-call-service';
export * from './mypage';
export * from './sinitto-main';
export * from './service-history';
99 changes: 99 additions & 0 deletions src/pages/sinitto/service-history/SinittoServiceHistory.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import { useGetAcceptedCallBackList, useGetApplyHelloCallList } from './api';
import {
CallBackServiceList,
HelloCallServiceList,
TextArea,
} from './components';
import { CALLBACK_SCHEMA, HELLO_CALL_SCHEMA } from './data';
import { Spinner } from '@chakra-ui/react';
import styled from '@emotion/styled';

export const SinittoServiceHistoryPage = () => {
const { data: acceptedCallBackList, isLoading: isAcceptedLoading } =
useGetAcceptedCallBackList();
const { data: applyHelloCallList, isLoading: isApplyHelloLoading } =
useGetApplyHelloCallList();

console.log(applyHelloCallList);
return (
<ServiceHistoryLayout>
<TextArea
title={CALLBACK_SCHEMA.TITLE}
status={CALLBACK_SCHEMA.STATUS}
description={CALLBACK_SCHEMA.DESCRIPTION}
textDirection='start'
/>
{isAcceptedLoading ? (
<StyledSpinnerWrapper>
<Spinner size='lg' thickness='3px' color='blue.500' />
</StyledSpinnerWrapper>
) : acceptedCallBackList ? (
<CallBackServiceList
key={acceptedCallBackList.callbackId}
date={acceptedCallBackList.postTime}
name={acceptedCallBackList.seniorName}
serviceStatus={acceptedCallBackList.status}
callbackId={acceptedCallBackList.callbackId}
/>
) : (
<NoServiceMessage>진행중인 서비스가 없어요! 😥</NoServiceMessage>
)}

<TextArea
title={HELLO_CALL_SCHEMA.TITLE}
status={[
HELLO_CALL_SCHEMA.STATUS_PROCESS,
HELLO_CALL_SCHEMA.STATUS_FINISH,
]}
description={[
HELLO_CALL_SCHEMA.DESCRIPTION_PROCESS,
HELLO_CALL_SCHEMA.DESCRIPTION_FINISH,
]}
textDirection='end'
/>
{isApplyHelloLoading ? (
<StyledSpinnerWrapper>
<Spinner size='lg' thickness='3px' color='blue.500' />
</StyledSpinnerWrapper>
) : applyHelloCallList && applyHelloCallList.length > 0 ? (
applyHelloCallList.map((call) => (
<HelloCallServiceList
key={call.helloCallId}
name={call.seniorName}
serviceStatus={call.status}
helloCallId={call.helloCallId}
days={call.days}
/>
))
) : (
<NoServiceMessage>진행중인 서비스가 없어요! 😥</NoServiceMessage>
)}
</ServiceHistoryLayout>
);
};

const ServiceHistoryLayout = styled.div`
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
padding: 0 2rem;
`;

const StyledSpinnerWrapper = styled.div`
display: flex;
height: 60px;
align-items: center;
justify-content: center;
width: 100%;
margin: 10px 0;
`;

const NoServiceMessage = styled.p`
font-size: 1rem;
font-weight: 700;
color: var(--color-black);
text-align: center;
margin: 20px 0;
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { AcceptedCallBackListResponse } from './types';
import { fetchInstance } from '@/shared';

export const getAcceptedCallBackListPath = '/api/callbacks/sinitto/accepted';

export const getAcceptedCallBackList =
async (): Promise<AcceptedCallBackListResponse> => {
const response = await fetchInstance.get<AcceptedCallBackListResponse>(
getAcceptedCallBackListPath
);
return response.data;
};
12 changes: 12 additions & 0 deletions src/pages/sinitto/service-history/api/apply-hello-call-list.api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ApplyHelloCallListResponse } from './types';
import { fetchInstance } from '@/shared/api/instance';

export const applyHelloCallListPath = () => `/api/hellocalls/own`;

export const getApplyHelloCallList =
async (): Promise<ApplyHelloCallListResponse> => {
const response = await fetchInstance.get<ApplyHelloCallListResponse>(
applyHelloCallListPath()
);
return response.data;
};
3 changes: 3 additions & 0 deletions src/pages/sinitto/service-history/api/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { useGetAcceptedCallBackList } from './useGetAcceptedCallBackList';
export { useGetApplyHelloCallList } from './useGetApplyHelloCallList';
export { usePutCancelHelloCall } from './usePutCancelHelloCall';
Loading