Skip to content

Commit

Permalink
feat: 1:1문의 답변기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
eun-hak committed Jun 9, 2024
1 parent e19c5cf commit e788bd2
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 12 deletions.
4 changes: 4 additions & 0 deletions src/api/types/question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ interface QuestionGet {
content: string;
branchName: string;
createdDate: string;
answer: {
privatePostAnswerId: number;
content: string;
};
}

interface QuestionGetResponse {
Expand Down
15 changes: 14 additions & 1 deletion src/components/modal/logoutModal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// components/LogoutModal.tsx
import { useSetMember } from '@/store/user';
import React from 'react';

interface LogoutModalProps {
Expand All @@ -7,6 +8,7 @@ interface LogoutModalProps {
}

const LogoutModal = ({ onConfirm, onCancel }: LogoutModalProps) => {
const setmember = useSetMember();
return (
<div
className="fixed inset-0 flex items-center justify-center bg-black bg-opacity-50 z-[9999]"
Expand All @@ -21,7 +23,18 @@ const LogoutModal = ({ onConfirm, onCancel }: LogoutModalProps) => {
<div className="flex justify-between">
<button
className="h-[42px] flex-1 text-center font-bold text-indigo-700 leading-normal text-lg font-['Pretendard']"
onClick={onConfirm}>
onClick={() => {
onConfirm();
setmember({
memberEmail: '',
memberName: '',
memberNickName: '',
memberJob: '',
memberSmsAgree: '',
memberPhone: '',
companyName: ''
});
}}>
확인
</button>
<div className="w-[1px] h-full bg-gray-300"></div>
Expand Down
18 changes: 17 additions & 1 deletion src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import MainContainer from '@/components/shared/MainContainer';
import { useMember, useSetMember } from '@/store/user';
import React, { useEffect } from 'react';
import { useQuery } from 'react-query';

import { fcmpost } from '@/api/fcm/fcm.post.api';
import { getTokenHandler } from '@/components/pwa/Fcm';
const Index = () => {
/* eslint-disable */
const member = useMember();
Expand All @@ -16,6 +17,21 @@ const Index = () => {
setmember(memberData?.data);
}, [memberData, setmember]);

useEffect(() => {
const fetchToken = async () => {
try {
const token = await getTokenHandler();
if (typeof token === 'string') {
fcmpost({ fcmToken: token });
}
} catch (error) {
console.error('Failed to get FCM token:', error);
}
};

fetchToken();
}, []);

return (
<MainContainer>
<MainPageIndex />
Expand Down
24 changes: 15 additions & 9 deletions src/pages/mypage/question/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,15 @@ const InquiryHistory = () => {

{inquiriesData?.map(
(
data: { title: string; content: string; createdDate: string },
data: {
title: string;
content: string;
createdDate: string;
answer: { content: string };
},
index: number
) => {
const openAnswer = inquiriesData.length - index;
// const openAnswer = inquiriesData.length - index;
return (
<div
key={index}
Expand Down Expand Up @@ -152,15 +157,16 @@ const InquiryHistory = () => {
</div>
</div>
</div>

<div className="flex flex-row justify-between">
<div className="w-auto h-auto min-h-[45px] max-w-[250px] pl-5 pr-4 py-3 bg-violet-50 rounded-tl-[10px] rounded-tr-[10px] rounded-bl-[10px] justify-center items-center gap-2 inline-flex">
<div className="text-right text-neutral-700 text-sm font-normal font-['Pretendard'] leading-[21px] tracking-tight">
{openAnswer}
{data.answer && (
<div className="flex flex-row justify-between">
<div className="w-auto h-auto min-h-[45px] max-w-[250px] pl-5 pr-4 py-3 bg-violet-50 rounded-tl-[10px] rounded-tr-[10px] rounded-bl-[10px] justify-center items-center gap-2 inline-flex">
<div className="text-right text-neutral-700 text-sm font-normal font-['Pretendard'] leading-[21px] tracking-tight">
{data.answer.content}
</div>
<div className="w-auto" />
</div>
<div className="w-auto" />
</div>
</div>
)}
</div>
)}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/sign/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import SignUpButton from '@/components/shared/sign/SignUpButton';

import Link from 'next/link';
// import useSendPush from '@/components/pwa/UseSendPush';
import { getTokenHandler } from '@/components/pwa/Fcm';
import { useEffect, useState } from 'react';
import { useRouter } from 'next/navigation';
import { getCookie } from '@/utils/cookies';
import { getTokenHandler } from '@/components/pwa/Fcm';

const SignHomePage = () => {
const token = getCookie('token');
Expand Down

0 comments on commit e788bd2

Please sign in to comment.