diff --git a/package.json b/package.json index ba8bf85e48..f052f71272 100644 --- a/package.json +++ b/package.json @@ -69,6 +69,7 @@ "@vitejs/plugin-react": "^4.3.3", "chokidar-cli": "^3.0.0", "concurrently": "^8.2.2", + "esbuild": "^0.24.0", "eslint": "8.30.0", "eslint-config-next": "^14.2.17", "eslint-plugin-import": "^2.31.0", @@ -77,14 +78,14 @@ "eslint-plugin-react": "^7.37.2", "jsdom": "^24.1.3", "only-allow": "^1.2.1", + "pluralize": "^8.0.0", "rimraf": "^5.0.10", "tsup": "^8.3.5", "turbo": "^2.2.3", "typescript": "5.3.3", - "vitest": "^1.6.0", "vite-tsconfig-paths": "^4.3.2", - "wait-on": "^8.0.1", - "esbuild": "^0.24.0" + "vitest": "^1.6.0", + "wait-on": "^8.0.1" }, "pnpm": { "overrides": { diff --git a/packages/template/package.json b/packages/template/package.json index 8cbf6a1506..7ef23e9a1a 100644 --- a/packages/template/package.json +++ b/packages/template/package.json @@ -56,6 +56,7 @@ "jose": "^5.2.2", "js-cookie": "^3.0.5", "lucide-react": "^0.378.0", + "pluralize": "^8.0.0", "oauth4webapi": "^2.10.3", "@oslojs/otp": "^1.1.0", "qrcode": "^1.5.4", diff --git a/packages/template/src/components-page/account-settings.tsx b/packages/template/src/components-page/account-settings.tsx index 61f117a9c4..c570b66b0c 100644 --- a/packages/template/src/components-page/account-settings.tsx +++ b/packages/template/src/components-page/account-settings.tsx @@ -15,6 +15,7 @@ import { ProfilePage } from "./account-settings/profile-page/profile-page"; import { SettingsPage } from './account-settings/settings/settings-page'; import { TeamCreationPage } from './account-settings/teams/team-creation-page'; import { TeamPage } from './account-settings/teams/team-page'; +import { pluralize } from "pluralize"; const Icon = ({ name }: { name: keyof typeof icons }) => { const LucideIcon = icons[name]; @@ -23,6 +24,7 @@ const Icon = ({ name }: { name: keyof typeof icons }) => { export function AccountSettings(props: { fullPage?: boolean, + entityName?: string extraItems?: ({ title: string, content: React.ReactNode, @@ -38,6 +40,7 @@ export function AccountSettings(props: { const teams = user.useTeams(); const stackApp = useStackApp(); const project = stackApp.useProject(); + const entityName = props.entityName ?? "Team"; return ( @@ -101,7 +104,7 @@ export function AccountSettings(props: { content: item.content, } as const)) || []), ...(teams.length > 0 || project.config.clientTeamCreationEnabled) ? [{ - title: t('Teams'), + title: t(`${pluralize(entityName)}`), type: 'divider', }] as const : [], ...teams.map(team => ({ @@ -110,16 +113,16 @@ export function AccountSettings(props: { {team.displayName} , type: 'item', - id: `team-${team.id}`, + id: `${entityName.toLowerCase()}-${team.id}`, content: }> , } as const)), ...project.config.clientTeamCreationEnabled ? [{ - title: t('Create a team'), + title: t(`Create a ${entityName.toLowerCase()}`), icon: , type: 'item', - id: 'team-creation', + id: `team-creation`, content: }> , diff --git a/packages/template/src/components-page/team-creation.tsx b/packages/template/src/components-page/team-creation.tsx index 6e81944138..cf4d03ffa2 100644 --- a/packages/template/src/components-page/team-creation.tsx +++ b/packages/template/src/components-page/team-creation.tsx @@ -12,11 +12,15 @@ import { FormWarningText } from "../components/elements/form-warning"; import { MaybeFullPage } from "../components/elements/maybe-full-page"; import { useTranslation } from "../lib/translations"; -export function TeamCreation(props: { fullPage?: boolean }) { +export function TeamCreation(props: { + fullPage?: boolean, + entityName?: string, + }) { const { t } = useTranslation(); + const entityName = props.entityName ? props.entityName : "Team"; const schema = yupObject({ - displayName: yupString().defined().nonEmpty(t('Please enter a team name')), + displayName: yupString().defined().nonEmpty(t(`Please enter ${entityName.toLowerCase()} name`)), }); const { register, handleSubmit, formState: { errors } } = useForm({ @@ -29,7 +33,7 @@ export function TeamCreation(props: { fullPage?: boolean }) { const navigate = app.useNavigate(); if (!project.config.clientTeamCreationEnabled) { - return ; + return ; } const onSubmit = async (data: yup.InferType) => { @@ -48,7 +52,7 @@ export function TeamCreation(props: { fullPage?: boolean }) {
- {t('Create a Team')} + {t(`Create ${entityName}`)}
string, selectedTeam?: Team, noUpdateSelectedTeam?: boolean, + entityName?: string, }; export function SelectedTeamSwitcher(props: SelectedTeamSwitcherProps) { @@ -44,6 +46,7 @@ function Inner(props: SelectedTeamSwitcherProps) { const selectedTeam = user?.selectedTeam || props.selectedTeam; const rawTeams = user?.useTeams(); const teams = useMemo(() => rawTeams?.sort((a, b) => b.id === selectedTeam?.id ? 1 : -1), [rawTeams, selectedTeam]); + const entityName = props.entityName ? props.entityName : "Team"; useEffect(() => { if (!props.noUpdateSelectedTeam && props.selectedTeam) { @@ -58,7 +61,7 @@ function Inner(props: SelectedTeamSwitcherProps) { runAsynchronouslyWithAlert(async () => { const team = teams?.find(team => team.id === value); if (!team) { - throw new Error('Team not found, this should not happen'); + throw new Error(`${entityName} not found, this should not happen`); } if (!props.noUpdateSelectedTeam) { @@ -71,14 +74,14 @@ function Inner(props: SelectedTeamSwitcherProps) { }} > - + {user?.selectedTeam ?
- {t('Current team')} + {t(`Current ${entityName.toLowerCase()}`)}
}