Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
dcgleason committed Jan 2, 2023
1 parent 490569b commit c3feb45
Showing 1 changed file with 73 additions and 18 deletions.
91 changes: 73 additions & 18 deletions pages/contributors.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


import { Button, Table, Modal, Input } from "antd";
import { Button, Table, Modal, Input, Select } from "antd";
import { useState } from "react";
import { EditOutlined, DeleteOutlined } from "@ant-design/icons";
import Papa from "papaparse";
Expand All @@ -12,6 +12,7 @@ const CSV = () => {
const [isModalVisible, setIsModalVisible] = useState(false);
const [name, setName] = useState("");
const [email, setEmail] = useState("");
const [notes, setNotes] = useState("");
const [submitted, setSubmitted] = useState("");
const [newStudent, setNewStudent] = useState(null);
// State to store parsed data
Expand All @@ -31,24 +32,28 @@ const CSV = () => {
name: "John",
email: "[email protected]",
submitted: "Yes",
notes: "",
},
{
id: 2,
name: "David",
email: "[email protected]",
submitted: "No",
notes: "",
},
{
id: 3,
name: "James",
email: "[email protected]",
submitted: "No",
notes: "",
},
{
id: 4,
name: "Sam",
email: "[email protected]",
submitted: "Yes",
notes: "",
},
]);
const columns = [
Expand All @@ -74,6 +79,11 @@ const CSV = () => {
},
{
key: "5",
title: "Notes",
dataIndex: "notes",
},
{
key: "6",
title: "Actions",
render: (record) => {
return (
Expand All @@ -93,6 +103,7 @@ const CSV = () => {
);
},
},

];


Expand Down Expand Up @@ -151,16 +162,16 @@ const CSV = () => {
const onAddStudent = () => {
setIsModalVisible(true);

const randomNumber = parseInt(Math.random() * 1000);
const newStudent = {
id: dataSource[dataSource.length - 1].id + 1,
name: "Name " + randomNumber,
email: randomNumber + "@gmail.com",
address: "Address " + randomNumber,
};
setDataSource((pre) => {
return [...pre, newStudent];
});
// const randomNumber = parseInt(Math.random() * 1000);
// const newStudent = {
// id: dataSource[dataSource.length - 1].id + 1,
// name: "Name " + randomNumber,
// email: randomNumber + "@gmail.com",
// address: "Address " + randomNumber,
// };
// setDataSource((pre) => {
// return [...pre, newStudent];
// });
};
const onDeleteStudent = (record) => {
Modal.confirm({
Expand All @@ -176,6 +187,7 @@ const CSV = () => {
};
const onEditStudent = (record) => {
setIsEditing(true);
console.log("record", record)
setEditingStudent({ ...record });
};
const resetEditing = () => {
Expand All @@ -185,9 +197,17 @@ const CSV = () => {

const handleOk = () => {
setIsModalVisible(false);


}

const newStudent = {
id: dataSource.length + 1,
name: name,
email: email,
submitted: submitted,
notes: notes,
};

setDataSource([...dataSource, newStudent]);
};

const handleCancel = () => {
setIsModalVisible(false);
Expand Down Expand Up @@ -238,11 +258,30 @@ const CSV = () => {
});
}}
/>
<Input
value={editingStudent?.address}
<Select
value={editingStudent?.submitted}
onChange={(value) => {
console.log("editingStudent", editingStudent);
setEditingStudent((pre) => {
return { ...pre, submitted: value };
});
}}
options={[
{
value: 'Yes',
label: 'Yes',
},
{
value: 'No',
label: 'No',
}
]}
/>
<Input
value={editingStudent?.notes}
onChange={(e) => {
setEditingStudent((pre) => {
return { ...pre, address: e.target.value };
return { ...pre, notes: e.target.value };
});
}}
/>
Expand All @@ -256,7 +295,23 @@ const CSV = () => {
>
<Input placeholder="Name" value={name} onChange={(e) => setName(e.target.value)}/>
<Input placeholder="Email" value={email} onChange={(e) => setEmail(e.target.value)}/>
<Input placeholder="Submitted" value={submitted} onChange={(e) => setSubmitted(e.target.value)} />
<Select
defaultValue="Yes"
style={{ width: 120 }}
onChange={(value) => setSubmitted(value)}
allowClear
options={[
{
value: 'yes',
label: 'Yes',
},
{
value: 'no',
label: 'No',
}
]}
/>
<Input placeholder="Notes" value={notes} onChange={(e) => setNotes(e.target.value)} />
</Modal>
</header>
</div>
Expand Down

0 comments on commit c3feb45

Please sign in to comment.