Skip to content

Commit f25caaa

Browse files
committed
feat: add green tick for generation api key fulfilled gf-189
1 parent 34b9245 commit f25caaa

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

apps/frontend/src/modules/project-api-keys/slices/project-api-keys.slice.ts

+5
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,27 @@ import { copyToClipboard, create } from "./actions.js";
77

88
type State = {
99
dataStatus: ValueOf<typeof DataStatus>;
10+
generateKeyDataStatus: ValueOf<typeof DataStatus>;
1011
};
1112

1213
const initialState: State = {
1314
dataStatus: DataStatus.IDLE,
15+
generateKeyDataStatus: DataStatus.IDLE,
1416
};
1517

1618
const { actions, name, reducer } = createSlice({
1719
extraReducers(builder) {
1820
builder.addCase(create.pending, (state) => {
1921
state.dataStatus = DataStatus.PENDING;
22+
state.generateKeyDataStatus = DataStatus.PENDING;
2023
});
2124
builder.addCase(create.fulfilled, (state) => {
2225
state.dataStatus = DataStatus.FULFILLED;
26+
state.generateKeyDataStatus = DataStatus.FULFILLED;
2327
});
2428
builder.addCase(create.rejected, (state) => {
2529
state.dataStatus = DataStatus.REJECTED;
30+
state.generateKeyDataStatus = DataStatus.REJECTED;
2631
});
2732

2833
builder.addCase(copyToClipboard.pending, (state) => {

apps/frontend/src/pages/project/libs/components/setup-analytics-modal/setup-analytics-modal.tsx

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
Button,
3+
Icon,
34
IconButton,
45
Input,
56
Modal,
@@ -32,12 +33,16 @@ const SetupAnalyticsModal = ({
3233
}: Properties): JSX.Element => {
3334
const dispatch = useAppDispatch();
3435

35-
const { dataStatus } = useAppSelector(({ projectApiKeys }) => projectApiKeys);
36+
const { dataStatus, generateKeyDataStatus } = useAppSelector(
37+
({ projectApiKeys }) => projectApiKeys,
38+
);
3639
const { authenticatedUser } = useAppSelector(({ auth }) => auth);
3740

3841
const hasProjectApiKey = project.apiKey !== null;
3942
const hasAuthenticatedUser = authenticatedUser !== null;
4043

44+
const isKeyGenerated = generateKeyDataStatus === DataStatus.FULFILLED;
45+
4146
const isGenerateButtonDisabled = dataStatus === DataStatus.PENDING;
4247
const isCopyButtonDisabled =
4348
!hasProjectApiKey || dataStatus === DataStatus.PENDING;
@@ -129,6 +134,15 @@ const SetupAnalyticsModal = ({
129134
label="API key"
130135
name="apiKey"
131136
placeholder="No API key"
137+
{...(isKeyGenerated
138+
? {
139+
leftIcon: (
140+
<div className={styles["generated-key-indicator"]}>
141+
<Icon height={20} name="check" width={20} />
142+
</div>
143+
),
144+
}
145+
: {})}
132146
rightIcon={
133147
<IconButton
134148
iconName="clipboard"

apps/frontend/src/pages/project/libs/components/setup-analytics-modal/styles.module.css

+8
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,11 @@
4141
.list-item-text {
4242
margin: 0;
4343
}
44+
45+
.generated-key-indicator {
46+
display: flex;
47+
align-items: center;
48+
justify-content: center;
49+
min-width: 30px;
50+
color: var(--color-success);
51+
}

0 commit comments

Comments
 (0)