Skip to content

Commit 129c1e8

Browse files
committed
Addressing few minor comments
1 parent 61f330f commit 129c1e8

File tree

3 files changed

+20
-38
lines changed

3 files changed

+20
-38
lines changed

cats-frontend/src/app/components/navigation/navigationpills/NavigationPills.tsx

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@ const NavigationPills: React.FC<INavigationPills> = ({
99
components,
1010
isDisable,
1111
}) => {
12-
const [activeTabKey, setactiveTabKey] = useState<string>('');
12+
const [activeTabKey, setactiveTabKey] = useState<string>(components[0].value);
1313

1414
const location = useLocation();
1515

16-
//const isMobileScreen = useMediaQuery('(max-width: 786px)');
17-
1816
useEffect(() => {
1917
if (location?.search !== '') {
2018
const component = components.find(
@@ -39,15 +37,6 @@ const NavigationPills: React.FC<INavigationPills> = ({
3937
return currentComponentIndex;
4038
}, [components, activeTabKey]);
4139

42-
useEffect(() => {
43-
if (
44-
(activeTabKey === '' && components.length > 0) ||
45-
getCurrentElementIndex() === -1
46-
) {
47-
handlePillClick(components[0].value);
48-
}
49-
}, [activeTabKey, components, getCurrentElementIndex]);
50-
5140
const isActiveTabFirstPosition = () => {
5241
return getCurrentElementIndex() === 0;
5342
};
@@ -144,7 +133,8 @@ const NavigationPills: React.FC<INavigationPills> = ({
144133
<div className="mt-4">
145134
{components &&
146135
activeTabKey !== '' &&
147-
components?.map((tabComponent: any, index: number) => {
136+
components?.map((tabComponent: { value: string, component: React.ReactNode }, index: number) => {
137+
console.log("nupur -type of tabComponent: ", typeof(tabComponent));
148138
return tabComponent.value === activeTabKey ? (
149139
<div key={index}>{tabComponent.component}</div>
150140
) : null;

cats-frontend/src/app/features/applications/application/ApplicationDetails.tsx

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@ import Actions from "../../../components/action/Actions";
88
import PageContainer from "../../../components/simple/PageContainer";
99
import NavigationPills from "../../../components/navigation/navigationpills/NavigationPills";
1010
import CustomLabel from "../../../components/simple/CustomLabel";
11-
import { AppActionBtn, AppDetailsMode } from "./dto/AppDetailsMode";
1211
import { ActionItems } from "../../../components/action/ActionsConfig";
1312
import {
1413
CancelButton,
1514
SaveButton,
1615
} from "../../../components/simple/CustomButtons";
16+
import { UserMode } from "../../../helpers/requests/userMode";
17+
import { UserAction } from "../../../helpers/requests/UserAction";
1718

1819
const ApplicationDetails = () => {
1920
const [edit, setEdit] = useState(false);
20-
const [viewMode, setViewMode] = useState(AppDetailsMode.ViewMode);
21+
const [viewMode, setViewMode] = useState(UserMode.Default);
2122
const [isVisible, setIsVisible] = useState(false);
2223
const [save, setSave] = useState(false);
2324
const navComponents = getNavComponents(true);
@@ -52,15 +53,15 @@ const ApplicationDetails = () => {
5253
const handleItemClick = async (value: string) => {
5354
console.log("nupur - handleItemClick value is: ", value);
5455
switch (value) {
55-
case AppDetailsMode.ViewMode:
56+
case UserMode.Default:
5657
setEdit(false);
57-
setViewMode(AppDetailsMode.ViewMode);
58+
setViewMode(UserMode.Default);
5859
break;
59-
case AppDetailsMode.EditMode:
60+
case UserMode.EditMode:
6061
setEdit(true);
61-
setViewMode(AppDetailsMode.EditMode);
62+
setViewMode(UserMode.EditMode);
6263
break;
63-
case AppActionBtn.SAVE:
64+
case UserAction.SAVE:
6465
setSave(true);
6566
break;
6667
default:
@@ -89,7 +90,7 @@ const ApplicationDetails = () => {
8990
</div>
9091
<div className="d-flex gap-2 justify-align-center pe-2 position-relative">
9192
{/* For Action Dropdown*/}
92-
{!edit && viewMode === AppDetailsMode.ViewMode && (
93+
{!edit && viewMode === UserMode.Default && (
9394
<Actions
9495
label="Actions"
9596
items={ActionItems}
@@ -103,16 +104,16 @@ const ApplicationDetails = () => {
103104
<>
104105
<CustomLabel
105106
labelType="c-b"
106-
label={AppDetailsMode.EditMode}
107+
label={UserMode.EditMode}
107108
/>
108109
<SaveButton
109110
variant="secondary"
110-
clickHandler={() => handleItemClick(AppActionBtn.SAVE)}
111+
clickHandler={() => handleItemClick(UserAction.SAVE)}
111112
// isDisabled={savedChanges?.length > 0 ? false : true}
112113
/>
113114
<CancelButton
114115
clickHandler={() => {
115-
handleItemClick(AppActionBtn.CANCEL);
116+
handleItemClick(UserAction.CANCEL);
116117
}}
117118
/>
118119
</>
@@ -148,7 +149,7 @@ const ApplicationDetails = () => {
148149
</Button>
149150
<div className="d-flex gap-2 justify-align-center pe-2 pos-relative">
150151
{/* For Action Dropdown*/}
151-
{!edit && viewMode === AppDetailsMode.ViewMode && (
152+
{!edit && viewMode === UserMode.Default && (
152153
<Actions
153154
label="Actions"
154155
items={ActionItems}
@@ -161,20 +162,20 @@ const ApplicationDetails = () => {
161162
<>
162163
<CustomLabel
163164
labelType="c-b"
164-
label={AppDetailsMode.EditMode}
165+
label={UserMode.EditMode}
165166
/>
166167
<SaveButton
167168
variant="secondary"
168-
clickHandler={() => handleItemClick(AppActionBtn.SAVE)}
169+
clickHandler={() => handleItemClick(UserAction.SAVE)}
169170
/>
170171
<CancelButton
171-
clickHandler={() => handleItemClick(AppActionBtn.CANCEL)}
172+
clickHandler={() => handleItemClick(UserAction.CANCEL)}
172173
/>
173174
</>
174175
)}
175176
</div>
176177

177-
{viewMode === AppDetailsMode.EditMode && (
178+
{viewMode === UserMode.EditMode && (
178179
<div className="d-flex d-md-none d-lg-none d-xl-none">
179180
<Actions
180181
label="Actions"

cats-frontend/src/app/features/applications/application/dto/AppDetailsMode.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)