Minor UI changes to teams
This commit is contained in:
		
							parent
							
								
									4939415a48
								
							
						
					
					
						commit
						7d81a1f1fb
					
				
					 4 changed files with 81 additions and 52 deletions
				
			
		|  | @ -44,7 +44,12 @@ export default function EditTeamModal(props) { | |||
|             <UsersIcon className="h-6 w-6 text-blue-600" /> | ||||
|           </div> | ||||
|           <div className="mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left"> | ||||
|             <h3 className="text-lg leading-6 font-medium text-gray-900" id="modal-title">Edit {props.team.name}</h3> | ||||
|             <h3 className="text-lg leading-6 font-medium text-gray-900" id="modal-title">Edit the {props.team.name} team</h3> | ||||
|             <div> | ||||
|               <p className="text-sm text-gray-400"> | ||||
|                 Manage and delete your team. | ||||
|               </p> | ||||
|             </div> | ||||
|           </div> | ||||
|         </div> | ||||
|         <form> | ||||
|  |  | |||
|  | @ -50,7 +50,12 @@ export default function MemberInvitationModal(props) { | |||
|             <UsersIcon className="h-6 w-6 text-blue-600" /> | ||||
|           </div> | ||||
|           <div className="mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left"> | ||||
|             <h3 className="text-lg leading-6 font-medium text-gray-900" id="modal-title">Member Invitation</h3> | ||||
|             <h3 className="text-lg leading-6 font-medium text-gray-900" id="modal-title">Invite a new member</h3> | ||||
|             <div> | ||||
|               <p className="text-sm text-gray-400"> | ||||
|                 Invite someone to your team. | ||||
|               </p> | ||||
|             </div> | ||||
|           </div> | ||||
|         </div> | ||||
|         <form onSubmit={inviteMember}> | ||||
|  | @ -70,13 +75,13 @@ export default function MemberInvitationModal(props) { | |||
|               </select> | ||||
|             </div> | ||||
|             <div className="mb-4"> | ||||
|               <label className="mt-1"> | ||||
|                 <input type="checkbox" name="sendInviteEmail" defaultChecked id="sendInviteEmail" className="shadow-sm mr-2 focus:ring-blue-500 focus:border-blue-500  sm:text-sm border-gray-300 rounded-md" /> | ||||
|                 Send invite email | ||||
|               <label className="mt-1 text-gray-600"> | ||||
|                 <input type="checkbox" name="sendInviteEmail" defaultChecked id="sendInviteEmail" className="shadow-sm mr-2 focus:ring-blue-500 focus:border-blue-500 sm:text-sm border-gray-300 rounded-md" /> | ||||
|                 Send an invite email | ||||
|               </label> | ||||
|             </div> | ||||
|           </div> | ||||
|           {errorMessage && <p className="text-red-700 text-sm"><span class="font-bold">Error: </span>{errorMessage}</p>} | ||||
|           {errorMessage && <p className="text-red-700 text-sm"><span className="font-bold">Error: </span>{errorMessage}</p>} | ||||
|           <div className="mt-5 sm:mt-4 sm:flex sm:flex-row-reverse"> | ||||
|             <button type="submit" className="btn btn-primary"> | ||||
|               Invite | ||||
|  |  | |||
|  | @ -27,7 +27,7 @@ export default function TeamListItem(props) { | |||
|         <UsersIcon className="text-gray-400 group-hover:text-gray-500 flex-shrink-0 -mt-4 mr-2 h-6 w-6 inline"/> | ||||
|         <div className="inline-block -mt-1"> | ||||
|           <span className="font-bold text-blue-700 text-sm">{props.team.name}</span> | ||||
|           <span className="text-xs text-gray-400 font-bold -mt-1 block capitalize">{props.team.role.toLowerCase()}</span> | ||||
|           <span className="text-xs text-gray-400 -mt-1 block capitalize">{props.team.role.toLowerCase()}</span> | ||||
|         </div> | ||||
|       </div> | ||||
|       {props.team.role === 'INVITEE' && <div> | ||||
|  |  | |||
|  | @ -3,7 +3,7 @@ import prisma from '../../lib/prisma'; | |||
| import Modal from '../../components/Modal'; | ||||
| import Shell from '../../components/Shell'; | ||||
| import SettingsShell from '../../components/Settings'; | ||||
| import {useEffect, useState} from 'react'; | ||||
| import { useEffect, useState } from 'react'; | ||||
| import { useSession, getSession } from 'next-auth/client'; | ||||
| import { | ||||
|   UsersIcon, | ||||
|  | @ -13,19 +13,19 @@ import TeamListItem from "../../components/team/TeamListItem"; | |||
| 
 | ||||
| export default function Teams(props) { | ||||
| 
 | ||||
|   const [ session, loading ] = useSession(); | ||||
|   const [ teams, setTeams ] = useState([]); | ||||
|   const [ invites, setInvites ] = useState([]); | ||||
|   const [ showCreateTeamModal, setShowCreateTeamModal ] = useState(false); | ||||
|   const [session, loading] = useSession(); | ||||
|   const [teams, setTeams] = useState([]); | ||||
|   const [invites, setInvites] = useState([]); | ||||
|   const [showCreateTeamModal, setShowCreateTeamModal] = useState(false); | ||||
| 
 | ||||
|   const loadTeams = () => fetch('/api/user/membership').then( (res: any) => res.json() ).then( | ||||
|   const loadTeams = () => fetch('/api/user/membership').then((res: any) => res.json()).then( | ||||
|     (data) => { | ||||
|       setTeams(data.membership.filter( (m) => m.role !== "INVITEE" )); | ||||
|       setInvites(data.membership.filter( (m) => m.role === "INVITEE" )); | ||||
|       setTeams(data.membership.filter((m) => m.role !== "INVITEE")); | ||||
|       setInvites(data.membership.filter((m) => m.role === "INVITEE")); | ||||
|     } | ||||
|   ); | ||||
| 
 | ||||
|   useEffect( () => { loadTeams(); }, []); | ||||
|   useEffect(() => { loadTeams(); }, []); | ||||
| 
 | ||||
|   if (loading) { | ||||
|     return <p className="text-gray-400">Loading...</p>; | ||||
|  | @ -39,13 +39,13 @@ export default function Teams(props) { | |||
|       headers: { | ||||
|         'Content-Type': 'application/json' | ||||
|       } | ||||
|     }).then( () => { | ||||
|     }).then(() => { | ||||
|       loadTeams(); | ||||
|       setShowCreateTeamModal(false); | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
|   return( | ||||
|   return ( | ||||
|     <Shell heading="Teams"> | ||||
|       <Head> | ||||
|         <title>Teams | Calendso</title> | ||||
|  | @ -57,17 +57,31 @@ export default function Teams(props) { | |||
|             <div className="flex justify-between"> | ||||
|               <div> | ||||
|                 <h2 className="text-lg leading-6 font-medium text-gray-900">Your teams</h2> | ||||
|                 <p className="mt-1 text-sm text-gray-500 mb-2"> | ||||
|                 <p className="mt-1 text-sm text-gray-500 mb-4"> | ||||
|                   View, edit and create teams to organise relationships between users | ||||
|                 </p> | ||||
|                 {!(invites.length || teams.length) && <div className="border rounded text-center p-4 pt-3 m-4"> | ||||
|                   <p className="text-sm text-gray-500">Team up with other users<br /> by adding a new team</p> | ||||
|                   <UsersIcon className="text-blue-500 w-32 h-32 mx-auto"/> | ||||
|                   <button className="btn-lg btn-primary" onClick={() => setShowCreateTeamModal(true)}>New team</button> | ||||
|                 </div>} | ||||
|                 {!(invites.length || teams.length) && | ||||
|                   <div className="bg-gray-50 sm:rounded-lg"> | ||||
|                     <div className="px-4 py-5 sm:p-6"> | ||||
|                       <h3 className="text-lg leading-6 font-medium text-gray-900">Create a team to get started</h3> | ||||
|                       <div className="mt-2 max-w-xl text-sm text-gray-500"> | ||||
|                         <p>Create your first team and invite other users to work together with you.</p> | ||||
|                       </div> | ||||
|                       <div className="mt-5"> | ||||
|                         <button | ||||
|                           type="button" | ||||
|                           onClick={() => setShowCreateTeamModal(true)} | ||||
|                           className="btn btn-primary" | ||||
|                         > | ||||
|                           Create new team | ||||
|                         </button> | ||||
|                       </div> | ||||
|                     </div> | ||||
|                   </div> | ||||
|                 } | ||||
|               </div> | ||||
|               {!!(invites.length || teams.length) && <div> | ||||
|                 <button className="btn-sm btn-primary" onClick={() => setShowCreateTeamModal(true)}>New team</button> | ||||
|                 <button className="btn-sm btn-primary" onClick={() => setShowCreateTeamModal(true)}>Create new team</button> | ||||
|               </div>} | ||||
|             </div> | ||||
|             <div> | ||||
|  | @ -79,7 +93,7 @@ export default function Teams(props) { | |||
|               {!!invites.length && <div> | ||||
|                 <h2 className="text-lg leading-6 font-medium text-gray-900">Open Invitations</h2> | ||||
|                 <ul className="border px-2 rounded mt-2 mb-2 divide-y divide-gray-200"> | ||||
|                   {invites.map( (team) => <TeamListItem onChange={loadTeams} key={team.id} team={team}></TeamListItem>)} | ||||
|                   {invites.map((team) => <TeamListItem onChange={loadTeams} key={team.id} team={team}></TeamListItem>)} | ||||
|                 </ul> | ||||
|               </div>} | ||||
|             </div> | ||||
|  | @ -98,38 +112,43 @@ export default function Teams(props) { | |||
|           </div> | ||||
|         </div> | ||||
|         {showCreateTeamModal && | ||||
|         <div className="fixed z-10 inset-0 overflow-y-auto" aria-labelledby="modal-title" role="dialog" aria-modal="true"> | ||||
|           <div className="flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0"> | ||||
|             <div className="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity" aria-hidden="true"></div> | ||||
|           <div className="fixed z-10 inset-0 overflow-y-auto" aria-labelledby="modal-title" role="dialog" aria-modal="true"> | ||||
|             <div className="flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0"> | ||||
|               <div className="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity" aria-hidden="true"></div> | ||||
| 
 | ||||
|             <span className="hidden sm:inline-block sm:align-middle sm:h-screen" aria-hidden="true">​</span> | ||||
|               <span className="hidden sm:inline-block sm:align-middle sm:h-screen" aria-hidden="true">​</span> | ||||
| 
 | ||||
|             <div className="inline-block align-bottom bg-white rounded-lg px-4 pt-5 pb-4 text-left shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full sm:p-6"> | ||||
|               <div className="sm:flex sm:items-start mb-4"> | ||||
|                 <div className="mx-auto flex-shrink-0 flex items-center justify-center h-12 w-12 rounded-full bg-blue-100 sm:mx-0 sm:h-10 sm:w-10"> | ||||
|                   <UsersIcon className="h-6 w-6 text-blue-600" /> | ||||
|                 </div> | ||||
|                 <div className="mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left"> | ||||
|                   <h3 className="text-lg leading-6 font-medium text-gray-900" id="modal-title">New team</h3> | ||||
|               <div className="inline-block align-bottom bg-white rounded-lg px-4 pt-5 pb-4 text-left shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full sm:p-6"> | ||||
|                 <div className="sm:flex sm:items-start mb-4"> | ||||
|                   <div className="mx-auto flex-shrink-0 flex items-center justify-center h-12 w-12 rounded-full bg-blue-100 sm:mx-0 sm:h-10 sm:w-10"> | ||||
|                     <UsersIcon className="h-6 w-6 text-blue-600" /> | ||||
|                   </div> | ||||
|                   <div className="mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left"> | ||||
|                     <h3 className="text-lg leading-6 font-medium text-gray-900" id="modal-title">Create a new team</h3> | ||||
|                     <div> | ||||
|                       <p className="text-sm text-gray-400"> | ||||
|                         Create a new team to collaborate with users. | ||||
|                       </p> | ||||
|                     </div> | ||||
|                   </div> | ||||
|                 </div> | ||||
|                 <form onSubmit={createTeam}> | ||||
|                   <div className="mb-4"> | ||||
|                     <label htmlFor="name" className="block text-sm font-medium text-gray-700">Name</label> | ||||
|                     <input type="text" name="name" id="name" placeholder="Acme Inc." required className="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm" /> | ||||
|                   </div> | ||||
|                   <div className="mt-5 sm:mt-4 sm:flex sm:flex-row-reverse"> | ||||
|                     <button type="submit" className="btn btn-primary"> | ||||
|                       Create team | ||||
|                   </button> | ||||
|                     <button onClick={() => setShowCreateTeamModal(false)} type="button" className="btn btn-white mr-2"> | ||||
|                       Cancel | ||||
|                   </button> | ||||
|                   </div> | ||||
|                 </form> | ||||
|               </div> | ||||
|               <form onSubmit={createTeam}> | ||||
|                 <div className="mb-4"> | ||||
|                   <label htmlFor="name" className="block text-sm font-medium text-gray-700">Name</label> | ||||
|                   <input type="text" name="name" id="name" required className="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm"  /> | ||||
|                 </div> | ||||
|                 <div className="mt-5 sm:mt-4 sm:flex sm:flex-row-reverse"> | ||||
|                   <button type="submit" className="btn btn-primary"> | ||||
|                     Create team | ||||
|                   </button> | ||||
|                   <button onClick={() => setShowCreateTeamModal(false)} type="button" className="btn btn-white mr-2"> | ||||
|                     Cancel | ||||
|                   </button> | ||||
|                 </div> | ||||
|               </form> | ||||
|             </div> | ||||
|           </div> | ||||
|         </div> | ||||
|         } | ||||
|       </SettingsShell> | ||||
|     </Shell> | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 Bailey Pumfleet
						Bailey Pumfleet