This repository has been archived on 2026-03-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
people/src/frontend/apps/desk/src/features/teams/index.tsx
Anthony LC 0b703cda97 🚚(app-desk) move features to features folder
The features were in the app folder, app folder is where Next uses
his router system.
To avoid confusion between the folder router and the features,
we export the features in a feature folder.
2024-02-05 16:08:22 +01:00

50 lines
1.2 KiB
TypeScript

import { Button, Field, Input, Loader } from '@openfun/cunningham-react';
import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useCreateTeam } from './api/useCreateTeam';
import { useTeams } from './api/useTeams';
export const Teams = () => {
const { data, isPending } = useTeams();
const { mutate: createTeam } = useCreateTeam();
const [teamName, setTeamName] = useState('');
const { t } = useTranslation();
if (isPending) {
return (
<div>
<Loader />
</div>
);
}
return (
<>
<Field>
<Input
type="text"
label={t('Team name')}
onChange={(e) => setTeamName(e.target.value)}
/>
<Button fullWidth onClick={() => createTeam(teamName)} className="mt-s">
{t('Create Team')}
</Button>
</Field>
<section>
<ul>
{data?.results.map((post, index) => (
<li key={post.id}>
<div>
<span>
{index + 1}. {post.name}
</span>
</div>
</li>
))}
</ul>
</section>
</>
);
};