OrgSwitcher
En qué organización trabaja la persona. La actual con sus iniciales en la barra superior; las demás en una lista, y «Crear organización» al final.
import { OrgSwitcher } from '@sypnia/ui/react'
En esta página
Organizaciones
Código
import { useState } from 'react';
import { OrgSwitcher, toast } from '@sypnia/ui/react';
// The current organization with its initials; the others in a list; «Create organization» and its settings at the end.
export default function Orgs() {
const [org, setOrg] = useState('acme');
return <OrgSwitcher current={org} onChange={setOrg} onCreate={() => toast('Create an organization')} onSettings={() => toast('Organization settings')}
options={[{ id: 'acme', name: 'Acme', detail: 'Pro · 4 projects' }, { id: 'north', name: 'Northwind', detail: 'Free · 1 project' }, { id: 'personal', name: 'Ana Ruiz', detail: 'Personal' }]} />;
} Cuándo usarlo
Úsalo cuando
- Primero en la barra superior, antes del proyecto.
- Agrega
detailcon el plan o el número de proyectos.
No lo uses cuando
- Personas que pertenecen a una sola organización: muestra su nombre, no un selector.
Para todos
- El botón dice qué cambia y cuál es la actual: «Cambiar de organización: Acme».
- La actual va marcada en la lista; las flechas se mueven y escribir salta.
Props
| OrgSwitcher | Tipo | Por defecto |
|---|---|---|
currentobligatorio | string | |
onChangeobligatorio | (id: string) => void | |
optionsobligatorio | SwitcherOption[] | |
compact | boolean | |
createLabelThe thing to create: «organization». Defaults to `kind`. | string | |
kind | string | |
onCreateAdds «Create …» at the end of the list. | (() => void) | |
onSettingsAdds a settings entry at the end of the list («Organization settings» on the OrgSwitcher). | (() => void) | |
settingsLabelThe words of that entry. | string |