All files / lib/pages/Signup index.tsx

0% Statements 0/26
0% Branches 0/12
0% Functions 0/3
0% Lines 0/26

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
'use client';
 
import { SubmitHandler, useForm } from 'react-hook-form';
import { styled } from 'styled-components';
import axios from 'axios';
import BottomImage from '@lib/assets/images/banner_design_image.png';
import TopImage from '@lib/assets/images/mini_design_image.png';
import DefaultLayout from '../DefaultLayout';
 
interface FormInputs {
  name: string;
  phone: string;
  gender: string;
  ageRange: string;
  livingPlace: string;
  funnel: string;
  isAgree: boolean;
}
 
export default function SignupPage() {
  const {
    register,
    handleSubmit,
    formState: { errors }
  } = useForm<FormInputs>();
 
  const onSubmit: SubmitHandler<FormInputs> = async (values) => {
    try {
      const { name, phone, gender, ageRange, livingPlace, funnel } = values;
 
      const { data } = await axios.post('/api/festival/submit', {
        name,
        phone,
        gender,
        age: ageRange,
        livingPlace,
        referral: funnel
      });
 
      console.log(data);
 
      alert('접수가 완료되었습니다.');
    } catch (e) {
      console.error(e);
    }
  };
 
  return (
    <DefaultLayout>
      <InfoContainer>
        <TopImageContainer>
          <TopImageItem src={TopImage.src} alt="이미지" />
        </TopImageContainer>
        <Header>사전 예약 신청 안내</Header>
        <StyledUl>
          <li>
            사전예약자 한 명당 한 개의 입장권이 준비되므로, 1인당 1개의 사전예약을 해주셔야 합니다.
          </li>
          <li>
            본 행사는 안전상의 이유로 미취학아동은 참여할 수 없으며, 8세 이상(2015년생 이상)부터
            보호자 동반하여 입장이 가능합니다.
          </li>
          <li>일행 및 아동 동반시에도 반드시 개별적으로 신청해 주시길 바랍니다.</li>
          <li>현장 접수는 500명 한정으로, 조기 마감될 수 있습니다.</li>
        </StyledUl>
      </InfoContainer>
      <FormContainer>
        <Header>신청 양식</Header>
        <Form onSubmit={handleSubmit(onSubmit)}>
          <Label>
            <LabelText required>이름</LabelText>
            <Input
              {...register('name', { required: true })}
              type="text"
              placeholder="이름을 입력해주세요."
            />
          </Label>
          {errors.name && <ErrorText>이름을 입력해주세요.</ErrorText>}
 
          <Label>
            <LabelText required>
              행사 안내 수신 연락처 (*연락처가 없다면 동행인 또는 보호자의 연락처를 기재해 주세요.)
            </LabelText>
            <Input {...register('phone', { required: true })} type="number" />
          </Label>
          {errors.phone && <ErrorText>연락처를 입력해주세요.</ErrorText>}
 
          <Label>
            <LabelText required>성별</LabelText>
            <Select {...register('gender', { required: true })}>
              <option disabled selected value="" style={{ color: '#777 !important' }}>
                성별을 선택해주세요.
              </option>
              <option>여성</option>
              <option>남성</option>
            </Select>
          </Label>
          {errors.gender && <ErrorText>성별을 입력해주세요.</ErrorText>}
 
          <Label>
            <LabelText required>연령대</LabelText>
            <Select {...register('ageRange', { required: true })}>
              <option disabled selected value="">
                연령대를 선택해주세요.
              </option>
              <option>10대</option>
              <option>20대</option>
              <option>30대</option>
              <option>40대</option>
              <option>50대 이상</option>
            </Select>
          </Label>
 
          {errors.ageRange && <ErrorText>연령대를 선택해주세요.</ErrorText>}
 
          <Label>
            <div>거주 지역</div>
            <Select {...register('livingPlace')}>
              <option disabled selected value="">
                거주 지역을 선택해주세요.
              </option>
              <option>강원특별자치도</option>
              <option>경기도</option>
              <option>경상남도</option>
              <option>경상북도</option>
              <option>광주광역시</option>
              <option>대구광역시</option>
              <option>대전광역시</option>
              <option>부산광역시</option>
              <option>서울특별시</option>
              <option>세종특별자치시</option>
              <option>울산광역시</option>
              <option>인천광역시</option>
              <option>전라남도</option>
              <option>전라북도</option>
              <option>제주특별자치도</option>
              <option>충청남도</option>
              <option>충청북도</option>
            </Select>
          </Label>
 
          <Label>
            <LabelText>유입 경로</LabelText>
            <Select {...register('funnel')}>
              <option disabled selected value="">
                유입 경로를 선택해주세요.
              </option>
              <option>지인 추천</option>
              <option>SNS 게시글</option>
              <option>리얼월드 앱</option>
              <option>온라인 광고 (유튜브, 포털 등)</option>
              <option>오프라인 광고 (버스, 현수막 등)</option>
              <option>뉴스기사 및 미디어 보도</option>
              <option>기타</option>
            </Select>
          </Label>
 
          <LabelText required>개인정보 수집 및 이용 동의</LabelText>
          <TermsContainer>
            <strong>개인정보 수집 및 이용 동의</strong>
            <br />
            <br />
            (주)유니크굿컴퍼니는 개인정보 보호법 제30조에 따라 정보 주체의 개인정보를 보호하고 이와
            관련한 고충을 신속하고 원활하게 처리할 수 있도록 하기 위하여 다음과 같이 개인정보
            처리지침을 수립, 공개합니다.
            <br />
            <br />
            - 개인정보의 수집 및 이용 주체: (주)유니크굿컴퍼니
            <br />
            - 개인정보의 수집 및 이용 목적: 이벤트 경품 제공
            <br />
            - 수집하는 개인정보의 항목: 이름, 휴대폰 번호
            <br />
            - 개인정보의 보유 및 이용 기간: 이벤트 종료 후 경품발송 후 파기
            <br />- 이용자는 활용에 대하여 동의를 거부할 권리가 있습니다. 단, 비동의 시 이벤트 참여
            및 경품 수령이 불가합니다.
          </TermsContainer>
 
          <label>
            <input
              {...register('isAgree', { required: true })}
              id="isAgree"
              type="checkbox"
              style={{ marginRight: '8px' }}
            />
            개인정보 수집 및 이용에 동의합니다.
          </label>
          {errors.isAgree && <ErrorText>개인정보 수집 및 이용에 동의해주세요.</ErrorText>}
 
          <SubmitButtonContainer>
            <SubmitButton type="submit">접수하기</SubmitButton>
          </SubmitButtonContainer>
          <BottomImageItem src={BottomImage.src} alt="이미지" />
        </Form>
      </FormContainer>
    </DefaultLayout>
  );
}
 
