feat: add REPRESENTATIVE_ID STORE_ID column, implement set value of storeId, representativeId for filtering survey List by member role
This commit is contained in:
parent
d2877ea440
commit
b2aefe7ea8
@ -75,7 +75,7 @@ const createMemberRoleCondition = (params: SearchParams): WhereCondition => {
|
||||
where.OR = [
|
||||
{
|
||||
// 같은 판매점에서 작성한 제출/제출되지 않은 매물
|
||||
AND: [{ STORE: { equals: params.store } }],
|
||||
AND: [{ STORE_ID: { equals: params.store } }],
|
||||
},
|
||||
{
|
||||
// MUSUBI (시공권한 X) 가 ORDER 에 제출한 매물
|
||||
@ -89,7 +89,7 @@ const createMemberRoleCondition = (params: SearchParams): WhereCondition => {
|
||||
{
|
||||
// MUSUBI (시공권한 X) 같은 판매점에서 작성한 제출/제출되지 않은 매물
|
||||
AND: [
|
||||
{ STORE: { equals: params.store } },
|
||||
{ STORE_ID: { equals: params.store } },
|
||||
{
|
||||
OR: [{ CONSTRUCTION_POINT: { equals: null } }, { CONSTRUCTION_POINT: { equals: '' } }],
|
||||
},
|
||||
@ -109,9 +109,10 @@ const createMemberRoleCondition = (params: SearchParams): WhereCondition => {
|
||||
|
||||
case 'Builder': // MUSUBI (시공권한 O)
|
||||
case 'Partner': // PARTNER
|
||||
// 같은 시공ID에서 작성된 매물
|
||||
// 시공점이 있고 STORE_ID가 시공ID와 같은 매물
|
||||
where.AND?.push({
|
||||
CONSTRUCTION_POINT: { equals: params.builderNo },
|
||||
CONSTRUCTION_POINT: { not: null },
|
||||
STORE_ID: { equals: params.builderNo },
|
||||
})
|
||||
break
|
||||
|
||||
@ -125,7 +126,7 @@ const createMemberRoleCondition = (params: SearchParams): WhereCondition => {
|
||||
},
|
||||
},
|
||||
{
|
||||
STORE: {
|
||||
STORE_ID: {
|
||||
equals: params.store,
|
||||
},
|
||||
},
|
||||
@ -149,11 +150,11 @@ export async function GET(request: Request) {
|
||||
const params: SearchParams = {
|
||||
keyword: searchParams.get('keyword'),
|
||||
searchOption: searchParams.get('searchOption'),
|
||||
isMySurvey: searchParams.get('isMySurvey'),
|
||||
isMySurvey: searchParams.get('isMySurvey'), //representativeId
|
||||
sort: searchParams.get('sort'),
|
||||
offset: searchParams.get('offset'),
|
||||
role: searchParams.get('role'),
|
||||
store: searchParams.get('store'),
|
||||
store: searchParams.get('store'), //storeId
|
||||
builderNo: searchParams.get('builderNo'),
|
||||
}
|
||||
|
||||
@ -162,7 +163,7 @@ export async function GET(request: Request) {
|
||||
|
||||
// 내가 작성한 매물 조건 적용
|
||||
if (params.isMySurvey) {
|
||||
where.AND.push({ REPRESENTATIVE: params.isMySurvey })
|
||||
where.AND.push({ REPRESENTATIVE_ID: params.isMySurvey })
|
||||
}
|
||||
|
||||
// 키워드 검색 조건 적용
|
||||
|
||||
@ -20,12 +20,16 @@ export default function BasicForm(props: { basicInfo: SurveyBasicRequest; setBas
|
||||
setBasicInfoSelected()
|
||||
}, [])
|
||||
|
||||
// 시공권한 user(Builder), Partner 계정은 조사매물 등록 할 때 STORE_ID에 시공점ID가 들어감
|
||||
// 권한 별 목록 필터링 시 시공권한 user(Builder), Partner는 시공점ID가 같은 것들만 조회
|
||||
useEffect(() => {
|
||||
if (session?.isLoggedIn) {
|
||||
setBasicInfo({
|
||||
...basicInfo,
|
||||
representative: session.userNm ?? '',
|
||||
representativeId: session.userId ?? null,
|
||||
store: session.role === 'Partner' ? null : session.storeNm ?? null,
|
||||
storeId: session.role === 'Partner' || session.role === 'Builder' ? session.builderNo : session.storeId ?? null,
|
||||
constructionPoint: session.builderNo ?? null,
|
||||
})
|
||||
}
|
||||
|
||||
@ -48,7 +48,9 @@ const roofInfoForm: SurveyDetailRequest = {
|
||||
|
||||
const basicInfoForm: SurveyBasicRequest = {
|
||||
representative: '',
|
||||
representativeId: null,
|
||||
store: null,
|
||||
storeId: null,
|
||||
constructionPoint: null,
|
||||
investigationDate: new Date().toLocaleDateString('en-CA'),
|
||||
buildingName: null,
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
import LoadMoreButton from '@/components/LoadMoreButton'
|
||||
import { useServey } from '@/hooks/useSurvey'
|
||||
import { useEffect, useState, useMemo, useRef } from 'react'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useRouter, usePathname } from 'next/navigation'
|
||||
import SearchForm from './SearchForm'
|
||||
import { useSurveyFilterStore } from '@/store/surveyFilterStore'
|
||||
@ -47,7 +47,7 @@ export default function ListTable() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<SearchForm memberRole={session?.role ?? ''} userNm={session?.userNm ?? ''} />
|
||||
<SearchForm memberRole={session?.role ?? ''} userId={session?.userId ?? ''} />
|
||||
<div className="sale-frame">
|
||||
{heldSurveyList.length > 0 ? (
|
||||
<ul className="sale-list-wrap">
|
||||
|
||||
@ -4,7 +4,7 @@ import { SEARCH_OPTIONS, SEARCH_OPTIONS_ENUM, SEARCH_OPTIONS_PARTNERS, useSurvey
|
||||
import { useRouter } from 'next/navigation'
|
||||
import { useState } from 'react'
|
||||
|
||||
export default function SearchForm({ memberRole, userNm }: { memberRole: string; userNm: string }) {
|
||||
export default function SearchForm({ memberRole, userId }: { memberRole: string; userId: string }) {
|
||||
const router = useRouter()
|
||||
const { setSearchOption, setSort, setIsMySurvey, setKeyword, reset, isMySurvey, keyword, searchOption, sort } = useSurveyFilterStore()
|
||||
const [searchKeyword, setSearchKeyword] = useState(keyword)
|
||||
@ -76,9 +76,9 @@ export default function SearchForm({ memberRole, userNm }: { memberRole: string;
|
||||
<input
|
||||
type="checkbox"
|
||||
id="ch01"
|
||||
checked={isMySurvey === userNm}
|
||||
checked={isMySurvey === userId}
|
||||
onChange={() => {
|
||||
setIsMySurvey(isMySurvey === userNm ? null : userNm)
|
||||
setIsMySurvey(isMySurvey === userId ? null : userId)
|
||||
}}
|
||||
/>
|
||||
<label htmlFor="ch01">私が書いた物件</label>
|
||||
|
||||
@ -90,7 +90,7 @@ export function useServey(id?: number): {
|
||||
isMySurvey,
|
||||
sort,
|
||||
offset,
|
||||
store: session?.storeNm,
|
||||
store: session?.storeId,
|
||||
builderNo: session?.builderNo,
|
||||
role: session?.role,
|
||||
},
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
export type SurveyBasicInfo = {
|
||||
id: number
|
||||
representative: string
|
||||
representativeId: string | null
|
||||
store: string | null
|
||||
storeId: string | null
|
||||
constructionPoint: string | null
|
||||
investigationDate: string | null
|
||||
buildingName: string | null
|
||||
@ -62,7 +64,9 @@ export type SurveyDetailInfo = {
|
||||
|
||||
export type SurveyBasicRequest = {
|
||||
representative: string
|
||||
representativeId: string | null
|
||||
store: string | null
|
||||
storeId: string | null
|
||||
constructionPoint: string | null
|
||||
investigationDate: string | null
|
||||
buildingName: string | null
|
||||
@ -120,7 +124,9 @@ export type SurveyDetailCoverRequest = {
|
||||
|
||||
export type SurveyRegistRequest = {
|
||||
representative: string
|
||||
representativeId: string | null
|
||||
store: string | null
|
||||
storeId: string | null
|
||||
constructionPoint: string | null
|
||||
investigationDate: string | null
|
||||
buildingName: string | null
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user