1 line
No EOL
7.7 KiB
JavaScript
1 line
No EOL
7.7 KiB
JavaScript
import{t as e}from"../chunks/createLucideIcon-CYyWUN7r.js";import{n as t,t as n}from"../chunks/x-CV132X1X.js";import{n as ee,t as te}from"../chunks/loader-circle-DBP4Qhm5.js";import{n as ne,r as re,t as ie}from"../chunks/StatusBadge-CZaj6wAi.js";import{t as r}from"../chunks/inbox-CWQqWjak.js";import{Fragment as i,createBlock as a,createCommentVNode as o,createElementBlock as s,createElementVNode as c,createTextVNode as l,createVNode as u,normalizeClass as d,openBlock as f,ref as p,renderList as m,toDisplayString as h,unref as g,watch as _,withCtx as v,withModifiers as y}from"vue";import{Link as b,useForm as x,usePage as S}from"@inertiajs/vue3";import{AppLayout as C,Button as w,Dialog as T,DialogContent as E,DialogDescription as D,DialogFooter as O,DialogHeader as k,DialogTitle as A,EmptyState as j,FormField as M,PageHeader as N,PersonAvatar as P,Textarea as F,formatDate as I,formatRelative as L,toast as R}from"@inhaus/ui";var z=e({name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]}),B=e({name:`message-square-text`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]}),V={"aria-labelledby":`offen`,class:`ih:mb-8`},H={id:`offen`,class:`ih:mb-3 ih:text-sm ih:font-semibold`},ae={class:`ih:text-muted-foreground`},U={key:0,class:`ih:grid ih:gap-3`},W=[`src`,`alt`],G={class:`ih:grid ih:min-w-0 ih:gap-1.5`},K={class:`ih:flex ih:flex-wrap ih:items-center ih:gap-2`},q={class:`ih:flex ih:items-center ih:gap-2 ih:text-sm`},J={class:`ih:font-medium`},oe={key:0,class:`ih:text-muted-foreground`},se={class:`ih:text-xs ih:text-muted-foreground`},ce={class:`ih:flex ih:flex-wrap ih:gap-x-4 ih:gap-y-1 ih:text-sm ih:text-muted-foreground`},le={class:`ih:inline-flex ih:items-center ih:gap-1`},ue={key:0,class:`ih:inline-flex ih:items-center ih:gap-1`},de={key:0,class:`ih:flex ih:gap-1.5 ih:text-sm`},fe={key:1,class:`ih:text-xs ih:text-muted-foreground`},pe={class:`ih:flex ih:gap-2 ih:sm:flex-col`},me={key:1,class:`ih:rounded-lg ih:border ih:bg-card`},he={key:0,"aria-labelledby":`zuletzt`},ge={class:`ih:divide-y ih:rounded-lg ih:border ih:bg-card`},_e={class:`ih:text-muted-foreground`},ve={class:`ih:ml-auto ih:text-xs ih:text-muted-foreground`},Y={__name:`Requests`,props:{pending:{type:Array,required:!0},recent:{type:Array,default:()=>[]},labels:{type:Object,required:!0}},setup(e){let Y=S();_(()=>Y.props.flash?.status,e=>e&&R.success(e),{immediate:!0});let X=p(null),Z=x({note:``});function Q(e,t){Z.reset(),Z.clearErrors(),X.value={request:e,accept:t}}function ye(){let{request:e,accept:t}=X.value;Z.post(`/verleih/anfragen/${e.id}/${t?`zusagen`:`absagen`}`,{preserveScroll:!0,onSuccess:()=>X.value=null})}let $=e=>[e.from?`ab ${I(e.from)}`:null,e.until?`bis ${I(e.until)}`:null].filter(Boolean).join(` `);return(p,_)=>(f(),a(g(C),{title:`Anfragen`},{default:v(()=>[u(g(b),{href:`/verleih`,class:`ih:mb-4 ih:inline-flex ih:items-center ih:gap-1 ih:text-sm ih:font-medium ih:text-muted-foreground ih:hover:text-foreground`},{default:v(()=>[u(g(ee),{class:`ih:size-4`}),l(` `+h(e.labels.title),1)]),_:1}),u(g(N),{title:`Anfragen`,description:`Zusagen trägt das ${e.labels.singular} gleich als verliehen ein – mit Wunschort und Person. Die anfragende Person wird benachrichtigt.`},null,8,[`description`]),c(`section`,V,[c(`h2`,H,[_[3]||=l(`Offen `,-1),c(`span`,ae,`(`+h(e.pending.length)+`)`,1)]),e.pending.length?(f(),s(`div`,U,[(f(!0),s(i,null,m(e.pending,e=>(f(),s(`article`,{key:e.id,class:`ih:grid ih:gap-4 ih:rounded-lg ih:border ih:bg-card ih:p-4 ih:sm:grid-cols-[7rem_minmax(0,1fr)_auto] ih:sm:items-center`},[u(g(b),{href:e.item?.url??`#`,class:`ih:grid ih:aspect-[4/3] ih:w-28 ih:place-items-center ih:overflow-hidden ih:rounded-md ih:bg-muted ih:p-1.5`},{default:v(()=>[e.item?.thumb_url?(f(),s(`img`,{key:0,src:e.item.thumb_url,alt:e.item.title,class:`ih:size-full ih:object-contain`},null,8,W)):(f(),a(g(re),{key:1,class:`ih:size-6 ih:text-muted-foreground`}))]),_:2},1032,[`href`]),c(`div`,G,[c(`div`,K,[u(g(b),{href:e.item?.url??`#`,class:`ih:font-semibold ih:hover:underline`},{default:v(()=>[l(h(e.item?.title),1)]),_:2},1032,[`href`]),e.item?(f(),a(ie,{key:0,lent:e.item.lent,class:`ih:border`},null,8,[`lent`])):o(``,!0)]),c(`p`,q,[u(g(P),{person:e.user,class:`ih:size-6`},null,8,[`person`]),c(`span`,null,[c(`span`,J,h(e.user?.name),1),e.user?.department?(f(),s(`span`,oe,` · `+h(e.user.department),1)):o(``,!0)]),c(`span`,se,h(g(L)(e.created_at)),1)]),c(`p`,ce,[c(`span`,le,[u(g(ne),{class:`ih:size-3.5`}),l(` `+h(e.location),1)]),$(e)?(f(),s(`span`,ue,[u(g(t),{class:`ih:size-3.5`}),l(` `+h($(e)),1)])):o(``,!0)]),e.message?(f(),s(`p`,de,[u(g(B),{class:`ih:mt-0.5 ih:size-3.5 ih:shrink-0 ih:text-muted-foreground`}),l(` „`+h(e.message)+`“`,1)])):o(``,!0),e.item?.lent?(f(),s(`p`,fe,`Gerade verliehen`+h(e.item.location?` (${e.item.location})`:``)+` – eine Zusage trägt den neuen Ort ein.`,1)):o(``,!0)]),c(`div`,pe,[u(g(w),{onClick:t=>Q(e,!0)},{default:v(()=>[u(g(z)),_[4]||=l(` Zusagen`,-1)]),_:1},8,[`onClick`]),u(g(w),{variant:`outline`,onClick:t=>Q(e,!1)},{default:v(()=>[u(g(n)),_[5]||=l(` Absagen`,-1)]),_:1},8,[`onClick`])])]))),128))])):(f(),s(`div`,me,[u(g(j),{icon:g(r),title:`Keine offenen Anfragen`,text:`Neue Anfragen kommen im Portal und per E-Mail.`},null,8,[`icon`])]))]),e.recent.length?(f(),s(`section`,he,[_[6]||=c(`h2`,{id:`zuletzt`,class:`ih:mb-3 ih:text-sm ih:font-semibold`},`Zuletzt beantwortet`,-1),c(`ul`,ge,[(f(!0),s(i,null,m(e.recent,e=>(f(),s(`li`,{key:e.id,class:`ih:flex ih:flex-wrap ih:items-center ih:gap-x-3 ih:gap-y-1 ih:px-4 ih:py-2.5 ih:text-sm`},[u(g(b),{href:e.item?.url??`#`,class:`ih:font-medium ih:hover:underline`},{default:v(()=>[l(h(e.item?.title),1)]),_:2},1032,[`href`]),c(`span`,_e,h(e.user?.name)+` · `+h(e.location),1),c(`span`,{class:d([`ih:rounded-full ih:px-2 ih:py-0.5 ih:text-xs ih:font-medium`,e.status===`accepted`?`ih:bg-brand-soft ih:text-brand-text`:`ih:bg-muted ih:text-muted-foreground`])},h(e.status_label),3),c(`span`,ve,h(e.decider?`${e.decider.name}, `:``)+h(g(I)(e.decided_at??e.created_at)),1)]))),128))])])):o(``,!0),u(g(T),{open:!!X.value,"onUpdate:open":_[2]||=e=>!e&&(X.value=null)},{default:v(()=>[X.value?(f(),a(g(E),{key:0,class:`ih:sm:max-w-md`},{default:v(()=>[u(g(k),null,{default:v(()=>[u(g(A),null,{default:v(()=>[l(h(X.value.accept?`Zusagen`:`Absagen`)+`: `+h(X.value.request.item?.title),1)]),_:1}),u(g(D),null,{default:v(()=>[X.value.accept?(f(),s(i,{key:0},[l(`Wird als verliehen an `+h(X.value.request.user?.name)+` nach „`+h(X.value.request.location)+`“ eingetragen.`,1)],64)):(f(),s(i,{key:1},[l(h(X.value.request.user?.name)+` bekommt die Absage im Portal und per E-Mail.`,1)],64))]),_:1})]),_:1}),c(`form`,{id:`verleih-entscheidung`,onSubmit:y(ye,[`prevent`])},[u(g(M),{id:`vl-note`,label:`Hinweis (optional)`,error:g(Z).errors.note||g(Z).errors.status},{default:v(()=>[u(g(F),{id:`vl-note`,modelValue:g(Z).note,"onUpdate:modelValue":_[0]||=e=>g(Z).note=e,rows:`3`,maxlength:`1000`,placeholder:X.value.accept?`z. B. Wir bringen es am Montag vorbei.`:`z. B. Ist bis Ende März schon vergeben.`},null,8,[`modelValue`,`placeholder`])]),_:1},8,[`error`])],32),u(g(O),null,{default:v(()=>[u(g(w),{variant:`outline`,onClick:_[1]||=e=>X.value=null},{default:v(()=>[..._[7]||=[l(`Abbrechen`,-1)]]),_:1}),u(g(w),{type:`submit`,form:`verleih-entscheidung`,variant:X.value.accept?`default`:`destructive`,disabled:g(Z).processing},{default:v(()=>[g(Z).processing?(f(),a(g(te),{key:0,class:`ih:animate-spin`})):o(``,!0),l(` `+h(X.value.accept?`Zusagen`:`Absagen`),1)]),_:1},8,[`variant`,`disabled`])]),_:1})]),_:1})):o(``,!0)]),_:1},8,[`open`])]),_:1}))}};export{Y as default}; |