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

QA 수정사항 진행 #145

Merged
merged 12 commits into from
Nov 7, 2024
Merged
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
5 changes: 0 additions & 5 deletions src/pages/assets/guard-main/list.svg

This file was deleted.

35 changes: 35 additions & 0 deletions src/pages/guard/guard-main/GuardMainPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useState } from 'react';
import { GuideLineList } from './components/guideline-list';
import { Header } from './components/header/Header';
import { HelloCallApply } from './components/hello-call-apply';
import { Box, Text } from '@chakra-ui/react';
import styled from '@emotion/styled';

export const GuardMainPage = () => {
Expand All @@ -14,6 +15,25 @@ export const GuardMainPage = () => {
currentSenior={currentSenior}
setCurrentSenior={setCurrentSenior}
/>
<CallbackNumber>
<Box
w='100%'
display='flex'
justifyContent='center'
padding='0.5rem'
fontSize='20px'
bg='var(--color-secondary)'
color='var(--color-black)'
fontWeight='bold'
borderRadius='20px'
marginBottom='10px'
>
시니어가 사용할 서비스 번호
</Box>
<Text fontSize='24px' fontWeight='bold'>
010-4163-8098
</Text>
</CallbackNumber>
<GuideLineList seniorId={currentSenior} />
<HelloCallApply />
</GuardMainPageLayout>
Expand All @@ -27,3 +47,18 @@ const GuardMainPageLayout = styled.div`
width: 100%;
padding: 0 2rem;
`;

const CallbackNumber = styled.div`
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
border-radius: 20px;
max-width: 338px;
padding: 0.5rem;
background-color: var(--color-primary);
color: white;
font-weight: bold;
margin-top: 1rem;
`;
4 changes: 1 addition & 3 deletions src/pages/guard/guard-main/components/header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { ChangeEvent, Dispatch, SetStateAction } from 'react';
import { Link } from 'react-router-dom';

import { RouterPath } from '@/app/routes';
import IconList from '@/pages/assets/guard-main/list.svg';
import IconUser from '@/pages/assets/shared/user.svg';
import { HEADER_HEIGHT, useAllSeniorInfo } from '@/shared';
import { Flex, Image, Select } from '@chakra-ui/react';
Expand All @@ -22,7 +21,6 @@ export const Header = ({ currentSenior, setCurrentSenior }: HeaderProps) => {

return (
<Wrapper>
<Image src={IconList} alt='icon-list' />
<Flex gap={3} alignItems='center'>
<Select
placeholder='부모님'
Expand Down Expand Up @@ -55,7 +53,7 @@ const Wrapper = styled.header`
height: ${HEADER_HEIGHT};
display: flex;
align-items: center;
justify-content: flex-end;
padding: 1.5rem 0;
justify-content: space-between;
background-color: var(--color-white);
`;
17 changes: 2 additions & 15 deletions src/pages/guard/guide-line/api/hooks/useGuidelineInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,19 @@ type GuidelineInfo = {
content: string;
};

type UseGuidelineInfoProps = {
type Props = {
guideline: GuidelineInfo;
seniorId: number;
editMutation: UseMutationResult<string, Error, ModifyGuidelineRequest>;
deleteMutation: UseMutationResult<string, Error, number>;
};

type UseGuidelineInfoReturn = {
isMore: boolean;
isEditing: boolean;
guidelineTitle: string;
guidelineContent: string;
toggleContent: () => void;
setIsEditing: (value: boolean) => void;
setGuidelineTitle: (value: string) => void;
setGuidelineContent: (value: string) => void;
editGuideline: () => void;
deleteGuideline: () => void;
};

export const useGuidelineInfo = ({
guideline,
seniorId,
editMutation,
deleteMutation,
}: UseGuidelineInfoProps): UseGuidelineInfoReturn => {
}: Props) => {
const [isMore, setIsMore] = useState(false);
const [isEditing, setIsEditing] = useState(false);
const [guidelineTitle, setGuidelineTitle] = useState(guideline.title);
Expand Down
5 changes: 3 additions & 2 deletions src/pages/guard/mypage/GuardMyPage.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { GuardProfileBox } from './components';
import { PointBox, PointLogBox } from '@/shared/components';
import { PointBox, PointLogBox, Withdrawal } from '@/shared/components';
import { Flex } from '@chakra-ui/react';
import styled from '@emotion/styled';

export const GuardMyPage = () => {
return (
<MyPageLayout>
<GuardProfileBox />
<PointBox />
<PointBox isSinitto={false} />
<PointLogBox />
<Withdrawal />
</MyPageLayout>
);
};
Expand Down
1 change: 0 additions & 1 deletion src/pages/guard/service-history/api/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export { useGetHelloHistoryList } from './useGetHelloHistoryList';
export { useDeleteHelloCall } from './useDeleteHelloCall';
export { useModifyHelloCall } from './useModifyHelloCall';
export { useGetCallbackHistory } from './useGetCallbackHistory';
export { useCompleteCallback } from './useCompleteCallback';
export { useHelloServiceHistory } from './useHelloServiceHistory';
Original file line number Diff line number Diff line change
@@ -1,52 +1,23 @@
import { useState } from 'react';

import {
HelloCallHistory,
ModifyHelloCallRequest,
useDeleteHelloCall,
useModifyHelloCall,
} from '@/pages/guard';
import {
ServiceDetailResponse,
useGetServiceDetail,
} from '@/pages/sinitto/hello-call-service/api';
import { HelloCallHistory, useDeleteHelloCall } from '@/pages/guard';
import { useGetServiceDetail } from '@/pages/sinitto/hello-call-service/api';

type UseHelloServiceHistoryProps = {
type Props = {
historyData: HelloCallHistory;
refetch: () => void;
};

type UseHelloServiceHistoryReturn = {
isEditMode: boolean;
selectedDays: string[];
helloCallDetail?: ServiceDetailResponse;
isDaySelected: (day: string) => boolean;
deleteHelloCall: () => void;
toggleDay: (day: string) => void;
handleEditStart: () => void;
handleEditCancel: () => void;
editHelloCall: () => void;
};

export const useHelloServiceHistory = ({
historyData,
refetch,
}: UseHelloServiceHistoryProps): UseHelloServiceHistoryReturn => {
const [isEditMode, setIsEditMode] = useState(false);
export const useHelloServiceHistory = ({ historyData, refetch }: Props) => {
const [selectedDays, setSelectedDays] = useState<string[]>(historyData.days);
const { days } = historyData;

const { data: helloCallDetail } = useGetServiceDetail(
historyData.helloCallId
);
const deleteHelloCallMutation = useDeleteHelloCall(refetch);
const editHelloCallMutation = useModifyHelloCall(
historyData.helloCallId,
refetch
);

const isDaySelected = (day: string): boolean =>
isEditMode ? selectedDays.includes(day) : days.includes(day);
const isDaySelected = (day: string): boolean => days.includes(day);

const deleteHelloCall = () => {
const isConfirmed = window.confirm(
Expand All @@ -58,63 +29,16 @@ export const useHelloServiceHistory = ({
};

const toggleDay = (day: string) => {
if (!isEditMode) return;

setSelectedDays((prev) =>
prev.includes(day) ? prev.filter((d) => d !== day) : [...prev, day]
);
};

const handleEditStart = () => {
setIsEditMode(true);
setSelectedDays(days);
};

const handleEditCancel = () => {
setIsEditMode(false);
setSelectedDays(days);
};

const editHelloCall = () => {
if (
!helloCallDetail ||
!helloCallDetail.timeSlots ||
helloCallDetail.timeSlots.length === 0
) {
alert('기존 시간 정보를 불러올 수 없습니다.');
return;
}

const baseTimeSlot = helloCallDetail.timeSlots[0];
const requestData: ModifyHelloCallRequest = {
startDate: helloCallDetail.startDate,
endDate: helloCallDetail.endDate,
timeSlots: selectedDays.map((day) => ({
dayName: day,
startTime: String(baseTimeSlot.startTime),
endTime: String(baseTimeSlot.endTime),
})),
price: helloCallDetail.price,
serviceTime: helloCallDetail.serviceTime,
requirement: helloCallDetail.requirement,
};

editHelloCallMutation.mutate(requestData, {
onSuccess: () => {
setIsEditMode(false);
},
});
};

return {
isEditMode,
selectedDays,
helloCallDetail,
isDaySelected,
deleteHelloCall,
toggleDay,
handleEditStart,
handleEditCancel,
editHelloCall,
};
};
22 changes: 0 additions & 22 deletions src/pages/guard/service-history/api/hooks/useModifyHelloCall.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/pages/guard/service-history/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export * from './get-hello-history.api';
export * from './delete-hello-call.api';
export * from './modify-hello-call.api';
export * from './get-callback-history.api';
export * from './make-callback-completed.api';
export * from './hooks';
28 changes: 0 additions & 28 deletions src/pages/guard/service-history/api/modify-hello-call.api.ts

This file was deleted.

Loading