import React, { useEffect, useState } from 'react' import ProductItem from './ProductItem' import { useMessage } from '@/hooks/useMessage' import Image from 'next/image' import dayjs from 'dayjs' import { useAxios } from '@/hooks/useAxios' import { useRecoilValue } from 'recoil' import { useRouter } from 'next/navigation' import { globalLocaleStore } from '@/store/localeAtom' import { queryStringFormatter } from '@/util/common-utils' export default function MainContents({ objectList, businessCharger, businessChargerMail, businessChargerTel }) { const { getMessage } = useMessage() const router = useRouter() const globalLocaleState = useRecoilValue(globalLocaleStore) const { get } = useAxios(globalLocaleState) //공지사항 const [recentNoticeList, setRecentNoticeList] = useState([]) //FAQ const [recentFaqList, setRecentFaqList] = useState([]) useEffect(() => { fetchNoticeList() fetchFaqList() }, []) //공지사항 호출 const fetchNoticeList = async () => { try { const param = { schNoticeTpCd: 'QC', schNoticeClsCd: 'NOTICE', startRow: 1, endRow: 1, } const noticeApiUrl = `api/board/list?${queryStringFormatter(param)}` const res = await get({ url: noticeApiUrl }) //console.log('공지res::', res) if (res) { if (res.data.length > 0) { setRecentNoticeList(res.data) } } } catch (error) { console.error('NOTICE fetching error:', error) } } //FAQ 호출 const fetchFaqList = async () => { try { const param = { schNoticeTpCd: 'QC', schNoticeClsCd: 'FAQ', startRow: 1, endRow: 3, } const faqApiUrl = `api/board/list?${queryStringFormatter(param)}` const res = await get({ url: faqApiUrl }) //console.log('FAQres::', res) if (res) { if (res.data.length > 0) { setRecentFaqList(res.data) } } } catch (error) { console.error('FAQ fetching error:', error) } } return (
    {objectList?.length > 0 ? ( <> {objectList.map((row) => { return (
  • { if (row.objectNo.substring(0, 1) === 'R') { router.push(`/management/stuff/detail?objectNo=${row.objectNo.toString()}`) } else { router.push(`/management/stuff/tempdetail?objectNo=${row.objectNo.toString()}`) } }} >
    {dayjs(row.lastEditDatetime).format('YYYY.MM.DD HH:mm:ss')} {row.objectNo} {row.objectName} {row.saleStoreName}
  • ) })} ) : ( <>
  • 최근 갱신 물건이 없습니다
  • )}
{recentNoticeList.length > 0 ? ( <>
{dayjs(recentNoticeList[0]?.regDt).format('YYYY.MM.DD')}
{recentNoticeList[0]?.title}
{recentNoticeList[0]?.contents}
) : null}
    {recentFaqList.length > 0 ? ( <> {recentFaqList.map((row) => { return (
  • FAQ {row.noticeNo}
    {row.title}
    {dayjs(row.regDt).format('YYYY.MM.DD')}
  • ) })} ) : null}
  • react
    {businessCharger}
  • react
    {businessChargerMail}
) }