Skip to content

Commit

Permalink
feat: migrate user credential list to react component
Browse files Browse the repository at this point in the history
  • Loading branch information
ironAiken2 committed Oct 18, 2024
1 parent 88112af commit 469be25
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 3 deletions.
61 changes: 61 additions & 0 deletions react/src/components/UserCredentialList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import Flex from './Flex';
import { ReloadOutlined } from '@ant-design/icons';
import { Button, Radio, theme } from 'antd';
import { useState, useTransition } from 'react';
import { useTranslation } from 'react-i18next';

const UserCredentialList: React.FC = () => {
const { t } = useTranslation();
const { token } = theme.useToken();

const [activeType, setActiveType] = useState<'active' | 'inactive'>('active');
const [isActiveTypePending, startActiveTypeTransition] = useTransition();

return (
<Flex direction="column">
<Flex
justify="between"
style={{
width: '100%',
padding: token.paddingContentVertical,
paddingLeft: token.paddingContentHorizontalSM,
paddingRight: token.paddingContentHorizontalSM,
}}
align="start"
>
<Flex gap={token.marginXS} align="start">
<Radio.Group
value={activeType}
onChange={(value) => {
startActiveTypeTransition(() => {
setActiveType(value.target.value);
});
// setPaginationState({
// current: 1,
// pageSize: paginationState.pageSize,
// });
}}
optionType="button"
buttonStyle="solid"
options={[
{
label: t('credential.Active'),
value: 'active',
},
{
label: t('credential.Inactive'),
value: 'inactive',
},
]}
/>
</Flex>
<Flex gap={token.marginXS}>
<Button icon={<ReloadOutlined />} />
<Button type="primary">{t('credential.AddCredential')}</Button>
</Flex>
</Flex>
</Flex>
);
};

export default UserCredentialList;
5 changes: 2 additions & 3 deletions react/src/pages/UserCredentialsPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import BAICard from '../BAICard';
import FlexActivityIndicator from '../components/FlexActivityIndicator';
import UserCredentialList from '../components/UserCredentialList';
import UserList from '../components/UserList';
import { createStyles } from 'antd-style';
import { CardTabListType } from 'antd/es/card';
Expand Down Expand Up @@ -48,9 +49,7 @@ const UserCredentialsPage: React.FC = () => {
}
>
{curTabKey === 'users' && <UserList />}
{curTabKey === 'credentials' && (
<div>{t('credential.Credentials')}</div>
)}
{curTabKey === 'credentials' && <UserCredentialList />}
</Suspense>
</BAICard>
);
Expand Down

0 comments on commit 469be25

Please sign in to comment.