mirror of
https://github.com/myfatemi04/wheelshare-frontend.git
synced 2025-04-21 19:29:51 -04:00
make pool creation work
This commit is contained in:
parent
8ea818a39a
commit
6cd56843b4
|
@ -1,6 +1,5 @@
|
||||||
import { FormEventHandler } from 'react';
|
|
||||||
import { makeAPIPostCall } from '../api/utils';
|
import { makeAPIPostCall } from '../api/utils';
|
||||||
import React, { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
|
|
||||||
const CreatePool = () => {
|
const CreatePool = () => {
|
||||||
const [title, setTitle] = useState('No Title');
|
const [title, setTitle] = useState('No Title');
|
||||||
|
@ -10,34 +9,18 @@ const CreatePool = () => {
|
||||||
const [direction, setDirection] = useState('pickup');
|
const [direction, setDirection] = useState('pickup');
|
||||||
const [type, setType] = useState('offer');
|
const [type, setType] = useState('offer');
|
||||||
const [description, setDescription] = useState('');
|
const [description, setDescription] = useState('');
|
||||||
|
const [group, setGroup] = useState('');
|
||||||
|
|
||||||
const onSubmit: FormEventHandler<HTMLFormElement> = (e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
fetch(`${process.env.REACT_APP_API_ENDPOINT}/createPool`)
|
|
||||||
.then((response) => response.json())
|
|
||||||
.then((data) => {
|
|
||||||
console.log(data);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
const onClick = () => {
|
const onClick = () => {
|
||||||
console.log({
|
|
||||||
title: title,
|
|
||||||
description: description,
|
|
||||||
start_time: start,
|
|
||||||
end_time: end,
|
|
||||||
capacity,
|
|
||||||
direction,
|
|
||||||
type,
|
|
||||||
});
|
|
||||||
makeAPIPostCall('/pool', {
|
makeAPIPostCall('/pool', {
|
||||||
title: title,
|
title,
|
||||||
description: description,
|
description,
|
||||||
start_time: start,
|
start_time: start,
|
||||||
end_time: end,
|
end_time: end,
|
||||||
capacity,
|
capacity,
|
||||||
direction,
|
direction,
|
||||||
type,
|
type,
|
||||||
|
group_id: group,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
useEffect(() => {}, []);
|
useEffect(() => {}, []);
|
||||||
|
@ -50,7 +33,6 @@ const CreatePool = () => {
|
||||||
className="container card card-body text-left "
|
className="container card card-body text-left "
|
||||||
style={{ backgroundColor: '#F1EAE8' }}
|
style={{ backgroundColor: '#F1EAE8' }}
|
||||||
>
|
>
|
||||||
<form onSubmit={onSubmit}>
|
|
||||||
<div className="form-group">
|
<div className="form-group">
|
||||||
<h1 className="form-title" style={{ fontFamily: 'Impact' }}>
|
<h1 className="form-title" style={{ fontFamily: 'Impact' }}>
|
||||||
Create Pool
|
Create Pool
|
||||||
|
@ -145,12 +127,21 @@ const CreatePool = () => {
|
||||||
placeholder="Enter text here..."
|
placeholder="Enter text here..."
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="form-group">
|
||||||
|
<label className="" htmlFor="pool_start">
|
||||||
|
Group:
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control"
|
||||||
|
placeholder=""
|
||||||
|
onChange={(event) => setGroup(event.target.value)}
|
||||||
|
></input>
|
||||||
|
</div>
|
||||||
<button className="btn btn-success text-left" onClick={onClick}>
|
<button className="btn btn-success text-left" onClick={onClick}>
|
||||||
Submit
|
Submit
|
||||||
</button>
|
</button>
|
||||||
<br />
|
<br />
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -74,7 +74,7 @@ export default function Group() {
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Typography variant="h1" align="center">
|
<Typography variant="h1" align="center">
|
||||||
Group {group.id}
|
{group.name}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|
||||||
<Typography variant="h3" align="center">
|
<Typography variant="h3" align="center">
|
||||||
|
|
Loading…
Reference in New Issue
Block a user