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

제휴문의시 페이지 생성 #23

Merged
merged 3 commits into from
Jun 20, 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
37 changes: 18 additions & 19 deletions src/api/alliance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,26 @@ const allianceApi = () => {
const formatedPlatforms = reservationPlatform.join(',');

try {
await requestApi
.post(`pre-registration-survey`, {
name: contactInfo.name,
email: contactInfo.email,
phoneNumber: contactInfo.phone,
businessName: contactInfo.store,
region: region,
reservationPlatform: formatedPlatforms,
snsContact: contactInfo.snsLink,
phoneInterview: shouldInterview,
})
.then((res) => {
if (res.status >= 400) throw Error(res.statusText);
alert('등록이 완료되었습니다.');
})
.catch((e) => {
alert('등록이 실패하였습니다. 작성하신 정보를 확인해주세요.');
throw Error(e);
});
const res = await requestApi.post(`pre-registration-survey`, {
name: contactInfo.name,
email: contactInfo.email,
phoneNumber: contactInfo.phone,
businessName: contactInfo.store,
region: region,
reservationPlatform: formatedPlatforms,
snsContact: contactInfo.snsLink,
phoneInterview: shouldInterview,
});

if (res.status >= 400) {
throw new Error(res.statusText);
}

return res; // 성공 시 응답 반환
} catch (e) {
console.log(e);
alert('등록이 실패하였습니다. 작성하신 정보를 확인해주세요.');
throw e;
}
};

Expand Down
35 changes: 22 additions & 13 deletions src/components/Alliance/AllianceContact/AllianceContact.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@ const { applyContactInfo } = allianceApi();

type AllianceContactProps = {
shouldScrollToContact: boolean;
setIsSuccessSurvey: React.Dispatch<boolean>;
VictoryJu marked this conversation as resolved.
Show resolved Hide resolved
};

