-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathActionRow.tsx
More file actions
57 lines (52 loc) · 1.61 KB
/
ActionRow.tsx
File metadata and controls
57 lines (52 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { DeleteOutlined, CheckCircleOutlined, StopOutlined } from '@ant-design/icons';
import React from 'react';
import { BaseButton } from '@app/components/common/BaseButton/BaseButton';
import { ActionRowContainer } from './ApiKeysTable.style';
import { ApiTableRow } from '@app/api/apiToken.api';
interface ActionRowProps {
record: ApiTableRow;
handleToggleRow: (id: number) => void;
handleDeleteRow: (id: number) => void;
isCreating?: boolean; // If record.id === -1
t: (key: string) => string;
}
export const ActionRow: React.FC<ActionRowProps> = ({
record,
handleToggleRow,
handleDeleteRow,
isCreating,
t
}) => {
if (isCreating) {
// If your record has id === -1, you might show a "Create" button or something else
return (
<ActionRowContainer>
<BaseButton className="action-btn" onClick={() => handleToggleRow(record.id)}>
{t('apiTable.create')}
</BaseButton>
</ActionRowContainer>
);
}
// Normal row: show activate/deactivate and delete
return (
<ActionRowContainer>
<BaseButton
className="action-btn"
ghost
onClick={() => handleToggleRow(record.id)}
icon={record.isActive ? <StopOutlined /> : <CheckCircleOutlined />}
>
{record.isActive ? t('apiTable.deactivate') : t('apiTable.activate')}
</BaseButton>
<div className="divider" />
<BaseButton
className="action-btn delete-btn"
danger
onClick={() => handleDeleteRow(record.id)}
icon={<DeleteOutlined />}
>
{t('apiTable.delete')}
</BaseButton>
</ActionRowContainer>
);
};