export const InfoContainer = styled.div`
  width: 980px;
  margin: 0 auto;
`;
 
export const FormContainer = styled.div`
  position: relative;
  width: 820px;
  margin: 0 auto;
`;
 
export const Form = styled.form`
  display: grid;
  gap: 16px;
  border: '1px solid #000';
`;
 
export const ErrorText = styled.span`
  color: red;
`;
 
export const Input = styled.input`
  width: 100%;
  height: 40px;
  border: 1px solid rgba(0, 0, 0, 0.3);
  border-radius: 6px;
  padding-left: 8px;
 
  &::-webkit-outer-spin-button,
  &::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
  }
`;
 
export const Select = styled.select`
  width: 100%;
  height: 40px;
  border: 1px solid rgba(0, 0, 0, 0.3);
  border-radius: 6px;
  padding-left: 8px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
`;
 
export const Label = styled.label<{ required?: boolean }>`
  display: grid;
  gap: 8px;
  line-height: 1.5;
`;
 
export const LabelText = styled.div<{ required?: boolean }>`
  &::after {
    content: ${(props) => (props.required ? '"*"' : '')};
    margin-left: 4px;
    color: red;
  }
`;
 
export const TermsContainer = styled.div`
  padding: 16px;
  border: 1px solid #bcbcbc;
  border-radius: 6px;
  line-height: 1.5;
`;
 
export const SubmitButtonContainer = styled.div`
  text-align: center;
`;
 
export const SubmitButton = styled.button`
  width: fit-content;
  padding: 10px 25px;
  background-color: #a62524;
  color: #fff;
  border: none;
  border-radius: 50px;
`;
 
export const BottomImageItem = styled.img`
  width: 100%;
  margin: 60px 0;
`;
 
export const TopImageContainer = styled.div`
  position: relative;
  width: 100%;
  height: 60px;
  margin: 60px 0;
  text-align: center;
`;
 
export const TopImageItem = styled.img`
  height: 100%;
`;
 
export const Header = styled.h2`
  text-align: center;
  margin: 60px 0;
  font-size: 32px;
`;
 
export const StyledUl = styled.ul`
  font-size: 18px;
  line-height: 1.8;
`;