42 lines
1.7 KiB
TypeScript
42 lines
1.7 KiB
TypeScript
import { useAppData } from "~/utils/data/useAppData";
|
|
import { ChevronsUpDown } from "~/components/ui/icons/vendor";
|
|
|
|
interface Props {
|
|
onOpenCommandPalette: () => void;
|
|
}
|
|
|
|
export default function TenantSelect({ onOpenCommandPalette }: Props) {
|
|
const appData = useAppData();
|
|
if (!appData.currentTenant) {
|
|
return null;
|
|
}
|
|
return (
|
|
<>
|
|
<button type="button" onClick={onOpenCommandPalette} className="group flex shrink-0 bg-slate-800 p-4 focus:outline-hidden">
|
|
<div className="group block w-full shrink-0">
|
|
<div className="flex items-center justify-between">
|
|
<div className="flex items-center truncate text-left">
|
|
{appData?.currentTenant?.icon ? (
|
|
<img
|
|
className="inline-block h-9 w-9 shrink-0 rounded-full bg-gray-500 shadow-2xs"
|
|
src={appData?.currentTenant?.icon}
|
|
alt={appData?.currentTenant?.name}
|
|
/>
|
|
) : (
|
|
<span className="bg-primary inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full">
|
|
<span className="text-primary-foreground text-sm font-medium leading-none">{appData?.currentTenant?.name.substring(0, 1)}</span>
|
|
</span>
|
|
)}
|
|
<div className="ml-3 truncate">
|
|
<p className="text-sm font-medium text-gray-200 group-hover:text-white">{appData?.currentTenant?.name}</p>
|
|
<p className="truncate text-xs font-medium text-gray-300 group-hover:text-gray-200">{appData?.user.email}</p>
|
|
</div>
|
|
</div>
|
|
<ChevronsUpDown className="text-muted-foreground h-5 w-5 group-hover:text-white" />
|
|
</div>
|
|
</div>
|
|
</button>
|
|
</>
|
|
);
|
|
}
|