(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2096],{16383:function(e,a,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/dataset/[datasetId]/[collectionName]/[...subfieldNames]",function(){return t(26052)}])},26052:function(e,a,t){"use strict";t.r(a);var l=t(24246),s=t(92222),i=t(59003),o=t(39158),n=t(30454),d=t.n(n),r=t(47215),c=t.n(r),u=t(86677),m=t(27378),f=t(77213),h=t(77830),g=t(58754),p=t(47935),v=t(66112),x=t(69828),b=t(41966),j=t(76252),w=t(69435);let C=(0,s.Cl)(),R=()=>(0,l.jsx)(o.gCW,{mt:6,p:10,spacing:4,borderRadius:"base",maxW:"70%","data-testid":"no-results-notice",alignSelf:"center",margin:"auto",textAlign:"center",children:(0,l.jsx)(o.gCW,{children:(0,l.jsx)(o.xvT,{fontSize:"md",fontWeight:"600",children:"No fields found."})})});a.default=()=>{let e=(0,u.useRouter)(),[a]=(0,b.TG)(),t=decodeURIComponent(e.query.datasetId),n=decodeURIComponent(e.query.collectionName),r=e.query.subfieldNames.map(decodeURIComponent),{isLoading:_,data:y}=(0,b.oM)(t),N=(0,m.useMemo)(()=>(null==y?void 0:y.collections)||[],[y]).find(e=>e.name===n),k=(0,m.useMemo)(()=>(null==N?void 0:N.fields)||[],[N]),M=(0,m.useMemo)(()=>{let e=k;return r.forEach(a=>{let t=e.find(e=>e.name===a);e=(null==t?void 0:t.fields)||[]}),e},[k,r]),[I,T]=(0,m.useState)(),E=(0,m.useCallback)(e=>{let{dataCategory:t,field:l}=e,s=l.data_categories||[],i=(0,w.Fk)({dataset:y,collectionName:n,subfields:[...r,l.name]}),o=d()(y);c()(o,"".concat(i,".data_categories"),[...s,t]),a(o)},[y,a,n,r]),q=(0,m.useCallback)(e=>{let{dataCategory:t,field:l}=e,s=l.data_categories||[],i=(0,w.Fk)({dataset:y,collectionName:n,subfields:[...r,null==l?void 0:l.name]}),o=d()(y);c()(o,"".concat(i,".data_categories"),s.filter(e=>e!==t)),a(o)},[y,a,n,r]),z=(0,m.useCallback)(a=>{let l=[...r.map(encodeURIComponent),a.name];e.push({pathname:h.y1,query:{datasetId:t,collectionName:n,subfieldNames:l}})},[t,e,n,r]),F=(0,m.useMemo)(()=>[C.accessor(e=>e.name,{id:"name",cell:e=>{var a;let t=e.row.original.fields&&(null===(a=e.row.original.fields)||void 0===a?void 0:a.length)>0;return(0,l.jsx)(p.G3,{fontWeight:t?"semibold":"normal",value:e.getValue()})},header:e=>(0,l.jsx)(p.Rr,{value:"Field Name",...e}),size:180}),C.accessor(e=>{var a;return null===(a=e.fides_meta)||void 0===a?void 0:a.data_type},{id:"type",cell:e=>e.getValue()?(0,l.jsx)(p.A4,{value:e.getValue()}):(0,l.jsx)(p.G3,{value:void 0}),header:e=>(0,l.jsx)(p.Rr,{value:"Type",...e}),size:80}),C.accessor(e=>e.description,{id:"description",cell:e=>(0,l.jsx)(p.G3,{value:e.getValue(),cellProps:e}),header:e=>(0,l.jsx)(p.Rr,{value:"Description",...e}),size:300,meta:{showHeaderMenu:!0}}),C.accessor(e=>e.data_categories,{id:"data_categories",cell:e=>{var a;let t=e.row.original;return!(e.row.original.fields&&(null===(a=e.row.original.fields)||void 0===a?void 0:a.length)>0)&&(0,l.jsx)(v.Z,{selectedTaxonomies:e.getValue()||[],onAddTaxonomy:e=>E({dataCategory:e,field:t}),onRemoveTaxonomy:e=>q({dataCategory:e,field:t})})},header:e=>(0,l.jsx)(p.Rr,{value:"Data categories",...e}),size:300,meta:{disableRowClick:!0}}),C.display({id:"actions",header:"Actions",cell:e=>{let{row:a}=e,t=a.original;return(0,l.jsx)(o.Ugi,{spacing:0,"data-testid":"field-".concat(t.name),children:(0,l.jsx)(o.wpx,{size:"small",icon:(0,l.jsx)(o.dY8,{}),onClick:()=>{W(t),G(!0)},children:"Edit"})})},meta:{disableRowClick:!0}})],[E,q]),S=(0,m.useMemo)(()=>I?M.filter(e=>e.name.toLowerCase().includes(I.toLowerCase())):M,[M,I]),U=(0,i.b7)({getCoreRowModel:(0,s.sC)(),getFilteredRowModel:(0,s.vL)(),getSortedRowModel:(0,s.tj)(),columns:F,data:S,columnResizeMode:"onChange"}),[A,G]=(0,m.useState)(!1),[V,W]=(0,m.useState)(),Z=(0,m.useMemo)(()=>{let e=[{title:"All datasets",href:h.$m},{title:t,href:{pathname:h.o5,query:{datasetId:t}},icon:x.Y[1]},{title:n,icon:x.Y[2],href:{pathname:h.RF,query:{datasetId:t,collectionName:n}}}];return r.forEach((a,l)=>{e.push({title:a,href:l<r.length-1?{pathname:h.y1,query:{datasetId:t,collectionName:n,subfieldNames:r.slice(0,l+1).map(encodeURIComponent)}}:void 0,icon:x.Y[3]})}),e},[t,n,r]);return(0,l.jsxs)(f.Z,{title:"Dataset - ".concat(t),children:[(0,l.jsx)(g.Z,{heading:"Datasets",breadcrumbItems:Z}),_?(0,l.jsx)(p.I4,{rowHeight:36,numRows:15}):(0,l.jsxs)(o.xuv,{"data-testid":"fields-table",children:[(0,l.jsx)(p.Q$,{children:(0,l.jsx)(p.HO,{globalFilter:I,setGlobalFilter:T,placeholder:"Search",testid:"fields-search"})}),(0,l.jsx)(p.ZK,{tableInstance:U,emptyTableNotice:(0,l.jsx)(R,{}),onRowClick:z,getRowIsClickable:e=>{var a;return!!(e.fields&&(null===(a=e.fields)||void 0===a?void 0:a.length)>0)}}),(0,l.jsx)(j.Z,{isOpen:A,onClose:()=>{G(!1),W(void 0)},field:V,dataset:y,collectionName:n,subfields:r})]})]})}}},function(e){e.O(0,[454,5487,549,2888,9774,179],function(){return e(e.s=16383)}),_N_E=e.O()}]);