diff --git a/src/components/community/Qna.jsx b/src/components/community/Qna.jsx
index ed65637f..033f7424 100644
--- a/src/components/community/Qna.jsx
+++ b/src/components/community/Qna.jsx
@@ -195,9 +195,7 @@ export default function Qna() {
))
) : (
- |
- {getMessage('common.message.no.data')}
- |
+ {getMessage('common.message.no.data')} |
)}
diff --git a/src/components/community/modal/QnaRegModal.jsx b/src/components/community/modal/QnaRegModal.jsx
index ef40457b..c7e3b40b 100644
--- a/src/components/community/modal/QnaRegModal.jsx
+++ b/src/components/community/modal/QnaRegModal.jsx
@@ -27,6 +27,7 @@ export default function QnaRegModal({ setOpen, setReload, searchValue, selectPag
const qnaTypeLgCodeRef = useRef(null)
const qnaTypeMdCodeRef = useRef(null)
const qnaTypeSmCodeRef = useRef(null)
+ const qstMail = useRef(null);
const regUserNmRef = useRef(null)
const regUserTelNoRef = useRef(null)
const titleRef = useRef(null)
@@ -65,6 +66,7 @@ let fileCheck = false;
const initQnaReg = async () => {
+ qstMail.current.value = ''
regUserNmRef.current.value = ''
regUserTelNoRef.current.value = ''
qnaTypeLgCodeRef.current.setValue();
@@ -148,7 +150,7 @@ let fileCheck = false;
if(!fileCheck) return;
fileUploadProps.uploadFiles.forEach((file) => {
- console.log("file::::::::",file)
+ //console.log("file::::::::",file)
formData.push(file)
})
@@ -156,6 +158,16 @@ let fileCheck = false;
fileCheck = false;
}
+ const isValidEmail = (email) => {
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
+ return emailRegex.test(email);
+ };
+
+ const isEmpty = (value) => {
+ return value === null || value === undefined || value.trim() === "";
+ };
+
+
const handleQnaSubmit = async () => {
//필수 체크
@@ -164,13 +176,22 @@ let fileCheck = false;
let regUserNm = qnaData?.regUserNm??'';
- if (regUserNm.trim().length === 0) {
+ if (!isValidEmail(qnaData.qstMail)) {
+ qstMail.current.focus();
+ swalFire({
+ title: getMessage('qna.reg.alert.require.qstMail'),
+ icon: 'warning',
+ });
+ return;
+ }
- regUserNmRef.current.value = '';
+
+ if (isEmpty(regUserNm)) {
+ regUserNmRef.current.value = '';
regUserNmRef.current.focus()
swalFire({
- text: getMessage('qna.reg.alert.require.regUserNm'),
- type: 'alert',
+ title: getMessage('qna.reg.alert.require.regUserNm'),
+ icon: 'warning',
})
return false
}
@@ -178,35 +199,35 @@ let fileCheck = false;
let qnaClsLrgCd = qnaData?.qnaClsLrgCd??'';
let qnaClsMidCd = qnaData?.qnaClsMidCd??'';
- if (qnaClsLrgCd.trim().length === 0 || qnaClsMidCd.trim().length === 0 ) {
- (qnaClsLrgCd.trim().length === 0)?qnaTypeLgCodeRef.current.focus():qnaTypeMdCodeRef.current.focus()
+ if (isEmpty(qnaClsLrgCd) || isEmpty(qnaClsMidCd) ) {
+ (isEmpty(qnaClsLrgCd))?qnaTypeLgCodeRef.current.focus():qnaTypeMdCodeRef.current.focus()
swalFire({
- text: getMessage('qna.reg.alert.select.type'),
- type: 'alert',
+ title: getMessage('qna.reg.alert.select.type'),
+ icon: 'warning',
})
return false
}
let title = qnaData?.title??'';
- if (title.trim().length === 0) {
+ if (isEmpty(title)) {
titleRef.current.value = '';
titleRef.current.focus()
swalFire({
- text: getMessage('qna.reg.alert.require.title'),
- type: 'alert',
+ title: getMessage('qna.reg.alert.require.title'),
+ icon: 'warning',
})
return false
}
//console.log("5::::",qnaData)
let contents = qnaData?.contents??'';
- if (contents.trim().length === 0) {
+ if (isEmpty(contents)) {
contentsRef.current.value = '';
contentsRef.current.focus()
swalFire({
- text: getMessage('qna.reg.alert.require.contents'),
- type: 'alert',
+ title: getMessage('qna.reg.alert.require.contents'),
+ icon: 'warning',
})
return false
}
@@ -310,7 +331,13 @@ let fileCheck = false;
{getMessage('qna.list.header.regNm')} |
|
E-Mail* |
- |
+ setQnaData({...qnaData, qstMail: e.target.value })}
+ onBlur={(e) => setQnaData({ ...qnaData, qstMail: e.target.value })} />
+ |
+
{getMessage('qna.reg.header.regDt')} |
{dayjs(new Date()).format('YYYY-MM-DD')} |
diff --git a/src/locales/ja.json b/src/locales/ja.json
index 00599068..d90cab69 100644
--- a/src/locales/ja.json
+++ b/src/locales/ja.json
@@ -612,6 +612,7 @@
"qna.reg.header.contents": "お問い合わせ内容",
"qna.reg.header.fileList": "ファイル添付",
"qna.reg.header.save": "保存",
+ "qna.reg.alert.require.qstMail": "無効なメール形式です。",
"qna.reg.alert.require.regUserNm": "名前を入力してください。",
"qna.reg.alert.select.type": "お問い合わせ区分を選択してください。",
"qna.reg.alert.require.title": "タイトルを入力してください。",
diff --git a/src/locales/ko.json b/src/locales/ko.json
index efcabd1c..67176ee8 100644
--- a/src/locales/ko.json
+++ b/src/locales/ko.json
@@ -612,6 +612,7 @@
"qna.reg.header.contents": "문의정보",
"qna.reg.header.fileList": "파일첨부",
"qna.reg.header.save": "저장",
+ "qna.reg.alert.require.qstMail": "올바르지 않은 이메일 형식입니다.",
"qna.reg.alert.require.regUserNm": "이름을 입력하세요.",
"qna.reg.alert.select.type": "문의구분을 선택하세요.",
"qna.reg.alert.require.title": "제목을 입력하세요.",