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