diff --git a/contracts/EventManager.sol b/contracts/EventManager.sol
index f7033a9..142bd86 100644
--- a/contracts/EventManager.sol
+++ b/contracts/EventManager.sol
@@ -12,7 +12,6 @@ contract EventManager {
address creator;
string name;
string location;
- uint date;
uint startTime;
uint endTime;
string description;
@@ -26,7 +25,6 @@ contract EventManager {
uint indexed eventId,
address indexed creator,
string indexed location,
- uint date,
uint startTime,
uint endTime,
uint price
@@ -37,7 +35,6 @@ contract EventManager {
uint indexed eventId,
address indexed creator,
string indexed location,
- uint date,
uint startTime,
uint endTime,
uint price
@@ -51,7 +48,6 @@ contract EventManager {
function createEvent(
string memory name,
string memory location,
- uint date,
uint startTime,
uint endTime,
string memory description,
@@ -65,7 +61,6 @@ contract EventManager {
creator: msg.sender,
name: name,
location: location,
- date: date,
startTime: startTime,
endTime: endTime,
description: description,
@@ -79,7 +74,6 @@ contract EventManager {
currentEventId,
msg.sender,
location,
- date,
startTime,
endTime,
price
@@ -90,7 +84,6 @@ contract EventManager {
uint eventId,
string memory name,
string memory location,
- uint date,
uint startTime,
uint endTime,
string memory description,
@@ -112,10 +105,6 @@ contract EventManager {
eventToUpdate.location = location;
}
- if (date != eventToUpdate.date) {
- eventToUpdate.date = date;
- }
-
if (startTime != eventToUpdate.startTime) {
eventToUpdate.startTime = startTime;
}
@@ -144,7 +133,6 @@ contract EventManager {
eventId,
msg.sender,
eventToUpdate.location,
- eventToUpdate.date,
eventToUpdate.startTime,
eventToUpdate.endTime,
eventToUpdate.price
diff --git a/src/pages/CreateEvent.jsx b/src/pages/CreateEvent.jsx
index 526e6e1..6a6fb37 100644
--- a/src/pages/CreateEvent.jsx
+++ b/src/pages/CreateEvent.jsx
@@ -8,15 +8,17 @@ import "react-datepicker/dist/react-datepicker.css";
export default function CreateEvent(){
const [name, setName] = useState()
const [location, setLocation] = useState()
- const [startDate, setStartDate] = useState(new Date())
- const [unixStartDate, setUnixStartDate] = useState()
+ const [startTime, setStartTime] = useState(new Date())
+ const [unixStartTime, setUnixStartTime] = useState()
+ const [endTime, setEndTime] = useState(new Date())
+ const [unixEndTime, setUnixEndTime] = useState()
const [description, setDescription] = useState()
const [price, setPrice] = useState()
const [totalTickets, setTotalTickets] = useState()
useEffect(() => {
- console.log({ name, location, startDate, description, price, totalTickets });
- }, [name, location, startDate, description, price, totalTickets]);
+ console.log({ name, location, startTime, description, price, totalTickets });
+ }, [name, location, startTime, description, price, totalTickets]);
let signer = null;
let provider;
@@ -37,10 +39,10 @@ export default function CreateEvent(){
const eventManagerContract = new ethers.Contract(eventManagerAddress, eventManagerAbi, provider);
- async function createEvent(name, location, startDate, startTime, endTime, description, eventType, price, totalTickets) {
+ async function createEvent(name, location, startTime, endTime, description, eventType, price, totalTickets) {
const signer = await provider.getSigner();
const contractWithSigner = eventManagerContract.connect(signer);
- const tx = await contractWithSigner.createEvent(name, location, startDate, startTime, endTime, description, eventType, price, totalTickets);
+ const tx = await contractWithSigner.createEvent(name, location, startTime, endTime, description, eventType, price, totalTickets);
const txResponse = await tx.wait();
console.log('Transaction sent!', txResponse.hash);
}
@@ -74,9 +76,9 @@ export default function CreateEvent(){
const createEventBtnHandler = async (e) => {
e.preventDefault();
- const endTime = unixStartDate + 7200;
+ const endTime = unixStartTime + 7200;
const eventType = 1;
- createEvent(name, location, unixStartDate, unixStartDate, endTime, description, eventType, price, totalTickets);
+ createEvent(name, location, unixStartTime, endTime, description, eventType, price, totalTickets);
uploadIpfsFile();
@@ -86,10 +88,21 @@ export default function CreateEvent(){
return Math.floor(date.getTime() / 1000);
}
- const startDateHandler = date => {
- setStartDate(date);
+ const startTimeHandler = date => {
+ setStartTime(date);
+ let unixDate = dateToUnixTimestamp(date)
+ setUnixStartTime(unixDate);
+
+ if (date > endTime) {
+ setEndTime(date);
+ setUnixEndTime(unixDate);
+ }
+ }
+
+ const endTimeHandler = date => {
+ setEndTime(date);
let unixDate = dateToUnixTimestamp(date)
- setUnixStartDate(unixDate);
+ setUnixEndTime(unixDate);
}
return (
@@ -120,13 +133,26 @@ export default function CreateEvent(){
Event Image
- {/*