2025-04-02 20:42:47 -03:00
|
|
|
"use client";
|
|
|
|
|
2025-03-30 16:42:51 -03:00
|
|
|
import React, { useState } from 'react';
|
|
|
|
|
|
|
|
const groups = [
|
|
|
|
{
|
|
|
|
label: "Personal Account",
|
|
|
|
teams: [
|
|
|
|
{ label: "Alicia Koch", value: "personal" },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Teams",
|
|
|
|
teams: [
|
|
|
|
{ label: "Acme Inc.", value: "acme-inc" },
|
|
|
|
{ label: "Monsters Inc.", value: "monsters" },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
export function TeamSwitcher() {
|
|
|
|
const [open, setOpen] = useState(false);
|
|
|
|
const [showNewTeamDialog, setShowNewTeamDialog] = useState(false);
|
|
|
|
const [selectedTeam, setSelectedTeam] = useState(groups[0].teams[0]);
|
|
|
|
|
|
|
|
return (
|
2025-03-30 19:28:28 -03:00
|
|
|
<div className="relative">
|
|
|
|
<button
|
|
|
|
onClick={() => setOpen(true)}
|
|
|
|
className="flex items-center space-x-2"
|
|
|
|
>
|
|
|
|
<div className="w-8 h-8 rounded-full bg-gray-200 flex items-center justify-center">
|
|
|
|
{selectedTeam.label[0]}
|
|
|
|
</div>
|
|
|
|
<span>{selectedTeam.label}</span>
|
|
|
|
</button>
|
|
|
|
|
|
|
|
{open && (
|
|
|
|
<div className="absolute z-10 mt-2 w-56 bg-white rounded-md shadow-lg">
|
|
|
|
<div className="p-2">
|
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
placeholder="Search team..."
|
|
|
|
className="w-full p-2 border rounded"
|
|
|
|
/>
|
|
|
|
</div>
|
2025-03-30 16:42:51 -03:00
|
|
|
{groups.map((group) => (
|
2025-03-30 19:28:28 -03:00
|
|
|
<div key={group.label} className="py-1">
|
|
|
|
<p className="px-3 py-1 text-sm font-medium text-gray-500">{group.label}</p>
|
2025-03-30 16:42:51 -03:00
|
|
|
{group.teams.map((team) => (
|
2025-03-30 19:28:28 -03:00
|
|
|
<button
|
2025-03-30 16:42:51 -03:00
|
|
|
key={team.value}
|
2025-03-30 19:28:28 -03:00
|
|
|
onClick={() => {
|
2025-03-30 16:42:51 -03:00
|
|
|
setSelectedTeam(team);
|
|
|
|
setOpen(false);
|
|
|
|
}}
|
2025-03-30 19:28:28 -03:00
|
|
|
className="w-full text-left px-3 py-2 hover:bg-gray-100"
|
2025-03-30 16:42:51 -03:00
|
|
|
>
|
2025-03-30 19:28:28 -03:00
|
|
|
{team.label}
|
|
|
|
</button>
|
2025-03-30 16:42:51 -03:00
|
|
|
))}
|
2025-03-30 19:28:28 -03:00
|
|
|
</div>
|
2025-03-30 16:42:51 -03:00
|
|
|
))}
|
2025-03-30 19:28:28 -03:00
|
|
|
<div className="border-t p-2">
|
|
|
|
<button
|
|
|
|
onClick={() => {
|
|
|
|
setOpen(false);
|
|
|
|
setShowNewTeamDialog(true);
|
|
|
|
}}
|
|
|
|
className="w-full p-2 text-left hover:bg-gray-100"
|
|
|
|
>
|
|
|
|
Create Team
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
|
|
|
|
{showNewTeamDialog && (
|
|
|
|
<div className="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center">
|
|
|
|
<div className="bg-white p-4 rounded-md">
|
|
|
|
<h3 className="text-lg font-medium mb-4">Create team</h3>
|
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
placeholder="Team name"
|
|
|
|
className="w-full p-2 border rounded mb-4"
|
|
|
|
/>
|
|
|
|
<div className="flex justify-end space-x-2">
|
|
|
|
<button
|
|
|
|
onClick={() => setShowNewTeamDialog(false)}
|
|
|
|
className="px-4 py-2 border rounded"
|
|
|
|
>
|
|
|
|
Cancel
|
|
|
|
</button>
|
|
|
|
<button
|
|
|
|
onClick={() => setShowNewTeamDialog(false)}
|
|
|
|
className="px-4 py-2 bg-blue-500 text-white rounded"
|
|
|
|
>
|
|
|
|
Create
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
2025-03-30 16:42:51 -03:00
|
|
|
);
|
|
|
|
}
|