Skip to content

Commit c92a6e6

Browse files
committed
Fix warnings and deprecated menu
1 parent c509c87 commit c92a6e6

File tree

4 files changed

+13
-31
lines changed

4 files changed

+13
-31
lines changed

apps/question-service/src/app/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ export default function Home() {
180180
dataIndex: "categories",
181181
key: "categories",
182182
render: (categories: string[]) =>
183-
categories.map((category) => <Tag>{category}</Tag>),
183+
categories.map((category) => <Tag key={category}>{category}</Tag>),
184184
},
185185
{
186186
title: "Difficulty",
@@ -363,6 +363,7 @@ export default function Home() {
363363
</div>
364364
<div className="content-table">
365365
<Table
366+
rowKey="id"
366367
dataSource={questions}
367368
columns={columns}
368369
loading={isLoading}

apps/question-service/src/app/question/[id]/page.tsx

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
Row,
1111
TableProps,
1212
Tag,
13+
Select,
1314
} from "antd";
1415
import { Content } from "antd/es/layout/layout";
1516
import {
@@ -55,7 +56,7 @@ export default function Home() {
5556
const [complexity, setComplexity] = useState<string | undefined>(undefined);
5657
const [categories, setCategories] = useState<string[]>([]); // Store the selected filter categories
5758
const [description, setDescription] = useState<string | undefined>(undefined);
58-
const [selectedItem, setSelectedItem] = useState("Python"); // State to hold the selected menu item
59+
const [selectedItem, setSelectedItem] = useState("python"); // State to hold the selected language item
5960

6061
// When code editor page is initialised, fetch the particular question, and display in code editor
6162
useEffect(() => {
@@ -71,25 +72,6 @@ export default function Home() {
7172
});
7273
}, [docRefId]);
7374

74-
// Function to handle the item selection
75-
const handleMenuClick = (e: any) => {
76-
const selected = ProgrammingLanguageOptions.find(
77-
(item) => item.key === e.key
78-
);
79-
if (selected) {
80-
setSelectedItem(selected.label);
81-
}
82-
};
83-
84-
// Menu component
85-
const menu = (
86-
<Menu onClick={handleMenuClick}>
87-
{ProgrammingLanguageOptions.map((item) => (
88-
<Menu.Item key={item.key}>{item.label}</Menu.Item>
89-
))}
90-
</Menu>
91-
);
92-
9375
return (
9476
<div>
9577
{contextHolder}
@@ -179,13 +161,12 @@ export default function Home() {
179161
<text className="language-text">
180162
Select Language:&nbsp;
181163
</text>
182-
<Dropdown
164+
<Select
183165
className="select-language-button"
184-
overlay={menu}
185-
trigger={["click"]}
186-
>
187-
<Button>{selectedItem}</Button>
188-
</Dropdown>
166+
defaultValue={selectedItem}
167+
onSelect={(val) => setSelectedItem(val)}
168+
options={ProgrammingLanguageOptions}
169+
/>
189170
</div>
190171
</div>
191172
<div className="code-editor-code-div">

apps/question-service/src/app/question/[id]/styles.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@
164164
}
165165

166166
.select-language-button {
167-
// margin-left: 10px;
167+
width: max-content;
168168
}
169169

170170
.session-details-title {

apps/question-service/src/utils/SelectOptions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,15 @@ export const OrderOption = [
127127

128128
export const ProgrammingLanguageOptions = [
129129
{
130-
key: "1",
130+
value: "python",
131131
label: "Python",
132132
},
133133
{
134-
key: "2",
134+
value: "java",
135135
label: "Java",
136136
},
137137
{
138-
key: "3",
138+
value: "c++",
139139
label: "C++",
140140
},
141141
];

0 commit comments

Comments
 (0)