const AllianceContact = ({ shouldScrollToContact }: AllianceContactProps) => {
const AllianceContact = ({ shouldScrollToContact, setIsSuccessSurvey }: AllianceContactProps) => {
const [contactInfo, setContactInfo] = useState<ContactInfoType>({
name: '',
email: '',
phone: '',
store: '',
snsLink: '',
});

const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const { name, value } = e.target;
setContactInfo((prevContactInfo) => ({
Expand Down Expand Up @@ -50,25 +51,33 @@ const AllianceContact = ({ shouldScrollToContact }: AllianceContactProps) => {
selectedPlatformList.length > 0 &&
region.length > 0;

const handleBenefitButton = () => {
const handleBenefitButton = async () => {
VictoryJu marked this conversation as resolved.
Show resolved Hide resolved
if (!validatedBenefitButton) return;
applyContactInfo({
contactInfo,
region: region,
reservationPlatform: selectedPlatformList,
shouldInterview: selectedInterview,
});
try {
const res = await applyContactInfo({
contactInfo,
region: region,
reservationPlatform: selectedPlatformList,
shouldInterview: selectedInterview,
});
if(res.status >= 201 && res.status < 300) {
setIsSuccessSurvey(true);
}

} catch (error) {
console.log(error);
}
};

const allianceContactWrapperRef = useRef<HTMLDivElement>(null);

useEffect(() => {
if (!allianceContactWrapperRef || !allianceContactWrapperRef.current) return;

if (shouldScrollToContact) {
if (shouldScrollToContact && allianceContactWrapperRef.current) {
allianceContactWrapperRef.current.scrollIntoView({ behavior: 'smooth' });
// 상태 초기화 (선택 사항)
window.history.replaceState({}, document.title);
}
}, [allianceContactWrapperRef]);
}, [shouldScrollToContact]);

return (
<section ref={allianceContactWrapperRef} className={styles.AllianceContactWrapper}>
Expand Down
36 changes: 36 additions & 0 deletions src/components/Alliance/SuccessSurvey/SuccessSurvey.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@import '/src/styles/responsive.scss';

.SuccessSurveyWrapper {
background-color: #fefdee;
padding: 80px 215px 114px 176px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: 30px;
@include media(phone, tablet) {
padding: 20px;
}
}

.SuccessSurveyTitle {
color: var(--Gray-Gray-bk, #000);
text-align: center;
font-size: 36px;
font-weight: 700;
line-height: 48px; /* 133.333% */
}

.SuccessSurveyDescription {
color: var(--Gray-Gray-bk, #000);
text-align: center;
font-size: 18px;
font-style: normal;
font-weight: 400;
line-height: 24px; /* 133.333% */
}

.SuccessImage {
width: 369px;
height: 341px;
}
22 changes: 22 additions & 0 deletions src/components/Alliance/SuccessSurvey/SuccessSurvey.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';
import * as styles from './SuccessSurvey.module.scss';
import { StaticImage } from 'gatsby-plugin-image';
const SuccessSurvey = () => {
return (
<section className={styles.SuccessSurveyWrapper}>
VictoryJu marked this conversation as resolved.
Show resolved Hide resolved
<div className={styles.SuccessSurveyTitle}>제출완료</div>
<div className={styles.SuccessSurveyDescription}>
몽글에 등록해주셔서 감사합니다.
<br />
기다려주시면 빠르게 회신드리겠습니다.
</div>
<StaticImage
src="../../../images/lending/lending_apply_image.png"
alt="LendingApplyImage"
className={styles.SuccessImage}
/>
</section>
);
}

export default SuccessSurvey;
4 changes: 1 addition & 3 deletions src/components/Layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ const Layout = ({ children }: LayoutProps) => {
<Nav />
{children}
<Footer />
{typeof window !== 'undefined' && window.location.pathname === '/' && (
<ApplyLink className={styles.LayoutMobileApplyLink} />
)}
<ApplyLink className={styles.LayoutMobileApplyLink} />
</div>
);
};
Expand Down
5 changes: 2 additions & 3 deletions src/components/Layout/Nav/Nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ const Nav = () => {
</li>
</div>
<li>
{typeof window !== 'undefined' && window.location.pathname === '/' && (
<ApplyLink className={styles.BenefitButton} />
)}

<ApplyLink className={styles.BenefitButton} />
</li>
</ul>
</div>
Expand Down
4 changes: 1 addition & 3 deletions src/components/Lending/LendingApply/LedingApply.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ const LedingApply = () => {
<div>반려견의 건강과 미용 서비스를 한 곳에서 모아보고</div>
<div>효율적으로 관리하세요.</div>
</div>
{typeof window !== 'undefined' && window.location.pathname === '/' && (
<ApplyLink className={styles.LendingApplyButton} />
)}
<ApplyLink className={styles.LendingApplyButton} />
<div className={styles.LendingApplyPcImageWrapper} data-aos="fade-left">
<StaticImage
src="../../../images/lending/lending_apply_image.png"
Expand Down
46 changes: 41 additions & 5 deletions src/pages/alliance/index.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,60 @@
import React, { useState } from 'react';
import React, { useState, useEffect, useRef } from 'react';
import { HeadFC, PageProps } from 'gatsby';
import LedingApply from '@components/Lending/LendingApply/LedingApply';
import AllianceBenefit from '@components/Alliance/AllianceBenefit/AllianceBenefit';
import AllianceMain from '@components/Alliance/AllianceMain/AllianceMain';
import AllianceContact from '@components/Alliance/AllianceContact/AllianceContact';
import Layout from '@components/Layout/Layout';
import SuccessSurvey from '@src/components/Alliance/SuccessSurvey/SuccessSurvey';

type CustomLocationType = {
shouldScrollToContact: boolean;
};

const IndexPage: React.FC<PageProps> = ({ location }) => {
const state = location.state as CustomLocationType;
const [isSuccessSurvey, setIsSuccessSurvey] = useState(false);
const allianceContactRef = useRef<HTMLDivElement>(null);

useEffect(() => {
const disableScroll = (e: Event) => e.preventDefault();

if (state?.shouldScrollToContact && allianceContactRef.current) {
document.addEventListener('wheel', disableScroll, { passive: false });
document.addEventListener('touchmove', disableScroll, { passive: false });

allianceContactRef.current.scrollIntoView({ behavior: 'smooth' });

// 스크롤이 완료된 후 스크롤 이벤트 활성화
setTimeout(() => {
document.removeEventListener('wheel', disableScroll);
document.removeEventListener('touchmove', disableScroll);
VictoryJu marked this conversation as resolved.
Show resolved Hide resolved
}, 1000); // 1초 후 스크롤 이벤트 활성화
}

return () => {
document.removeEventListener('wheel', disableScroll);
document.removeEventListener('touchmove', disableScroll);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setTimeout부분에서 remove를 해주고있어서 요부분은 나중에 없애시는거스로~

};
}, [state]);

return (
<Layout>
<LedingApply />
<AllianceMain />
<AllianceBenefit />
<AllianceContact shouldScrollToContact={state?.shouldScrollToContact} />
{isSuccessSurvey ? (
<SuccessSurvey />
) : (
<>
<LedingApply />
<AllianceMain />
<AllianceBenefit />
<div ref={allianceContactRef}>
<AllianceContact
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오잉? 여기에 ref를 넣으면 하단까지 scrollIntoView가 되나요?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

찾아보면서 지피티 시키니까 작동은 잘 되긴합니다 신기하져?

shouldScrollToContact={state?.shouldScrollToContact}
setIsSuccessSurvey={setIsSuccessSurvey}
/>
</div>
</>
)}
</Layout>
);
};
Expand Down
12 changes: 12 additions & 0 deletions src/styles/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,15 @@ li {
a {
text-decoration: none;
}

/* Chrome, Safari, Edge, Opera */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}

/* Firefox */
input[type='number'] {
-moz-appearance: textfield;
}
Loading