T01 이 작성한 물건 T01아닌 사용자가 로그인했을때 버튼 숨김 처리

This commit is contained in:
basssy 2025-01-07 09:35:11 +09:00
parent 6e17d07074
commit e5d48b6b68
2 changed files with 37 additions and 22 deletions

View File

@ -41,12 +41,12 @@ export default function MainPage(mainPageProps) {
if (searchRadioType === 'object') { if (searchRadioType === 'object') {
setStuffSearch({ setStuffSearch({
...stuffSearch, ...stuffSearch,
schObjectNo: searchTxt, schObjectNo: searchTxt.trim(),
code: 'M', code: 'M',
}) })
router.push('/management/stuff', { scroll: false }) router.push('/management/stuff', { scroll: false })
} else { } else {
setSearchForm({ ...searchForm, searchValue: searchTxt, mainFlag: 'Y' }) setSearchForm({ ...searchForm, searchValue: searchTxt.trim(), mainFlag: 'Y' })
router.push('/community/faq') router.push('/community/faq')
} }
} }

View File

@ -34,6 +34,8 @@ export default function StuffDetail() {
const [popPlanNo, setPopPlanNo] = useState('1') //default 1 const [popPlanNo, setPopPlanNo] = useState('1') //default 1
const [showButton, setShowButton] = useState('') //, ,
// //
const { commonCode, findCommonCode } = useCommonCode() const { commonCode, findCommonCode } = useCommonCode()
const [selOptions, setSelOptions] = useState('') // 1 const [selOptions, setSelOptions] = useState('') // 1
@ -266,7 +268,11 @@ export default function StuffDetail() {
display: 'none', display: 'none',
} }
} }
//createUser T01 T01
if (managementState?.createUser === 'T01' && session?.userId !== 'T01') {
//createUser T01 T01
setShowButton('none')
}
return ( return (
<> <>
<div className="grid-cell-btn"> <div className="grid-cell-btn">
@ -318,8 +324,16 @@ export default function StuffDetail() {
setIsFormValid(true) setIsFormValid(true)
} }
promiseGet({ url: `/api/object/${objectNo}/detail` }).then((res) => { promiseGet({ url: `/api/object/${objectNo}/detail` }).then((res) => {
// console.log('res::::', res.data)
if (res.status === 200) { if (res.status === 200) {
// console.log(res.data.createUser)
// console.log(session)
if (res?.data?.createUser === 'T01') {
if (session?.userId !== 'T01') {
//createUser T01 T01
setShowButton('none')
}
}
if (isObjectNotEmpty(res.data)) { if (isObjectNotEmpty(res.data)) {
let surfaceTypeValue let surfaceTypeValue
if (res.data.surfaceType === 'Ⅲ・Ⅳ') { if (res.data.surfaceType === 'Ⅲ・Ⅳ') {
@ -1475,11 +1489,11 @@ export default function StuffDetail() {
</div> </div>
<div className="left-unit-box"> <div className="left-unit-box">
{!isFormValid ? ( {!isFormValid ? (
<Button className="btn-origin grey mr5" onPress={onTempSave}> <Button className="btn-origin grey mr5" onPress={onTempSave} style={{ display: showButton }}>
{getMessage('stuff.detail.btn.tempSave')} {getMessage('stuff.detail.btn.tempSave')}
</Button> </Button>
) : ( ) : (
<Button type="submit" className="btn-origin navy mr5"> <Button type="submit" className="btn-origin navy mr5" style={{ display: showButton }}>
{getMessage('stuff.detail.btn.save')} {getMessage('stuff.detail.btn.save')}
</Button> </Button>
)} )}
@ -1514,7 +1528,7 @@ export default function StuffDetail() {
)) || )) ||
null} null}
</div> </div>
<Button type="button" className="btn-origin grey" onPress={onSearchDesignRequestPopOpen}> <Button type="button" className="btn-origin grey" onPress={onSearchDesignRequestPopOpen} style={{ display: showButton }}>
{getMessage('stuff.planReqPopup.title')} {getMessage('stuff.planReqPopup.title')}
</Button> </Button>
</div> </div>
@ -1751,7 +1765,7 @@ export default function StuffDetail() {
<div className="input-wrap mr5" style={{ width: '200px' }}> <div className="input-wrap mr5" style={{ width: '200px' }}>
<input type="text" className="input-light" disabled value={form.watch('zipNo') || ''} /> <input type="text" className="input-light" disabled value={form.watch('zipNo') || ''} />
</div> </div>
<Button className="btn-origin grey" onPress={onSearchPostNumberPopOpen}> <Button className="btn-origin grey" onPress={onSearchPostNumberPopOpen} style={{ display: showButton }}>
{getMessage('stuff.detail.btn.addressPop')} {getMessage('stuff.detail.btn.addressPop')}
</Button> </Button>
<div className="guide">{getMessage('stuff.detail.btn.addressPop.guide')}</div> <div className="guide">{getMessage('stuff.detail.btn.addressPop.guide')}</div>
@ -1841,7 +1855,7 @@ export default function StuffDetail() {
></Select> ></Select>
</div> </div>
<span className="mr10">{getMessage('stuff.detail.standardWindSpeedIdSpan')}</span> <span className="mr10">{getMessage('stuff.detail.standardWindSpeedIdSpan')}</span>
<Button type="button" className="btn-origin grey" onPress={onSearchWindSpeedPopOpen}> <Button type="button" className="btn-origin grey" onPress={onSearchWindSpeedPopOpen} style={{ display: showButton }}>
{getMessage('stuff.detail.btn.windSpeedPop')} {getMessage('stuff.detail.btn.windSpeedPop')}
</Button> </Button>
</div> </div>
@ -1963,11 +1977,11 @@ export default function StuffDetail() {
</div> </div>
<div className="sub-right-footer"> <div className="sub-right-footer">
{!isFormValid ? ( {!isFormValid ? (
<Button className="btn-origin grey mr5" onPress={onTempSave}> <Button className="btn-origin grey mr5" onPress={onTempSave} style={{ display: showButton }}>
{getMessage('stuff.detail.btn.tempSave')} {getMessage('stuff.detail.btn.tempSave')}
</Button> </Button>
) : ( ) : (
<Button type="submit" className="btn-origin navy mr5"> <Button type="submit" className="btn-origin navy mr5" style={{ display: showButton }}>
{getMessage('stuff.detail.btn.save')} {getMessage('stuff.detail.btn.save')}
</Button> </Button>
)} )}
@ -1995,10 +2009,10 @@ export default function StuffDetail() {
{getMessage('stuff.detail.btn.moveList')} {getMessage('stuff.detail.btn.moveList')}
</button> </button>
</Link> </Link>
<Button type="submit" className="btn-origin navy mr5"> <Button type="submit" className="btn-origin navy mr5" style={{ display: showButton }}>
{getMessage('stuff.detail.btn.save')} {getMessage('stuff.detail.btn.save')}
</Button> </Button>
<Button type="button" className="btn-origin grey" onPress={onDelete}> <Button type="button" className="btn-origin grey" onPress={onDelete} style={{ display: showButton }}>
{getMessage('stuff.detail.btn.delete')} {getMessage('stuff.detail.btn.delete')}
</Button> </Button>
</div> </div>
@ -2007,11 +2021,11 @@ export default function StuffDetail() {
<> <>
<div className="left-unit-box"> <div className="left-unit-box">
{!isFormValid ? ( {!isFormValid ? (
<Button className="btn-origin grey mr5" onPress={onTempSave}> <Button className="btn-origin grey mr5" onPress={onTempSave} style={{ display: showButton }}>
{getMessage('stuff.detail.btn.tempSave')} {getMessage('stuff.detail.btn.tempSave')}
</Button> </Button>
) : ( ) : (
<Button type="submit" className="btn-origin navy mr5"> <Button type="submit" className="btn-origin navy mr5" style={{ display: showButton }}>
{getMessage('stuff.detail.btn.save')} {getMessage('stuff.detail.btn.save')}
</Button> </Button>
)} )}
@ -2045,12 +2059,13 @@ export default function StuffDetail() {
onClick={() => { onClick={() => {
form.setValue('planReqNo', '') form.setValue('planReqNo', '')
}} }}
style={{ display: showButton }}
></button> ></button>
) : null} ) : null}
</div> </div>
{managementState?.tempFlg === '1' ? ( {managementState?.tempFlg === '1' ? (
<> <>
<Button className="btn-origin grey" onPress={onSearchDesignRequestPopOpen}> <Button className="btn-origin grey" onPress={onSearchDesignRequestPopOpen} style={{ display: showButton }}>
{getMessage('stuff.planReqPopup.title')} {getMessage('stuff.planReqPopup.title')}
</Button> </Button>
</> </>
@ -2306,7 +2321,7 @@ export default function StuffDetail() {
<div className="input-wrap mr5" style={{ width: '200px' }}> <div className="input-wrap mr5" style={{ width: '200px' }}>
<input type="text" className="input-light" disabled value={form.watch('zipNo') || ''} /> <input type="text" className="input-light" disabled value={form.watch('zipNo') || ''} />
</div> </div>
<Button className="btn-origin grey" onPress={onSearchPostNumberPopOpen}> <Button className="btn-origin grey" onPress={onSearchPostNumberPopOpen} style={{ display: showButton }}>
{getMessage('stuff.detail.btn.addressPop')} {getMessage('stuff.detail.btn.addressPop')}
</Button> </Button>
<div className="guide">{getMessage('stuff.detail.btn.addressPop.guide')}</div> <div className="guide">{getMessage('stuff.detail.btn.addressPop.guide')}</div>
@ -2401,7 +2416,7 @@ export default function StuffDetail() {
></Select> ></Select>
</div> </div>
<span className="mr10">{getMessage('stuff.detail.standardWindSpeedIdSpan')}</span> <span className="mr10">{getMessage('stuff.detail.standardWindSpeedIdSpan')}</span>
<Button type="button" className="btn-origin grey" onPress={onSearchWindSpeedPopOpen}> <Button type="button" className="btn-origin grey" onPress={onSearchWindSpeedPopOpen} style={{ display: showButton }}>
{getMessage('stuff.detail.btn.windSpeedPop')} {getMessage('stuff.detail.btn.windSpeedPop')}
</Button> </Button>
</div> </div>
@ -2571,10 +2586,10 @@ export default function StuffDetail() {
{getMessage('stuff.detail.btn.moveList')} {getMessage('stuff.detail.btn.moveList')}
</button> </button>
</Link> </Link>
<Button type="submit" className="btn-origin navy mr5"> <Button type="submit" className="btn-origin navy mr5" style={{ display: showButton }}>
{getMessage('stuff.detail.btn.save')} {getMessage('stuff.detail.btn.save')}
</Button> </Button>
<Button type="button" className="btn-origin grey" onPress={onDelete}> <Button type="button" className="btn-origin grey" onPress={onDelete} style={{ display: showButton }}>
{getMessage('stuff.detail.btn.delete')} {getMessage('stuff.detail.btn.delete')}
</Button> </Button>
</div> </div>
@ -2583,11 +2598,11 @@ export default function StuffDetail() {
<> <>
<div className="sub-right-footer"> <div className="sub-right-footer">
{!isFormValid ? ( {!isFormValid ? (
<Button className="btn-origin grey mr5" onPress={onTempSave}> <Button className="btn-origin grey mr5" onPress={onTempSave} style={{ display: showButton }}>
{getMessage('stuff.detail.btn.tempSave')} {getMessage('stuff.detail.btn.tempSave')}
</Button> </Button>
) : ( ) : (
<Button type="submit" className="btn-origin navy mr5"> <Button type="submit" className="btn-origin navy mr5" style={{ display: showButton }}>
{getMessage('stuff.detail.btn.save')} {getMessage('stuff.detail.btn.save')}
</Button> </Button>
)} )}