Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/4bujak-4bujak/frontend i…
Browse files Browse the repository at this point in the history
…nto feature/meetingroomQA
  • Loading branch information
jiohjung98 committed Jun 10, 2024
2 parents 0f99108 + fdfb3f8 commit e7bc8c2
Show file tree
Hide file tree
Showing 50 changed files with 1,262 additions and 338 deletions.
18 changes: 15 additions & 3 deletions public/firebase-messaging-sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ self.addEventListener('push', function (event) {
image: data.image,
data: {
click_action: data.click_action,
targetUrl: url.targetUrl
targetUrl: url.targetUrl,
targetId: url.targetId,
targetType: url.targetType
}
};

Expand All @@ -36,14 +38,18 @@ self.addEventListener('push', function (event) {
});

// 알림을 클릭하면 사이트로 이동한다.
self.addEventListener('notificationclick', function (event) {
self.addEventListener('notificationclick', async function (event) {
event.preventDefault();
// 알림창 닫기
event.notification.close();

// 이동할 url
const urlToOpen = event.notification.data.targetUrl;
// const targetId = event.notification.data.targetId;
console.log(urlToOpen);
console.log(event.notification);
const Type = event.notification.data.targetType;
console.log('asdfasf', Type);
// 클라이언트에 해당 사이트가 열려 있는지 체크
const promiseChain = clients
.matchAll({
Expand All @@ -64,7 +70,13 @@ self.addEventListener('notificationclick', function (event) {
if (matchingClient) {
return matchingClient.focus();
} else {
return clients.openWindow(urlToOpen);
if (Type === 'RESERVATION') {
return clients.openWindow(
`reservation/myreservationlist?targetId=${event.notification.data.targetId}`
);
} else {
return clients.openWindow(`community/${event.notification.data.targetId}`);
}
}
});

Expand Down
3 changes: 3 additions & 0 deletions public/home/triangle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions public/reservation/rechargingError.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 30 additions & 2 deletions src/api/auth/auth.post.api.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
// import { ICommon } from '../types/common';
import { postRequest } from '../request';
import { patchRequest, postRequest } from '../request';
import {
ISignIn,
ISignUp,
IEmail,
IEmailAuth,
IPhoneNumber,
IPhoneAuth,
UserLoginType
UserLoginType,
IPasswordVerifyChange
} from '../types/auth';
import { ICommon } from '../types/common';

Expand Down Expand Up @@ -54,6 +55,16 @@ export const emailauthrequest = async ({ emailAddress }: IEmail) => {
return response;
};

/* 비밀번호 찾기 코드 요청 */

export const emailauthpasswordrequest = async ({ emailAddress }: IEmail) => {
const response = await postRequest<ICommon<null>, IEmail>(`auth/password`, {
emailAddress
});

return response;
};

/* 이메일 코드 검증 */

export const emailauthverify = async ({ emailAddress, code }: IEmailAuth) => {
Expand All @@ -65,6 +76,23 @@ export const emailauthverify = async ({ emailAddress, code }: IEmailAuth) => {
return response;
};

/* 비밀번호 변경 patch */

export const passwordchangerequest = async ({
email,
password
}: IPasswordVerifyChange) => {
const response = await patchRequest<ICommon<null>, IPasswordVerifyChange>(
`auth/password`,
{
email,
password
}
);

return response;
};

/* 휴대전화 번호 인증 요청*/

export const phoneauthrequest = async ({ phoneNumber }: IPhoneNumber) => {
Expand Down
24 changes: 20 additions & 4 deletions src/api/question/question.api.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
/* 일대일 문의 전체 조회 */

import { getRequest } from '../request';
import { QuestionType } from '../types/question';
import { getRequest, postRequest } from '../request';
import {
PostQuestionTypeResponse,
QuestionPost,
GetQuestionType
} from '../types/question';

export const userinfo = async () => {
const response = await getRequest<QuestionType>('privatePosts');
export const questioninfo = async () => {
const response = await getRequest<GetQuestionType>(
`privatePosts?page=1&size=100&sort=string`
);
return response;
};

/* 일대일 문의 등록 */

export const registerquestion = async ({ title, content, branchName }: QuestionPost) => {
const response = await postRequest<PostQuestionTypeResponse, QuestionPost>(
'privatePosts',
{ title, content, branchName }
);
return response;
};
8 changes: 8 additions & 0 deletions src/api/types/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ export interface IWithdraw {
export interface IEmail {
emailAddress: string;
}

export interface IEmailChange {
email: string;
}

export interface IPasswordVerifyChange extends IEmailChange {
password: string;
}
export interface IEmailAuth extends IEmail {
code: string;
}
Expand Down
1 change: 1 addition & 0 deletions src/api/types/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface NotificationType {
content: string;
targetUrl: string;
date: string;
targetId: string;
}

interface NotificationListType {
Expand Down
24 changes: 18 additions & 6 deletions src/api/types/question.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
// import { Branch } from './branch';
import { ICommon } from './common';
export interface QuestionPost {
title: string;
content: string;
branchName: string | undefined;
}

interface QuestionPost {
interface QuestionGet {
id: number;
title: string;
content: string;
branchName: string;
createdDate: string;
answer: {
privatePostAnswerId: number;
content: string;
};
}

interface QuestionPosttResponse {
privatePostList: QuestionPost[];
interface QuestionGetResponse {
privatePostList: QuestionGet[];
hasNext: boolean;
}

interface Message {
message: string;
interface QuestionMessage {
id: number;
}

export type QuestionType = ICommon<QuestionPosttResponse & Message>;
export type GetQuestionType = ICommon<QuestionGetResponse>;

export type PostQuestionTypeResponse = ICommon<QuestionMessage>;
55 changes: 47 additions & 8 deletions src/components/home/AvailableRoom.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
'use client';
import { useBranchStore } from '@/store/branch.store';
import { format } from 'date-fns';
import React, { useEffect, useState } from 'react';
import { useQuery, useQueryClient } from 'react-query';
import { getAllAvailableCount } from './remote/mainReservation';
import { useRouter } from 'next/router';

const AvailableRoom = () => {
const router = useRouter();
const queryClient = useQueryClient();
const [currentTime, setCurrentTime] = useState(format(new Date(), 'HH:mm'));
const selectedBranch = useBranchStore((state) => state.selectedBranch);

const { data } = useQuery(
['AllAvailableCount', selectedBranch?.branchId],
() => getAllAvailableCount(selectedBranch?.branchId as number),
{
enabled: !!selectedBranch?.branchId
}
);

useEffect(() => {
const handleVisibilityChange = () => {
Expand All @@ -17,6 +32,10 @@ const AvailableRoom = () => {
};
}, []);

if (!data) {
return null;
}

return (
<div className="pb-10">
{/* 상단 */}
Expand All @@ -26,7 +45,13 @@ const AvailableRoom = () => {
<div>{currentTime} 기준</div>
<div
className="cursor-pointer"
onClick={() => setCurrentTime(format(new Date(), 'HH:mm'))}>
onClick={() => {
queryClient.invalidateQueries([
'AllAvailableCount',
selectedBranch?.branchId
]);
setCurrentTime(format(new Date(), 'HH:mm'));
}}>
<img src="/home/refresh.svg" alt="" />
</div>
</div>
Expand All @@ -41,12 +66,16 @@ const AvailableRoom = () => {
<div className="text-gray-600 text-sm font-normal ">미팅룸</div>
<div className="flex justify-center items-center gap-1">
<div>
<span className="text-space-purple text-[26px] font-medium">1</span>
<span className="text-space-purple text-[26px] font-medium">
{data?.availableMeetingRoomCount}
</span>
</div>
<div>
<img src="/home/slash.svg" alt="" />
</div>
<div className="text-gray-400 font-medium text-base">30</div>
<div className="text-gray-400 font-medium text-base">
{data?.totalMeetingRoomCount}
</div>
</div>
</div>

Expand All @@ -57,12 +86,16 @@ const AvailableRoom = () => {
<div className="text-gray-600 text-sm font-normal ">리차징룸</div>
<div className="flex justify-center items-center gap-1">
<div>
<span className="text-space-purple text-[26px] font-medium">1</span>
<span className="text-space-purple text-[26px] font-medium">
{data?.availableRechargingRoomCount}
</span>
</div>
<div>
<img src="/home/slash.svg" alt="" />
</div>
<div className="text-gray-400 font-medium text-base">30</div>
<div className="text-gray-400 font-medium text-base">
{data?.totalRechargingRoomCount}
</div>
</div>
</div>

Expand All @@ -73,18 +106,24 @@ const AvailableRoom = () => {
<div className="text-gray-600 text-sm font-normal ">포커스존</div>
<div className="flex justify-center items-center gap-1">
<div>
<span className="text-space-purple text-[26px] font-medium">1</span>
<span className="text-space-purple text-[26px] font-medium">
{data?.availableFocusDeskCount}
</span>
</div>
<div>
<img src="/home/slash.svg" alt="" />
</div>
<div className="text-gray-400 font-medium text-base">30</div>
<div className="text-gray-400 font-medium text-base">
{data?.totalFocusDeskCount}
</div>
</div>
</div>
</div>

{/* 하단 */}
<div className="cursor-pointer mt-8 rounded-lg w-full h-12 border-2 border-space-purple flex justify-center items-center text-space-purple text-[15px] font-semibold">
<div
onClick={() => router.push('reservation')}
className="cursor-pointer mt-8 rounded-lg w-full h-12 border-2 border-space-purple flex justify-center items-center text-space-purple text-[15px] font-semibold">
예약하기
</div>
</div>
Expand Down
30 changes: 23 additions & 7 deletions src/components/home/CurrentOffice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@ import SearchModal from './SearchModal';
import SelectOfficeMap from './SelectOfficeMap';
import { Branch } from '@/api/types/branch';
import { useBranchStore } from '@/store/branch.store';
import { useIsCurrentBranch } from '@/store/isCurrentBranch.store';

const CurrentOffice = () => {
const [showSearchModal, setShowSearchModal] = useState(false);
const [showSelectOfficeMap, setShowSelectOfficeMap] = useState(false);
const selectedBranch = useBranchStore((state) => state.selectedBranch);
const setSelectedBranch = useBranchStore((state) => state.setSelectedBranch);
const [isHydrated, setIsHydrated] = useState(false);
const { isCurrent } = useIsCurrentBranch();

const initialBranch: Branch = {
branchId: 27,
branchName: '강남1호점',
branchAddress: '서울 강남구 강남대로 382 메리츠타워 17, 18층 (메인라운지 17층)',
branchLatitude: 37.4971261,
branchLongitude: 127.0287132,
branchLongitude: 127.0287132
};

useEffect(() => {
Expand All @@ -28,10 +30,6 @@ const CurrentOffice = () => {
}
}, [selectedBranch, setSelectedBranch]);

useEffect(() => {
console.log('Current selectedBranch:', selectedBranch);
}, [selectedBranch]);

const handleBranchSelect = (branch: Branch) => {
setSelectedBranch(branch, Date.now());
setShowSearchModal(false);
Expand All @@ -58,12 +56,30 @@ const CurrentOffice = () => {
<div>
<img src="/home/location.svg" alt="" />
</div>
<div className="text-white text-lg underline font-medium cursor-pointer" onClick={handleSearchClick}>
<div
className="text-white text-lg underline font-medium cursor-pointer"
onClick={handleSearchClick}>
{selectedBranch?.branchName}
</div>
</div>

{!isCurrent ? (
<div className="absolute z-50 top-6 right-20">
<div className="ml-[22px] opacity-95 ">
<img src="/home/triangle.svg" alt="" />
</div>
<div className="border-t border-space-purple-dark-active p-2 opacity-95 bg-space-purple-dark-active rounded text-white text-sm font-normal">
이 지점이 맞나요?
</div>
</div>
) : null}
</div>
{showSearchModal && <SearchModal onClose={() => setShowSearchModal(false)} onBranchSelect={handleBranchSelect} />}
{showSearchModal && (
<SearchModal
onClose={() => setShowSearchModal(false)}
onBranchSelect={handleBranchSelect}
/>
)}
{showSelectOfficeMap && selectedBranch && (
<SelectOfficeMap branch={selectedBranch} onClose={handleCloseSelectOfficeMap} />
)}
Expand Down
Loading

0 comments on commit e7bc8c2

Please sign in to comment.