비밀번호변경팝업 & 메인 컨텐츠

This commit is contained in:
basssy 2024-10-22 14:32:37 +09:00
parent f268e96221
commit 591636740f
5 changed files with 98 additions and 79 deletions

View File

@ -2,39 +2,32 @@
import React, { useEffect, useState } from 'react' import React, { useEffect, useState } from 'react'
import { useRouter } from 'next/navigation' import { useRouter } from 'next/navigation'
import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil' import { useRecoilState, useRecoilValue } from 'recoil'
import { modalContent, modalState, modalProps } from '@/store/modalAtom'
import { sessionStore } from '@/store/commonAtom' import { sessionStore } from '@/store/commonAtom'
import { useAxios } from '@/hooks/useAxios' import { useAxios } from '@/hooks/useAxios'
import { globalLocaleStore } from '@/store/localeAtom' import { globalLocaleStore } from '@/store/localeAtom'
import MainContents from './main/MainContents' import MainContents from './main/MainContents'
import { useMessage } from '@/hooks/useMessage' import { useMessage } from '@/hooks/useMessage'
import { stuffSearchState } from '@/store/stuffAtom' import { stuffSearchState } from '@/store/stuffAtom'
import { useForm } from 'react-hook-form'
import '@/styles/contents.scss' import '@/styles/contents.scss'
import ChangePasswordPop from './main/ChangePasswordPop' import ChangePasswordPop from './main/ChangePasswordPop'
import { searchState } from '@/store/boardAtom' import { searchState } from '@/store/boardAtom'
export default function MainPage() { export default function MainPage() {
const [sessionState, setSessionState] = useRecoilState(sessionStore) const sessionState = useRecoilValue(sessionStore)
const globalLocaleState = useRecoilValue(globalLocaleStore) const globalLocaleState = useRecoilValue(globalLocaleStore)
const { get } = useAxios(globalLocaleState) const { promiseGet } = useAxios(globalLocaleState)
const router = useRouter() const router = useRouter()
const { getMessage } = useMessage() const { getMessage } = useMessage()
const [searchTxt, setSearchTxt] = useState('') const [searchTxt, setSearchTxt] = useState('')
const [searchRadioType, setSearchRadioType] = useState('object') const [searchRadioType, setSearchRadioType] = useState('object')
//
const [saleStoreId, setSaleStoreId] = useState('') const [saleStoreId, setSaleStoreId] = useState('')
const [saleStoreName, setSaleStoreName] = useState('') const [saleStoreName, setSaleStoreName] = useState('')
const [objectList, setObjectList] = useState([])
const [businessCharger, setBusinessCharger] = useState('')
const [businessChargerMail, setBusinessChargerMail] = useState('')
const [businessChargerTel, setBusinessChargerTel] = useState('')
const [stuffSearch, setStuffSearch] = useRecoilState(stuffSearchState) const [stuffSearch, setStuffSearch] = useRecoilState(stuffSearchState)
const [searchForm, setSearchForm] = useRecoilState(searchState) const [searchForm, setSearchForm] = useRecoilState(searchState)
@ -47,17 +40,15 @@ export default function MainPage() {
const fetchObjectList = async () => { const fetchObjectList = async () => {
try { try {
// const apiUrl = `/api/main-page/object/X167/list`
const apiUrl = `/api/main-page/object/${sessionState?.storeId}/list` const apiUrl = `/api/main-page/object/${sessionState?.storeId}/list`
const res = await get({ url: apiUrl }) await promiseGet({
if (res) { url: apiUrl,
setSaleStoreId(res.saleStoreId) }).then((res) => {
setSaleStoreName(res.saleStoreName) if (res.status === 200) {
setObjectList(res.objectList) setSaleStoreId(res.data.saleStoreId)
setBusinessCharger(res.businessCharger) setSaleStoreName(res.data.saleStoreName)
setBusinessChargerMail(res.businessChargerMail) }
setBusinessChargerTel(res.businessChargerTel) })
}
} catch (error) { } catch (error) {
console.error('MAIN API fetching error:', error) console.error('MAIN API fetching error:', error)
} }
@ -143,12 +134,7 @@ export default function MainPage() {
<button className="search-icon" onClick={handleOnSubmit}></button> <button className="search-icon" onClick={handleOnSubmit}></button>
</div> </div>
</div> </div>
<MainContents <MainContents />
objectList={objectList}
businessCharger={businessCharger}
businessChargerMail={businessChargerMail}
businessChargerTel={businessChargerTel}
/>
</div> </div>
</> </>
)) || ( )) || (

View File

@ -70,8 +70,9 @@ export default function ChangePasswordPop() {
chgType: 'I', chgType: 'I',
chgPwd: _password1, chgPwd: _password1,
} }
await patch({ url: '/api/login/v1.0/user/change-password', data: param }).then((res) => { await patch({ url: '/api/login/v1.0/user/change-password', data: param }).then((res) => {
if (res) { if (res.result.code === 200) {
if (res.result.resultCode === 'S') { if (res.result.resultCode === 'S') {
alert(getMessage('main.popup.login.success')) alert(getMessage('main.popup.login.success'))
setSessionState({ ...sessionState, pwdInitYn: 'Y' }) setSessionState({ ...sessionState, pwdInitYn: 'Y' })

View File

@ -8,11 +8,18 @@ import { useRecoilValue } from 'recoil'
import { useRouter } from 'next/navigation' import { useRouter } from 'next/navigation'
import { globalLocaleStore } from '@/store/localeAtom' import { globalLocaleStore } from '@/store/localeAtom'
import { queryStringFormatter } from '@/util/common-utils' import { queryStringFormatter } from '@/util/common-utils'
export default function MainContents({ objectList, businessCharger, businessChargerMail, businessChargerTel }) { import { sessionStore } from '@/store/commonAtom'
export default function MainContents() {
const { getMessage } = useMessage() const { getMessage } = useMessage()
const router = useRouter() const router = useRouter()
const globalLocaleState = useRecoilValue(globalLocaleStore) const globalLocaleState = useRecoilValue(globalLocaleStore)
const { get } = useAxios(globalLocaleState) const { promiseGet, get } = useAxios(globalLocaleState)
const sessionState = useRecoilValue(sessionStore)
//
const [objectList, setObjectList] = useState([])
// //
const [recentNoticeList, setRecentNoticeList] = useState([]) const [recentNoticeList, setRecentNoticeList] = useState([])
@ -20,10 +27,37 @@ export default function MainContents({ objectList, businessCharger, businessChar
//FAQ //FAQ
const [recentFaqList, setRecentFaqList] = useState([]) const [recentFaqList, setRecentFaqList] = useState([])
//Sales Contact info
const [businessCharger, setBusinessCharger] = useState(null)
const [businessChargerMail, setBusinessChargerMail] = useState(null)
useEffect(() => { useEffect(() => {
fetchObjectList()
fetchNoticeList() fetchNoticeList()
fetchFaqList() fetchFaqList()
}, []) }, [sessionState])
// / Sales Contact info
const fetchObjectList = async () => {
try {
const apiUrl = `/api/main-page/object/${sessionState?.storeId}/list`
await promiseGet({
url: apiUrl,
}).then((res) => {
if (res.status === 200) {
setObjectList(res.data.objectList)
setBusinessCharger(res.data.businessCharger)
setBusinessChargerMail(res.data.businessChargerMail)
} else {
setObjectList([])
setBusinessCharger(null)
setBusinessChargerMail(null)
}
})
} catch (error) {
console.error('MAIN API fetching error:', error)
}
}
// //
const fetchNoticeList = async () => { const fetchNoticeList = async () => {
@ -35,13 +69,13 @@ export default function MainContents({ objectList, businessCharger, businessChar
endRow: 1, endRow: 1,
} }
const noticeApiUrl = `api/board/list?${queryStringFormatter(param)}` const noticeApiUrl = `api/board/list?${queryStringFormatter(param)}`
const res = await get({ url: noticeApiUrl }) await promiseGet({ url: noticeApiUrl }).then((res) => {
//console.log('res::', res) if (res.status === 200) {
if (res) { setRecentNoticeList(res.data.data)
if (res.data.length > 0) { } else {
setRecentNoticeList(res.data) setRecentNoticeList([])
} }
} })
} catch (error) { } catch (error) {
console.error('NOTICE fetching error:', error) console.error('NOTICE fetching error:', error)
} }
@ -57,13 +91,15 @@ export default function MainContents({ objectList, businessCharger, businessChar
endRow: 3, endRow: 3,
} }
const faqApiUrl = `api/board/list?${queryStringFormatter(param)}` const faqApiUrl = `api/board/list?${queryStringFormatter(param)}`
const res = await get({ url: faqApiUrl }) await promiseGet({
//console.log('FAQres::', res) url: faqApiUrl,
if (res) { }).then((res) => {
if (res.data.length > 0) { if (res.status === 200) {
setRecentFaqList(res.data) setRecentFaqList(res.data.data)
} else {
setRecentFaqList([])
} }
} })
} catch (error) { } catch (error) {
console.error('FAQ fetching error:', error) console.error('FAQ fetching error:', error)
} }
@ -74,38 +110,28 @@ export default function MainContents({ objectList, businessCharger, businessChar
<div className="main-product-list"> <div className="main-product-list">
<ProductItem num={1} name={getMessage('main.content.objectList')}> <ProductItem num={1} name={getMessage('main.content.objectList')}>
<ul className="recently-list"> <ul className="recently-list">
{objectList?.length > 0 ? ( {objectList.map((row) => {
<> return (
{objectList.map((row) => { <li
return ( key={row.objectNo}
<li className="recently-item"
key={row.objectNo} onClick={() => {
className="recently-item" if (row.objectNo.substring(0, 1) === 'R') {
onClick={() => { router.push(`/management/stuff/detail?objectNo=${row.objectNo.toString()}`)
if (row.objectNo.substring(0, 1) === 'R') { } else {
router.push(`/management/stuff/detail?objectNo=${row.objectNo.toString()}`) router.push(`/management/stuff/tempdetail?objectNo=${row.objectNo.toString()}`)
} else { }
router.push(`/management/stuff/tempdetail?objectNo=${row.objectNo.toString()}`) }}
} >
}} <div className="item-inner">
> <span className="time">{dayjs(row.lastEditDatetime).format('YYYY.MM.DD HH:mm:ss')}</span>
<div className="item-inner"> <span>{row.objectNo}</span>
<span className="time">{dayjs(row.lastEditDatetime).format('YYYY.MM.DD HH:mm:ss')}</span> <span>{row.objectName}</span>
<span>{row.objectNo}</span> <span>{row.saleStoreName}</span>
<span>{row.objectName}</span> </div>
<span>{row.saleStoreName}</span>
</div>
</li>
)
})}
</>
) : (
<>
<li>
<div className="item-inner">최근 갱신 물건이 없습니다</div>
</li> </li>
</> )
)} })}
</ul> </ul>
</ProductItem> </ProductItem>
<ProductItem num={2} name={getMessage('main.content.notice')}> <ProductItem num={2} name={getMessage('main.content.notice')}>
@ -156,13 +182,17 @@ export default function MainContents({ objectList, businessCharger, businessChar
<div className="icon-box"> <div className="icon-box">
<Image src="/static/images/main/user.svg" alt="react" width={20} height={20} /> <Image src="/static/images/main/user.svg" alt="react" width={20} height={20} />
</div> </div>
<div className="infor-data">{businessCharger}</div> {(businessCharger && <div className="infor-data">{businessCharger}</div>) || (
<div className="infor-data pre">{getMessage('main.content.noBusiness')}</div>
)}
</li> </li>
<li className="info-item"> <li className="info-item">
<div className="icon-box"> <div className="icon-box">
<Image src="/static/images/main/mail.svg" alt="react" width={20} height={20} /> <Image src="/static/images/main/mail.svg" alt="react" width={20} height={20} />
</div> </div>
<div className="infor-data pre">{businessChargerMail}</div> {(businessChargerMail && <div className="infor-data pre">{businessChargerMail}</div>) || (
<div className="infor-data pre">{getMessage('main.content.noBusiness')}</div>
)}
</li> </li>
</ul> </ul>
</ProductItem> </ProductItem>

View File

@ -588,6 +588,7 @@
"main.content.notice": "お知らせ", "main.content.notice": "お知らせ",
"main.content.download1": "操作マニュアル", "main.content.download1": "操作マニュアル",
"main.content.download2": "屋根の説明書", "main.content.download2": "屋根の説明書",
"main.content.noBusiness": "Hanwha Japanにお問い合わせください",
"main.popup.login.popupTitle": "パスワード変更", "main.popup.login.popupTitle": "パスワード変更",
"main.popup.login.newPassword1": "新しいパスワードを入力", "main.popup.login.newPassword1": "新しいパスワードを入力",
"main.popup.login.newPassword2": "新規パスワード再入力", "main.popup.login.newPassword2": "新規パスワード再入力",

View File

@ -472,7 +472,7 @@
"stuff.addressPopup.btn1": "닫기", "stuff.addressPopup.btn1": "닫기",
"stuff.addressPopup.btn2": "주소적용", "stuff.addressPopup.btn2": "주소적용",
"stuff.planReqPopup.title": "설계의뢰 불러오기", "stuff.planReqPopup.title": "설계의뢰 불러오기",
"stuff.temp.subTitle" : "물건정보", "stuff.temp.subTitle": "물건정보",
"stuff.detail.required": "필수 입력항목", "stuff.detail.required": "필수 입력항목",
"stuff.detail.planReqNo": "설계의뢰No.", "stuff.detail.planReqNo": "설계의뢰No.",
"stuff.detail.dispCompanyName": "담당자", "stuff.detail.dispCompanyName": "담당자",
@ -593,12 +593,13 @@
"main.content.notice": "공지사항", "main.content.notice": "공지사항",
"main.content.download1": "조작메뉴얼", "main.content.download1": "조작메뉴얼",
"main.content.download2": "지붕설명서", "main.content.download2": "지붕설명서",
"main.content.noBusiness": "Hanwha Japan에 문의하세요",
"main.popup.login.popupTitle": "비밀번호변경", "main.popup.login.popupTitle": "비밀번호변경",
"main.popup.login.newPassword1": "새 비밀번호 입력", "main.popup.login.newPassword1": "새 비밀번호 입력",
"main.popup.login.newPassword2": "새 비밀번호 재입력", "main.popup.login.newPassword2": "새 비밀번호 재입력",
"main.popup.login.placeholder": "반각 10자 이내", "main.popup.login.placeholder": "반각 10자 이내",
"main.popup.login.guide1": "초기화된 비밀번호로 로그인한 경우 비밀번호를 변경하지 않으면 사이트 이용이 가능합니다.", "main.popup.login.guide1": "초기화된 비밀번호로 로그인한 경우, 비밀번호를 변경해야 사이트 이용이 가능합니다.",
"main.popup.login.guide2": "비밀번호를 변경하지 않으려면 로그인 화면으로 이동합니다.", "main.popup.login.guide2": "비밀번호를 변경하지 않을 경우, 로그인 화면으로 이동합니다.",
"main.popup.login.btn1": "변경", "main.popup.login.btn1": "변경",
"main.popup.login.btn2": "변경안함", "main.popup.login.btn2": "변경안함",
"main.popup.login.validate1": "입력한 패스워드가 다릅니다.", "main.popup.login.validate1": "입력한 패스워드가 다릅니다.",