260121_01_ENH : client env 정규화 및 로그인 페이지 오류 수정
This commit is contained in:
@@ -6,7 +6,7 @@ import {Card, CardContent, CardHeader} from "@/components/ui/card";
|
|||||||
import {Input} from "@/components/ui/input";
|
import {Input} from "@/components/ui/input";
|
||||||
import React, {useEffect, useRef, useState} from "react";
|
import React, {useEffect, useRef, useState} from "react";
|
||||||
import { nextApi } from "@/lib/http-client";
|
import { nextApi } from "@/lib/http-client";
|
||||||
import {useRouter, useSearchParams} from "next/navigation";
|
import {useSearchParams} from "next/navigation";
|
||||||
import {LoginUser} from "@/types/auth";
|
import {LoginUser} from "@/types/auth";
|
||||||
import { useAuth } from "@/hooks/useAuth";
|
import { useAuth } from "@/hooks/useAuth";
|
||||||
import { useLoading } from "@/hooks/useLoading";
|
import { useLoading } from "@/hooks/useLoading";
|
||||||
@@ -35,12 +35,15 @@ const LoginPage = () => {
|
|||||||
const tryLogin = () => {
|
const tryLogin = () => {
|
||||||
if(!userId){
|
if(!userId){
|
||||||
alert("아이디를 입력해 주세요");
|
alert("아이디를 입력해 주세요");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if(!userPw){
|
if(!userPw){
|
||||||
alert("PW를 입력해 주세요");
|
alert("PW를 입력해 주세요");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if(loginType === "call" && !seatNum){
|
if(loginType === "call" && !seatNum){
|
||||||
alert("자리번호를 입력해 주세요");
|
alert("자리번호를 입력해 주세요");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setError(null);
|
setError(null);
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
export const clientEnv = {
|
const required = <K extends keyof typeof RAW_PUBLIC_ENV>(name: K) => {
|
||||||
ENV: process.env.NEXT_PUBLIC_ENV as string,
|
const v = RAW_PUBLIC_ENV[name];
|
||||||
API_BASE: process.env.NEXT_PUBLIC_API_BASE as string,
|
if (!v) throw new Error(`Missing env: ${name}`);
|
||||||
STORE_KEY: process.env.NEXT_PUBLIC_STORE_KEY as string,
|
return v;
|
||||||
// 다른 클라이언트 전용 env들 추가 가능
|
|
||||||
};
|
};
|
||||||
if (!clientEnv.ENV) {
|
|
||||||
throw new Error("Missing env: NEXT_PUBLIC_ENV");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!clientEnv.API_BASE) {
|
const RAW_PUBLIC_ENV = {
|
||||||
throw new Error("Missing env: NEXT_PUBLIC_API_BASE");
|
NEXT_PUBLIC_ENV: process.env.NEXT_PUBLIC_ENV,
|
||||||
}
|
NEXT_PUBLIC_API_BASE: process.env.NEXT_PUBLIC_API_BASE,
|
||||||
|
NEXT_PUBLIC_STORE_KEY: process.env.NEXT_PUBLIC_STORE_KEY,
|
||||||
|
} as const;
|
||||||
|
|
||||||
if (!clientEnv.STORE_KEY) {
|
export const clientEnv = {
|
||||||
throw new Error("Missing env: NEXT_PUBLIC_STORE_KEY");
|
ENV: required("NEXT_PUBLIC_ENV"),
|
||||||
}
|
API_BASE: required("NEXT_PUBLIC_API_BASE"),
|
||||||
|
STORE_KEY: required("NEXT_PUBLIC_STORE_KEY"),
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user