1 line
No EOL
17 KiB
JavaScript
1 line
No EOL
17 KiB
JavaScript
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,54858,e=>{"use strict";let t="/api/v1";async function r(e,t){let r=await e.text();if(!r)return t;try{let e=JSON.parse(r);return e.detail??e.message??r}catch{return r}}async function s(e,t){let r=await fetch("/api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e,password:t}),credentials:"include"});if(!r.ok){let e=Error(await r.text()||`HTTP ${r.status}`);throw e.status=r.status,e}return r.json()}async function i(e,r){let s=await fetch(`${t}${e}`,{cache:"no-store",credentials:"include"});if(!s.ok)throw Error(`API request failed: ${s.status}`);return s.json()}async function a(e,s,i,a){let n=await fetch(`${t}${e}`,{method:i,headers:{"Content-Type":"application/json"},body:JSON.stringify(a),credentials:"include"});if(!n.ok)throw Error(await r(n,`API request failed: ${n.status}`));return n.json()}async function n(e,s){let i=await fetch(`${t}${e}`,{method:"DELETE",credentials:"include"});if(!i.ok)throw Error(await r(i,`API request failed: ${i.status}`))}async function l(e,s,i){let a=await fetch(`${t}${e}`,{...i,headers:{"Content-Type":"application/json",...i?.headers??{}},credentials:"include"});if(!a.ok)throw Error(await r(a,`API request failed: ${a.status}`));return a.json()}e.s(["API_BASE",0,t,"apiDelete",0,n,"apiFetch",0,l,"apiGet",0,i,"apiSend",0,a,"login",0,s,"normalizeValidationPayload",0,function(e){return{...e,...Object.fromEntries(["contact_id","examiner_id"].map(t=>[t,e[t]||null]))}}])},66027,e=>{"use strict";let t;var r=e.i(75555),s=e.i(73911),i=e.i(40143),a=e.i(86491),n=e.i(15823),l=e.i(93803),o=e.i(19273),u=e.i(80166),c=class extends n.Subscribable{constructor(e,t){super(),this.options=t,this.#e=e,this.#t=null,this.#r=(0,l.pendingThenable)(),this.bindMethods(),this.setOptions(t)}#e;#s=void 0;#i=void 0;#a=void 0;#n;#l;#r;#t;#o;#u;#c;#h;#d;#p;#f=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){1===this.listeners.size&&(this.#s.addObserver(this),h(this.#s,this.options)?this.#y():this.updateResult(),this.#m())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return d(this.#s,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return d(this.#s,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#v(),this.#s.removeObserver(this)}setOptions(e){let t=this.options,r=this.#s;if(this.options=this.#e.defaultQueryOptions(e),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled&&"function"!=typeof this.options.enabled&&"boolean"!=typeof(0,o.resolveQueryBoolean)(this.options.enabled,this.#s))throw Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#g(),this.#s.setOptions(this.options),t._defaulted&&!(0,o.shallowEqualObjects)(this.options,t)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#s,observer:this});let s=this.hasListeners();s&&p(this.#s,r,this.options,t)&&this.#y(),this.updateResult(),s&&(this.#s!==r||(0,o.resolveQueryBoolean)(this.options.enabled,this.#s)!==(0,o.resolveQueryBoolean)(t.enabled,this.#s)||(0,o.resolveStaleTime)(this.options.staleTime,this.#s)!==(0,o.resolveStaleTime)(t.staleTime,this.#s))&&this.#x();let i=this.#R();s&&(this.#s!==r||(0,o.resolveQueryBoolean)(this.options.enabled,this.#s)!==(0,o.resolveQueryBoolean)(t.enabled,this.#s)||i!==this.#p)&&this.#Q(i)}getOptimisticResult(e){var t,r;let s=this.#e.getQueryCache().build(this.#e,e),i=this.createResult(s,e);return t=this,r=i,(0,o.shallowEqualObjects)(t.getCurrentResult(),r)||(this.#a=i,this.#l=this.options,this.#n=this.#s.state),i}getCurrentResult(){return this.#a}trackResult(e,t){return new Proxy(e,{get:(e,r)=>(this.trackProp(r),t?.(r),"promise"===r&&(this.trackProp("data"),this.options.experimental_prefetchInRender||"pending"!==this.#r.status||this.#r.reject(Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(e,r))})}trackProp(e){this.#f.add(e)}getCurrentQuery(){return this.#s}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),r=this.#e.getQueryCache().build(this.#e,t);return r.fetch().then(()=>this.createResult(r,t))}fetch(e){return this.#y({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#a))}#y(e){this.#g();let t=this.#s.fetch(this.options,e);return e?.throwOnError||(t=t.catch(o.noop)),t}#x(){this.#b();let e=(0,o.resolveStaleTime)(this.options.staleTime,this.#s);if(s.environmentManager.isServer()||this.#a.isStale||!(0,o.isValidTimeout)(e))return;let t=(0,o.timeUntilStale)(this.#a.dataUpdatedAt,e);this.#h=u.timeoutManager.setTimeout(()=>{this.#a.isStale||this.updateResult()},t+1)}#R(){return("function"==typeof this.options.refetchInterval?this.options.refetchInterval(this.#s):this.options.refetchInterval)??!1}#Q(e){this.#v(),this.#p=e,!s.environmentManager.isServer()&&!1!==(0,o.resolveQueryBoolean)(this.options.enabled,this.#s)&&(0,o.isValidTimeout)(this.#p)&&0!==this.#p&&(this.#d=u.timeoutManager.setInterval(()=>{(this.options.refetchIntervalInBackground||r.focusManager.isFocused())&&this.#y()},this.#p))}#m(){this.#x(),this.#Q(this.#R())}#b(){void 0!==this.#h&&(u.timeoutManager.clearTimeout(this.#h),this.#h=void 0)}#v(){void 0!==this.#d&&(u.timeoutManager.clearInterval(this.#d),this.#d=void 0)}createResult(e,t){let r,s=this.#s,i=this.options,n=this.#a,u=this.#n,c=this.#l,d=e!==s?e.state:this.#i,{state:y}=e,m={...y},b=!1;if(t._optimisticResults){let r=this.hasListeners(),n=!r&&h(e,t),l=r&&p(e,s,t,i);(n||l)&&(m={...m,...(0,a.fetchState)(y.data,e.options)}),"isRestoring"===t._optimisticResults&&(m.fetchStatus="idle")}let{error:v,errorUpdatedAt:g,status:x}=m;r=m.data;let R=!1;if(void 0!==t.placeholderData&&void 0===r&&"pending"===x){let e;n?.isPlaceholderData&&t.placeholderData===c?.placeholderData?(e=n.data,R=!0):e="function"==typeof t.placeholderData?t.placeholderData(this.#c?.state.data,this.#c):t.placeholderData,void 0!==e&&(x="success",r=(0,o.replaceData)(n?.data,e,t),b=!0)}if(t.select&&void 0!==r&&!R)if(n&&r===u?.data&&t.select===this.#o)r=this.#u;else try{this.#o=t.select,r=t.select(r),r=(0,o.replaceData)(n?.data,r,t),this.#u=r,this.#t=null}catch(e){this.#t=e}this.#t&&(v=this.#t,r=this.#u,g=Date.now(),x="error");let Q="fetching"===m.fetchStatus,k="pending"===x,w="error"===x,j=k&&Q,T=void 0!==r,I={status:x,fetchStatus:m.fetchStatus,isPending:k,isSuccess:"success"===x,isError:w,isInitialLoading:j,isLoading:j,data:r,dataUpdatedAt:m.dataUpdatedAt,error:v,errorUpdatedAt:g,failureCount:m.fetchFailureCount,failureReason:m.fetchFailureReason,errorUpdateCount:m.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:m.dataUpdateCount>d.dataUpdateCount||m.errorUpdateCount>d.errorUpdateCount,isFetching:Q,isRefetching:Q&&!k,isLoadingError:w&&!T,isPaused:"paused"===m.fetchStatus,isPlaceholderData:b,isRefetchError:w&&T,isStale:f(e,t),refetch:this.refetch,promise:this.#r,isEnabled:!1!==(0,o.resolveQueryBoolean)(t.enabled,e)};if(this.options.experimental_prefetchInRender){let t=void 0!==I.data,r="error"===I.status&&!t,i=e=>{r?e.reject(I.error):t&&e.resolve(I.data)},a=()=>{i(this.#r=I.promise=(0,l.pendingThenable)())},n=this.#r;switch(n.status){case"pending":e.queryHash===s.queryHash&&i(n);break;case"fulfilled":(r||I.data!==n.value)&&a();break;case"rejected":r&&I.error===n.reason||a()}}return I}updateResult(){let e=this.#a,t=this.createResult(this.#s,this.options);if(this.#n=this.#s.state,this.#l=this.options,void 0!==this.#n.data&&(this.#c=this.#s),(0,o.shallowEqualObjects)(t,e))return;this.#a=t;let r=()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,r="function"==typeof t?t():t;if("all"===r||!r&&!this.#f.size)return!0;let s=new Set(r??this.#f);return this.options.throwOnError&&s.add("error"),Object.keys(this.#a).some(t=>this.#a[t]!==e[t]&&s.has(t))};this.#k({listeners:r()})}#g(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#s)return;let t=this.#s;this.#s=e,this.#i=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#m()}#k(e){i.notifyManager.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#a)}),this.#e.getQueryCache().notify({query:this.#s,type:"observerResultsUpdated"})})}};function h(e,t){return!1!==(0,o.resolveQueryBoolean)(t.enabled,e)&&void 0===e.state.data&&("error"!==e.state.status||!1!==(0,o.resolveQueryBoolean)(t.retryOnMount,e))||void 0!==e.state.data&&d(e,t,t.refetchOnMount)}function d(e,t,r){if(!1!==(0,o.resolveQueryBoolean)(t.enabled,e)&&"static"!==(0,o.resolveStaleTime)(t.staleTime,e)){let s="function"==typeof r?r(e):r;return"always"===s||!1!==s&&f(e,t)}return!1}function p(e,t,r,s){return(e!==t||!1===(0,o.resolveQueryBoolean)(s.enabled,e))&&(!r.suspense||"error"!==e.state.status)&&f(e,r)}function f(e,t){return!1!==(0,o.resolveQueryBoolean)(t.enabled,e)&&e.isStaleByTime((0,o.resolveStaleTime)(t.staleTime,e))}e.i(47167);var y=e.i(71645),m=e.i(12598);e.i(43476);var b=y.createContext((t=!1,{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t})),v=y.createContext(!1);v.Provider;var g=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});e.s(["useQuery",0,function(e,t){return function(e,t,r){let a,n=y.useContext(v),l=y.useContext(b),u=(0,m.useQueryClient)(r),c=u.defaultQueryOptions(e);u.getDefaultOptions().queries?._experimental_beforeQuery?.(c);let h=u.getQueryCache().get(c.queryHash),d=!1!==e.subscribed;if(c._optimisticResults=n?"isRestoring":d?"optimistic":void 0,c.suspense){let e=e=>"static"===e?e:Math.max(e??1e3,1e3),t=c.staleTime;c.staleTime="function"==typeof t?(...r)=>e(t(...r)):e(t),"number"==typeof c.gcTime&&(c.gcTime=Math.max(c.gcTime,1e3))}a=h?.state.error&&"function"==typeof c.throwOnError?(0,o.shouldThrowError)(c.throwOnError,[h.state.error,h]):c.throwOnError,(c.suspense||c.experimental_prefetchInRender||a)&&!l.isReset()&&(c.retryOnMount=!1),y.useEffect(()=>{l.clearReset()},[l]);let p=!u.getQueryCache().get(c.queryHash),[f]=y.useState(()=>new t(u,c)),x=f.getOptimisticResult(c),R=!n&&d;if(y.useSyncExternalStore(y.useCallback(e=>{let t=R?f.subscribe(i.notifyManager.batchCalls(e)):o.noop;return f.updateResult(),t},[f,R]),()=>f.getCurrentResult(),()=>f.getCurrentResult()),y.useEffect(()=>{f.setOptions(c)},[c,f]),c?.suspense&&x.isPending)throw g(c,f,l);if((({result:e,errorResetBoundary:t,throwOnError:r,query:s,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&s&&(i&&void 0===e.data||(0,o.shouldThrowError)(r,[e.error,s])))({result:x,errorResetBoundary:l,throwOnError:c.throwOnError,query:h,suspense:c.suspense}))throw x.error;if(u.getDefaultOptions().queries?._experimental_afterQuery?.(c,x),c.experimental_prefetchInRender&&!s.environmentManager.isServer()&&x.isLoading&&x.isFetching&&!n){let e=p?g(c,f,l):h?.promise;e?.catch(o.noop).finally(()=>{f.updateResult()})}return c.notifyOnChangeProps?x:f.trackResult(x)}(e,c,t)}],66027)},7233,e=>{"use strict";let t=(0,e.i(75254).default)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);e.s(["Plus",0,t],7233)},45388,e=>{"use strict";var t=e.i(43476),r=e.i(66027),s=e.i(75254);let i=(0,s.default)("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),a=(0,s.default)("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),n=(0,s.default)("ClipboardList",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]),l=(0,s.default)("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]),o=(0,s.default)("FilePenLine",[["path",{d:"m18 5-2.414-2.414A2 2 0 0 0 14.172 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2",key:"142zxg"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}],["path",{d:"M8 18h1",key:"13wk12"}]]);var u=e.i(94827),c=e.i(7233),h=e.i(20286);let d=(0,s.default)("TestTubeDiagonal",[["path",{d:"M21 7 6.82 21.18a2.83 2.83 0 0 1-3.99-.01a2.83 2.83 0 0 1 0-4L17 3",key:"1ub6xw"}],["path",{d:"m16 2 6 6",key:"1gw87d"}],["path",{d:"M12 16H4",key:"1cjfip"}]]),p=(0,s.default)("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);var f=e.i(22016),y=e.i(28779),m=e.i(54858),b=e.i(82649);let v=[{label:"Neue Validierung starten",value:"Schnellstart",href:"/validations/quick-start",icon:c.Plus},{label:"Validierungen",key:"validations",href:"/validations",icon:n},{label:"Kunden",key:"customers",href:"/customers",icon:p},{label:"Geraete",key:"devices",href:"/devices",icon:h.Stethoscope},{label:"Pruefmittel",key:"equipment",href:"/equipment",icon:d}],g=[{label:"Entwuerfe",key:"validation_drafts",href:"/validations?status=ENTWURF",icon:o},{label:"Bereit zur Pruefung",key:"validation_ready",href:"/validations?status=BEREIT_ZUR_PRUEFUNG",icon:n},{label:"In Pruefung",key:"validation_in_review",href:"/validations?status=IN_PRUEFUNG",icon:l},{label:"Freigegeben",key:"validation_approved",href:"/validations?status=FREIGEGEBEN",icon:a},{label:"Ueberfaellige Revalidierungen",key:"validation_overdue",href:"/validations?overdue_only=true",icon:i}];e.s(["default",0,function(){let{token:e}=(0,y.useAuth)(),s=(0,r.useQuery)({queryKey:["dashboard",e],queryFn:()=>(0,m.apiGet)("/dashboard",e??""),enabled:!!e});return(0,t.jsxs)("div",{className:"space-y-8",children:[(0,t.jsxs)("header",{className:"rounded-lg border border-border bg-surface p-6 shadow-soft",children:[(0,t.jsxs)("div",{className:"flex flex-col justify-between gap-4 md:flex-row md:items-center",children:[(0,t.jsx)(b.BrandLogo,{}),(0,t.jsxs)("div",{className:"text-sm text-text-light",children:[(0,t.jsx)("p",{children:"Benutzer: angemeldet"}),(0,t.jsx)("p",{children:"Speicherstatus: synchronisiert"})]})]}),(0,t.jsx)("h1",{className:"mt-6 text-3xl font-semibold text-text",children:"Dashboard"}),(0,t.jsx)("p",{className:"mt-2 text-text-light",children:"Validierungsworkflow und faellige Revalidierungen."})]}),(0,t.jsx)("section",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-5",children:v.map(e=>{let r=e.icon,i="key"in e?s.data?.[e.key]??0:e.value;return(0,t.jsxs)(f.default,{href:e.href,className:"rounded-lg border border-border bg-surface p-6 shadow-soft transition hover:-translate-y-0.5 hover:border-primary/40 hover:shadow-lg",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("p",{className:"text-sm text-text-light",children:e.label}),(0,t.jsx)(r,{className:"h-5 w-5 text-primary"})]}),(0,t.jsx)("p",{className:"mt-6 text-4xl font-semibold text-text",children:i})]},e.label)})}),(0,t.jsx)("section",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-5",children:g.map(e=>{let r=e.icon;return(0,t.jsxs)(f.default,{href:e.href,className:"rounded-lg border border-border bg-surface p-5 shadow-soft transition hover:border-primary/40 hover:bg-background",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("p",{className:"text-sm text-text-light",children:e.label}),(0,t.jsx)(r,{className:"h-5 w-5 text-primary"})]}),(0,t.jsx)("p",{className:"mt-4 text-3xl font-semibold text-text",children:s.data?.[e.key]??0})]},e.key)})}),(0,t.jsxs)("section",{className:"grid gap-4 xl:grid-cols-4",children:[(0,t.jsxs)(f.default,{href:"/validations?sort_by=updated_at&sort_order=desc",className:"rounded-lg border border-border bg-surface p-6 shadow-soft transition hover:border-primary/40 hover:bg-background",children:[(0,t.jsx)("h2",{className:"text-xl font-semibold",children:"Zuletzt bearbeitet"}),(0,t.jsx)("p",{className:"mt-3 text-sm leading-6 text-text-light",children:"Aktuelle Validierungen nach Bearbeitungsdatum oeffnen."})]}),(0,t.jsxs)(f.default,{href:"/validations?overdue_only=true",className:"rounded-lg border border-border bg-surface p-6 shadow-soft transition hover:border-danger/40 hover:bg-background",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("h2",{className:"text-xl font-semibold",children:"Ueberfaellige Revalidierungen"}),(0,t.jsx)(i,{className:"h-5 w-5 text-danger"})]}),(0,t.jsx)("p",{className:"mt-4 text-3xl font-semibold text-text",children:s.data?.validation_overdue??0})]}),(0,t.jsxs)(f.default,{href:"/equipment",className:"rounded-lg border border-border bg-surface p-6 shadow-soft transition hover:border-primary/40 hover:bg-background",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("h2",{className:"text-xl font-semibold",children:"Kalibrierstatus"}),(0,t.jsx)(u.Gauge,{className:"h-5 w-5 text-primary"})]}),(0,t.jsxs)("p",{className:"mt-4 text-sm text-text-light",children:["Gruen ",s.data?.equipment_green??0," · Gelb ",s.data?.equipment_yellow??0," · Rot ",s.data?.equipment_red??0]})]}),(0,t.jsxs)(f.default,{href:"/validations?status=ABGESCHLOSSEN",className:"rounded-lg border border-border bg-surface p-6 shadow-soft transition hover:border-primary/40 hover:bg-background",children:[(0,t.jsx)("h2",{className:"text-xl font-semibold",children:"Letzte Berichte"}),(0,t.jsx)("p",{className:"mt-4 text-3xl font-semibold text-text",children:s.data?.validation_completed??0})]})]})]})}],45388)}]); |