From 50bafe610401c1964d5dfc4e9582f83914a094d7 Mon Sep 17 00:00:00 2001 From: Dan Gleason Date: Thu, 19 Jan 2023 10:33:09 -0500 Subject: [PATCH] change to side bar and routes --- components/sidebar.js | 6 +- pages/contributors.js | 535 ------------------------- pages/cover.js | 348 ++++++++++++++++ pages/index.js | 908 ++++++++++++++++++++++++++---------------- 4 files changed, 911 insertions(+), 886 deletions(-) delete mode 100755 pages/contributors.js create mode 100644 pages/cover.js mode change 100644 => 100755 pages/index.js diff --git a/components/sidebar.js b/components/sidebar.js index 876ba58..3211cb1 100755 --- a/components/sidebar.js +++ b/components/sidebar.js @@ -55,7 +55,7 @@ export default function Home() {
- +
@@ -66,7 +66,7 @@ export default function Home() {

Control Panel

- +
@@ -74,7 +74,7 @@ export default function Home() {
-

Edit Order

+

Choose My Cover

diff --git a/pages/contributors.js b/pages/contributors.js deleted file mode 100755 index 304cc9c..0000000 --- a/pages/contributors.js +++ /dev/null @@ -1,535 +0,0 @@ - - -import { Button, Table, Modal, Input, Select, Upload, message, notification } from "antd"; -import { useState } from "react"; -import { EditOutlined, DeleteOutlined, InboxOutlined } from "@ant-design/icons"; -import Papa from "papaparse"; -import React from "react"; - -const { TextArea } = Input; - -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); - const [pictureSubmitted, setPictureSubmitted ] = useState(false); - // State to store parsed data - const [parsedData, setParsedData] = useState([]); - - //State to store table Column name - const [tableRows, setTableRows] = useState([]); - - //State to store the values - const [values, setValues] = useState([]); - const [modalData, setModalData] = useState(""); - const [showModal, setShowModal] = useState(false); - const [ submission, setSubmission ] = useState(""); - - const [isEditing, setIsEditing] = useState(false); - const [editingStudent, setEditingStudent] = useState(null); - const [dataSource, setDataSource] = useState([ - { - id: 1, - name: "John", - email: "john@gmail.com", - submitted: "Yes", - notes: "", - submission: "Dear Person, I love you! You're great. Much love, Dan", - picture: true - }, - { - id: 2, - name: "David", - email: "david@gmail.com", - submitted: "No", - notes: "", - submission: "Dear Person, I love you! You're awesome. Much love, Dan", - picture: false - }, - { - id: 3, - name: "James", - email: "james@gmail.com", - submitted: "No", - notes: "", - submission: "", - picture: false - }, - { - id: 4, - name: "Sam", - email: "sam@gmail.com", - submitted: "Yes", - notes: "", - submission: "Dear Person, I love you! You're sweet. Much love, Dan", - picture: false - }, - ]); - const columns = [ - { - key: "1", - title: "ID", - dataIndex: "id", - }, - { - key: "2", - title: "Name", - dataIndex: "name", - }, - { - key: "3", - title: "Email", - dataIndex: "email", - }, - { - key: "4", - title: "Submitted", - dataIndex: "submitted", - }, - { - key: "5", - title: "Submission", - dataIndex: "submission", - render: (record) => { - return ( - <> - {record !== "" ? - handleModalOpen(record)}>View Submission - : - "No Submission" - } - - ) - } - }, - { - key: "6", - title: "Picture", - dataIndex: "picture", - render: (record) => { - return ( - <> - {record !== false ? - handleViewPicture(record)}>View Picture - : - "No Picture Uploaded" - } - - ) - } - }, - { - key: "7", - title: "Notes", - dataIndex: "notes", - }, - { - key: "7", - title: "Actions", - render: (record) => { - return ( - <> - { - onEditStudent(record); - }} - /> - { - onDeleteStudent(record); - }} - style={{ color: "red", marginLeft: 12 }} - /> - - ); - }, - }, - - ]; - - - const handleChangeUpload = (info) => { - if (info.file.status !== "uploading") { - console.log(info.file, info.fileList); - - } - if (info.file.status === "done") { - message.success(`${info.file.name} file uploaded successfully`); - notification.success({ - message: 'Picture successfully uploaded', - duration: 2, - }); - setPictureSubmitted(true); - } else if (info.file.status === "error") { - message.error(`${info.file.name} file upload failed.`); - } - }; - - const handleModalClose = () => { - setShowModal(false); - }; - - const handleModalOpen = (data) => { - setModalData(data); - console.log("data is", data) - setShowModal(true); - }; - - const displaySubmission = (data) => { - return data ? data : "No message available"; - }; - - const handleViewPicture = (record) => { // dont need the dataSource record, just the pictureUrl - // get the public url of the image - var pictureUrl; - window.open(pictureUrl, '_blank'); - } - const addtoList = () => { - - console.log('values = '+ values); - - let objects = []; - - const firstValue = dataSource[dataSource.length - 1].id; - for (let i = 0; i < values.length; i ++) { - objects.push({ - id: firstValue + 1 + i, - name: values[i][1], - email: values[i][2], - address: values[i][3] - }); - - } - console.log('objects = '+ JSON.stringify(objects)) - - setDataSource([...dataSource, ...objects]); - - } - - const changeHandler = (event) => { - // Passing file data (event.target.files[0]) to parse using Papa.parse - Papa.parse(event.target.files[0], { - header: true, - skipEmptyLines: true, - complete: function (results) { - const rowsArray = []; - const valuesArray = []; - - // Iterating data to get column name and their values - results.data.map((d) => { - rowsArray.push(Object.keys(d)); - valuesArray.push(Object.values(d)); - }); - - // Parsed Data Response in array format - setParsedData(results.data); - - // Filtered Column Names - setTableRows(rowsArray[0]); - - // Filtered Values - setValues(valuesArray); - console.log('values = '+ values) - }, - }); - }; - - - - 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 onDeleteStudent = (record) => { - Modal.confirm({ - title: "Are you sure, you want to delete this student record?", - okText: "Yes", - okType: "danger", - onOk: () => { - setDataSource((pre) => { - return pre.filter((student) => student.id !== record.id); - }); - }, - }); - }; - const onEditStudent = (record) => { - setIsEditing(true); - console.log("record", record) - setEditingStudent({ ...record }); - }; - const resetEditing = () => { - setIsEditing(false); - setEditingStudent(null); - }; - - const handleOk = () => { - setIsModalVisible(false); - - const newStudent = { - id: dataSource.length + 1, - name: name, - email: email, - submitted: submitted, - submission: submission, - picture: pictureSubmitted, // starts as an empty string - notes: notes, - }; - - setDataSource([...dataSource, newStudent]); - }; - - const handleCancel = () => { - setIsModalVisible(false); - }; - - - - return ( -<> - - - OK - , - ]} - > - { displaySubmission( modalData)} - - -
-
- -
- { - resetEditing(); - }} - onOk={() => { - setDataSource((pre) => { - return pre.map((student) => { - if (student.id === editingStudent.id) { - return editingStudent; - } else { - return student; - } - }); - }); - resetEditing(); - }} - > - - { - setEditingStudent((pre) => { - return { ...pre, name: e.target.value }; - }); - }} - /> - - { - setEditingStudent((pre) => { - return { ...pre, email: e.target.value }; - }); - }} - /> - -