transcriptor-web/public/build/assets/TeamMemberManager-BrsMsdPA.js
2025-04-05 15:58:14 +02:00

2 lines
7.9 KiB
JavaScript

import{u as q,m as x,r as p,j as e,W as G}from"./app-43FwoUKv.js";import{u as H}from"./useTypedPage-_EZ6P4Xz.js";import{A as J}from"./ActionMessage-BR0zIw5R.js";import{A as C}from"./Modal-Dl0HSC4q.js";import{C as i}from"./ConfirmationModal-A-4mK9mU.js";import{D as M}from"./DangerButton--OsE_WB2.js";import{D as y}from"./DialogModal-CM2pkQ7Q.js";import{F as K}from"./FormSection-fM5DX8Wc.js";import{T as Q,I as S}from"./TextInput-CdoY_jBz.js";import{I as w}from"./InputLabel-Cl3yDvOx.js";import{P as A}from"./PrimaryButton-Gixff4KF.js";import{S as b}from"./SecondaryButton-CKdOzt0Y.js";import{S as k}from"./SectionBorder-DsOSyNBH.js";import{c as a}from"./index-C3aXnQRR.js";import"./transition-aKza8ZE9.js";import"./SectionTitle-CmR6E75W.js";function me({team:o,availableRoles:l,userPermissions:d}){const m=q(),s=x({email:"",role:null}),n=x({role:null}),h=x({}),g=x({}),[F,c]=p.useState(!1),[f,R]=p.useState(null),[L,j]=p.useState(!1),[v,u]=p.useState(null),N=H();function B(){s.post(m("team-members.store",[o]),{errorBag:"addTeamMember",preserveScroll:!0,onSuccess:()=>s.reset()})}function D(r){G.delete(m("team-invitations.destroy",[r]),{preserveScroll:!0})}function I(r){R(r),n.setData("role",r.membership.role),c(!0)}function z(){f&&n.put(m("team-members.update",[o,f]),{preserveScroll:!0,onSuccess:()=>c(!1)})}function O(){j(!0)}function E(){h.delete(m("team-members.destroy",[o,N.props.auth.user]))}function W(r){u(r)}function _(){v&&g.delete(m("team-members.destroy",[o,v]),{errorBag:"removeTeamMember",preserveScroll:!0,preserveState:!0,onSuccess:()=>u(null)})}function T(r){var t;return(t=l.find(P=>P.key===r))==null?void 0:t.name}return e.jsxs("div",{children:[d.canAddTeamMembers?e.jsxs("div",{children:[e.jsx(k,{}),e.jsxs(K,{onSubmit:B,title:"Add Team Member",description:"Add a new team member to your team, allowing them to collaborate with you.",renderActions:()=>e.jsxs(e.Fragment,{children:[e.jsx(J,{on:s.recentlySuccessful,className:"mr-3",children:"Added."}),e.jsx(A,{className:a({"opacity-25":s.processing}),disabled:s.processing,children:"Add"})]}),children:[e.jsx("div",{className:"col-span-6",children:e.jsx("div",{className:"max-w-xl text-sm text-gray-600 dark:text-gray-400",children:"Please provide the email address of the person you would like to add to this team."})}),e.jsxs("div",{className:"col-span-6 sm:col-span-4",children:[e.jsx(w,{htmlFor:"email",value:"Email"}),e.jsx(Q,{id:"email",type:"email",className:"mt-1 block w-full",value:s.data.email,onChange:r=>s.setData("email",r.currentTarget.value)}),e.jsx(S,{message:s.errors.email,className:"mt-2"})]}),l.length>0?e.jsxs("div",{className:"col-span-6 lg:col-span-4",children:[e.jsx(w,{htmlFor:"roles",value:"Role"}),e.jsx(S,{message:s.errors.role,className:"mt-2"}),e.jsx("div",{className:"relative z-0 mt-1 border border-gray-200 dark:border-gray-700 rounded-lg cursor-pointer",children:l.map((r,t)=>e.jsx("button",{type:"button",className:a("relative px-4 py-3 inline-flex w-full rounded-lg focus:z-10 focus:outline-hidden focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-2 focus:ring-indigo-500 dark:focus:ring-indigo-600",{"border-t border-gray-200 dark:border-gray-700 focus:border-none rounded-t-none":t>0,"rounded-b-none":t!=Object.keys(l).length-1}),onClick:()=>s.setData("role",r.key),children:e.jsxs("div",{className:a({"opacity-50":s.data.role&&s.data.role!=r.key}),children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:a("text-sm text-gray-600 dark:text-gray-400",{"font-semibold":s.data.role==r.key}),children:r.name}),s.data.role==r.key?e.jsx("svg",{className:"ml-2 h-5 w-5 text-green-400",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}):null]}),e.jsx("div",{className:"mt-2 text-xs text-gray-600 dark:text-gray-400",children:r.description})]})},r.key))})]}):null]})]}):null,o.team_invitations.length>0&&d.canAddTeamMembers?e.jsxs("div",{children:[e.jsx(k,{}),e.jsx("div",{className:"mt-10 sm:mt-0"}),e.jsx(C,{title:"Pending Team Invitations",description:"These people have been invited to your team and have been sent an invitation email. They may join the team by accepting the email invitation.",children:e.jsx("div",{className:"space-y-6",children:o.team_invitations.map(r=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-gray-600 dark:text-gray-400",children:r.email}),e.jsx("div",{className:"flex items-center",children:d.canRemoveTeamMembers?e.jsx("button",{className:"cursor-pointer ml-6 text-sm text-red-500 focus:outline-hidden",onClick:()=>D(r),children:"Cancel"}):null})]},r.id))})})]}):null,o.users.length>0?e.jsxs("div",{children:[e.jsx(k,{}),e.jsx("div",{className:"mt-10 sm:mt-0"}),e.jsx(C,{title:"Team Members",description:"All of the people that are part of this team.",children:e.jsx("div",{className:"space-y-6",children:o.users.map(r=>{var t;return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("img",{className:"w-8 h-8 rounded-full",src:r.profile_photo_url,alt:r.name}),e.jsx("div",{className:"ml-4 dark:text-white",children:r.name})]}),e.jsxs("div",{className:"flex items-center",children:[d.canAddTeamMembers&&l.length?e.jsx("button",{className:"ml-2 text-sm text-gray-400 underline",onClick:()=>I(r),children:T(r.membership.role)}):l.length?e.jsx("div",{className:"ml-2 text-sm text-gray-400",children:T(r.membership.role)}):null,((t=N.props.auth.user)==null?void 0:t.id)===r.id?e.jsx("button",{className:"cursor-pointer ml-6 text-sm text-red-500",onClick:O,children:"Leave"}):null,d.canRemoveTeamMembers?e.jsx("button",{className:"cursor-pointer ml-6 text-sm text-red-500",onClick:()=>W(r),children:"Remove"}):null]})]},r.id)})})})]}):null,e.jsxs(y,{isOpen:F,onClose:()=>c(!1),children:[e.jsx(y.Content,{title:"Manage Role"}),f?e.jsx("div",{children:e.jsx("div",{className:"relative z-0 mt-1 border border-gray-200 dark:border-gray-700 rounded-lg cursor-pointer",children:l.map((r,t)=>e.jsx("button",{type:"button",className:a("relative px-4 py-3 inline-flex w-full rounded-lg focus:z-10 focus:outline-hidden focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-2 focus:ring-indigo-500 dark:focus:ring-indigo-600",{"border-t border-gray-200 dark:border-gray-700 focus:border-none rounded-t-none":t>0,"rounded-b-none":t!==Object.keys(l).length-1}),onClick:()=>n.setData("role",r.key),children:e.jsxs("div",{className:a({"opacity-50":n.data.role&&n.data.role!==r.key}),children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:a("text-sm text-gray-600 dark:text-gray-400",{"font-semibold":n.data.role===r.key}),children:r.name}),n.data.role===r.key?e.jsx("svg",{className:"ml-2 h-5 w-5 text-green-400",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}):null]}),e.jsx("div",{className:"mt-2 text-xs text-gray-600 dark:text-gray-400",children:r.description})]})},r.key))})}):null,e.jsxs(y.Footer,{children:[e.jsx(b,{onClick:()=>c(!1),children:"Cancel"}),e.jsx(A,{onClick:z,className:a("ml-2",{"opacity-25":n.processing}),disabled:n.processing,children:"Save"})]})]}),e.jsxs(i,{isOpen:L,onClose:()=>j(!1),children:[e.jsx(i.Content,{title:"Leave Team",children:"Are you sure you would like to leave this team?"}),e.jsxs(i.Footer,{children:[e.jsx(b,{onClick:()=>j(!1),children:"Cancel"}),e.jsx(M,{onClick:E,className:a("ml-2",{"opacity-25":h.processing}),disabled:h.processing,children:"Leave"})]})]}),e.jsxs(i,{isOpen:!!v,onClose:()=>u(null),children:[e.jsx(i.Content,{title:"Remove Team Member",children:"Are you sure you would like to remove this person from the team?"}),e.jsxs(i.Footer,{children:[e.jsx(b,{onClick:()=>u(null),children:"Cancel"}),e.jsx(M,{onClick:_,className:a("ml-2",{"opacity-25":g.processing}),disabled:g.processing,children:"Remove"})]})]})]})}export{me as default};