• Y
  • List All
  • Feedback
    • This Project
    • This Group
    • All Projects
Profile Account settings Log out
  • Favorite
  • Project
  • All
Loading...
  • Log in
  • Sign up
itnAdmin / base_react star
  • Project homeH
  • CodeC
  • IssueI
  • Pull requestP
  • Review R
  • MilestoneM
  • BoardB
  • Files
  • Commit
  • Branches
base_reactsrcadminfeatureboardmasterhookpageuseBoardFormPage.ts
Download as .zip file
File name
Commit message
Commit date
public/publish
게시판 관리 게시판 마스터 목록 + (포토형, 일반형) 게시판 목록 [detail, 홈페이지 이동 추가해야함.]
05-07
src
editor 추가 및 권한관리 작업 완료 [컨텐츠 관리], [권한관리]
05-28
.gitignore
init commit
05-04
eslint.config.js
권한관리 > 관리자별메뉴관리, 자주 쓰이는 메커니즘 function [util] 화
05-20
index.html
init commit
05-04
package-lock.json
editor 추가 및 권한관리 작업 완료 [컨텐츠 관리], [권한관리]
05-28
package.json
editor 추가 및 권한관리 작업 완료 [컨텐츠 관리], [권한관리]
05-28
tsconfig.app.json
init commit
05-04
tsconfig.json
init commit
05-04
tsconfig.node.json
init commit
05-04
vite.config.ts
게시판 관리 게시판 마스터 목록 + (포토형, 일반형) 게시판 목록 [detail, 홈페이지 이동 추가해야함.]
05-07
File name
Commit message
Commit date
admin
editor 추가 및 권한관리 작업 완료 [컨텐츠 관리], [권한관리]
05-28
api
api use Query + axios 형태로 변경 예시 use BoardListQuery 추가
05-06
styles
editor 추가 및 권한관리 작업 완료 [컨텐츠 관리], [권한관리]
05-28
type
권한관리 > 롤관리
05-20
user
editor 추가 및 권한관리 작업 완료 [컨텐츠 관리], [권한관리]
05-28
App.tsx
editor 추가 및 권한관리 작업 완료 [컨텐츠 관리], [권한관리]
05-28
main.tsx
toast Message + board example Add
05-06
File name
Commit message
Commit date
component
editor 추가 및 권한관리 작업 완료 [컨텐츠 관리], [권한관리]
05-28
feature
editor 추가 및 권한관리 작업 완료 [컨텐츠 관리], [권한관리]
05-28
hook
권한관리 > 관리자별메뉴관리, 자주 쓰이는 메커니즘 function [util] 화
05-20
layout
권한관리 > 관리자별메뉴관리, 자주 쓰이는 메커니즘 function [util] 화
05-20
route
editor 추가 및 권한관리 작업 완료 [컨텐츠 관리], [권한관리]
05-28
index.ts
init commit
05-04
File name
Commit message
Commit date
board
권한관리 > 롤관리
05-20
content
editor 추가 및 권한관리 작업 완료 [컨텐츠 관리], [권한관리]
05-28
role
editor 추가 및 권한관리 작업 완료 [컨텐츠 관리], [권한관리]
05-28
File name
Commit message
Commit date
article
권한관리 > 관리자별메뉴관리, 자주 쓰이는 메커니즘 function [util] 화
05-20
master
권한관리 > 롤관리
05-20
File name
Commit message
Commit date
api
관리자 feature 구조를 세부메뉴 단위로 정리
05-15
components
권한관리 > 관리자별메뉴관리, 자주 쓰이는 메커니즘 function [util] 화
05-20
hook
권한관리 > 롤관리
05-20
page
관리자 feature 구조를 세부메뉴 단위로 정리
05-15
type
관리자 feature 구조를 세부메뉴 단위로 정리
05-15
File name
Commit message
Commit date
mutation
관리자 feature 구조를 세부메뉴 단위로 정리
05-15
page
권한관리 > 롤관리
05-20
query
관리자 feature 구조를 세부메뉴 단위로 정리
05-15
File name
Commit message
Commit date
useBoardFormPage.ts
권한관리 > 롤관리
05-20
useBoardListPage.ts
관리자 feature 구조를 세부메뉴 단위로 정리
05-15
chominsoo4245 05-20 c4884bf 권한관리 > 롤관리 UNIX
Raw Open in browser Change history
import {type ChangeEvent, useMemo, useState} from "react"; import {useNavigate} from "react-router-dom"; import {toast} from "react-toastify"; import {ADMIN_BBS_MASTER_ROUTE} from "../../../../../route/adminRouteMap.ts"; import type {CommonCodeItem} from "../../../../../../type/code.ts"; import type {BoardFormItem} from "../../type/boardMaster.types.ts"; import {useBoardDetail} from "../query/useBoardDetail.ts"; import {useCreateBoard} from "../mutation/useCreateBoard.ts"; import {useDeleteBoard} from "../mutation/useDeleteBoard.ts"; import {useUpdateBoard} from "../mutation/useUpdateBoard.ts"; import type {FormActionsModel, FormMode, HeaderModel, StatusModel} from "../../../../../../type/viewModel.ts"; type BoardFormPageModel = { header: HeaderModel; status: StatusModel; form: { form: BoardFormItem; onChange: (event: ChangeEvent<HTMLInputElement | HTMLSelectElement>) => void; }; actions: FormActionsModel<FormMode>; }; const initBoardFormData: BoardFormItem = { bbsId: '', bbsNm: '', bbsTyCode: '', noticeYn: 'Y', addYn: 'Y', fileAtchPosblAt: 'Y', posblAtchFileNumber: '0', posblAtchFileSize: '0', viewsYn: 'Y', useAt: 'Y', }; const createInitialForm = ( item?: BoardFormItem, typeList: CommonCodeItem[] = [] ) => ({ ...initBoardFormData, bbsTyCode: typeList[0]?.code ?? '', ...item, }); export const useBoardFormPage = (bbsId: string): BoardFormPageModel => { const navigate = useNavigate(); const mode: FormMode = bbsId ? 'update' : 'create'; const [formDraft, setFormDraft] = useState<Partial<BoardFormItem>>({}); const {data, isLoading, error} = useBoardDetail(bbsId, {enabled: !!bbsId}); const {mutateAsync: createBoard, isPending: isCreating} = useCreateBoard(); const {mutateAsync: updateBoard, isPending: isUpdating} = useUpdateBoard(); const {mutateAsync: deleteBoard, isPending: isDeleting} = useDeleteBoard(); const isPending = isCreating || isUpdating || isDeleting; const title = `게시판 ${mode === 'create' ? '생성' : '수정'}`; const breadcrumb = [ {label: '게시판 관리', url: ADMIN_BBS_MASTER_ROUTE}, {label: title} ]; const baseForm = useMemo( () => createInitialForm(data?.result, data?.typeList), [data?.result, data?.typeList] ); const form = { ...baseForm, ...formDraft, }; const handleChange = (event: ChangeEvent<HTMLInputElement | HTMLSelectElement>) => { const {name, value} = event.target; setFormDraft((prev) => ({ ...prev, [name]: value, })); }; const validateForm = () => { if (!form.bbsNm.trim()) { toast.warning('게시판명을 입력해주세요.'); return false; } if (!form.bbsTyCode) { toast.warning('게시판유형을 선택해주세요.'); return false; } return true; }; const handleCreate = async () => { if (!validateForm()) { return; } await toast.promise( createBoard(form), { pending: '등록 중...', success: '등록 완료', error: '등록 실패' } ); handleList(); }; const handleUpdate = async () => { if (!validateForm()) { return; } await toast.promise( updateBoard(form), { pending: '수정 중...', success: '수정 완료', error: '수정 실패' } ); handleList(); }; const handleDelete = async () => { if (!bbsId || !window.confirm('게시판을 삭제하시겠습니까?')) { return; } await toast.promise( deleteBoard(bbsId), { pending: '삭제 중...', success: '삭제 완료', error: '삭제 실패' } ); handleList(); }; const handleList = () => { navigate(ADMIN_BBS_MASTER_ROUTE); }; return { header: { title, breadcrumb, homeUrl: "#", }, status: { isLoading, error, successMessage: '데이터 조회가 완료되었습니다.', }, form: { form, onChange: handleChange, }, actions: { mode, disabled: isPending, onCreate: handleCreate, onUpdate: handleUpdate, onDelete: handleDelete, onList: handleList, }, }; };

          
        
    
    
Copyright Yona authors & © NAVER Corp. & NAVER LABS Supported by NAVER CLOUD PLATFORM

or
Sign in with github login with Google Sign in with Google
Reset password | Sign up