Skip to content

Commit

Permalink
search fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
SMNAFI committed Nov 24, 2022
1 parent 6975ee9 commit ba5219c
Show file tree
Hide file tree
Showing 5 changed files with 297 additions and 246 deletions.
4 changes: 2 additions & 2 deletions src/components/Request.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const Donar = ({ request }) => {
date,
numBag,
contact,
area,
location,
district,
numManaged,
// response,
Expand All @@ -39,7 +39,7 @@ const Donar = ({ request }) => {
<Card.Text>Number of bages: {numBag}</Card.Text>
<Card.Text>Contuct Number: {contact}</Card.Text>
<Card.Text>
Location: {area}, {district}
Location: {location}, {district}
</Card.Text>
<Card.Text>Bag managed: {numManaged}</Card.Text>
{/* <Card.Text>Total response: {response.length}</Card.Text> */}
Expand Down
4 changes: 2 additions & 2 deletions src/screens/RequestDetailsScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function RequestDetailsScreen() {
date,
numBag,
contact,
area,
location,
district,
numManaged,
isManaged,
Expand Down Expand Up @@ -74,7 +74,7 @@ function RequestDetailsScreen() {
<Card.Text>Number of bages: {numBag}</Card.Text>
<Card.Text>Contuct Number: {contact}</Card.Text>
<Card.Text>
Location: {area}, {district}
Location: {location}, {district}
</Card.Text>
<Card.Text>Bag managed: {numManaged}</Card.Text>
{/* <Card.Text>Total response: {response.length}</Card.Text> */}
Expand Down
280 changes: 155 additions & 125 deletions src/screens/RequestEditScreen.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React, { useEffect, useState } from 'react'
import { doc, getDoc, setDoc } from 'firebase/firestore'
import { db } from '../firebase'
import { Button, Form } from 'react-bootstrap'
import FormContainer from '../components/FormContainer'
import { Button, Col, Form, Row } from 'react-bootstrap'
import Loader from '../components/Loader'
import Message from '../components/Message'
import { useParams } from 'react-router-dom'
Expand All @@ -16,6 +15,7 @@ const RequestEditScreen = () => {
const [numBag, setNumBag] = useState(1)
const [contact, setContact] = useState('')
const [location, setLocation] = useState('')
const [district, setDistrict] = useState('')
const [isManaged, setIsManaged] = useState(false)
const [numManaged, setNumManaged] = useState(0)
const [success, setSuccess] = useState(false)
Expand All @@ -38,11 +38,13 @@ const RequestEditScreen = () => {
setNumBag(res.numBag)
setContact(res.contact)
setLocation(res.location)
setDistrict(res.district)
setIsManaged(res.isManaged)
setNumManaged(res.numManaged)

setLoading(false)
} catch (error) {
setLoading(false)
setError(error.message)
console.log(error)
console.log(error.message)
Expand Down Expand Up @@ -71,6 +73,7 @@ const RequestEditScreen = () => {
numManaged,
contact,
location,
district,
},
{ merge: true }
)
Expand All @@ -86,129 +89,156 @@ const RequestEditScreen = () => {

return (
<>
<FormContainer>
<h1 className='text-center my-5'>Edit your request</h1>

{success && <Message>Request updated successfully</Message>}
{error && <Message variant='danger'>{error}</Message>}
{loading && <Loader />}

<Form onSubmit={submitHandler} className='my-5'>
<Form.Group controlId='isManged' className='mb-3'>
<Form.Check
type='switch'
id='isManged'
label='Mark as managed'
checked={isManaged}
onChange={(e) => setIsManaged(e.target.checked)}
/>
</Form.Group>

<Form.Group controlId='problem' className='mb-3'>
<Form.Label>Problem</Form.Label>
<Form.Control
as='textarea'
placeholder='Enter your reason'
value={problem}
onChange={(e) => setProblem(e.target.value)}
required={true}
></Form.Control>
</Form.Group>

<Form.Group controlId='bloodGroup' className='mb-3'>
<Form.Label>Required Blood Group</Form.Label>
<Form.Select
value={bloodGroup}
onChange={(e) => setBloodGroup(e.target.value)}
required={true}
>
<option></option>
<option>A+</option>
<option>A-</option>
<option>B+</option>
<option>B-</option>
<option>AB+</option>
<option>AB-</option>
<option>O+</option>
<option>O-</option>
</Form.Select>
</Form.Group>

<Form.Group controlId='numBag' className='mb-3'>
<Form.Label>Required number of bages</Form.Label>
<Form.Control
type='number'
placeholder='Num of bages'
value={numBag}
onChange={(e) => setNumBag(e.target.value)}
required={true}
min='1'
></Form.Control>
</Form.Group>

<Form.Group controlId='numManaged' className='mb-3'>
<Form.Label>Number of bag that is managed</Form.Label>
<Form.Control
type='number'
placeholder='Num of bages'
value={numManaged}
onChange={(e) => setNumManaged(e.target.value)}
required={true}
min='0'
></Form.Control>
</Form.Group>

<Form.Group controlId='location' className='mb-3'>
<Form.Label>Location</Form.Label>
<Form.Control
type='text'
placeholder='Enter location'
value={location}
onChange={(e) => setLocation(e.target.value)}
required={true}
></Form.Control>
</Form.Group>

<Form.Group controlId='time' className='mb-3'>
<Form.Label>Time</Form.Label>
<Form.Control
type='time'
placeholder='Time'
value={time}
onChange={(e) => setTime(e.target.value)}
required={true}
></Form.Control>
</Form.Group>

<Form.Group controlId='lastDonation' className='mb-3'>
<Form.Label>Date</Form.Label>
<Form.Control
type='date'
placeholder='Date'
value={date}
onChange={(e) => setDate(e.target.value)}
required={true}
></Form.Control>
</Form.Group>

<Form.Group controlId='contact' className='mb-3'>
<Form.Label>Contact Number</Form.Label>
<Form.Control
type='text'
placeholder='Contact Number'
value={contact}
onChange={(e) => setContact(e.target.value)}
required={true}
pattern='[0-9]{11}'
title='11 digits phone number'
></Form.Control>
</Form.Group>

<Button type='submit' varient='primary'>
Update
</Button>
</Form>
</FormContainer>
<h1 className='text-center my-5'>Edit your request</h1>

{success && <Message>Request updated successfully</Message>}
{error && <Message variant='danger'>{error}</Message>}
{loading && <Loader />}

<Form onSubmit={submitHandler} className='my-5'>
<Form.Group controlId='isManged' className='mb-3'>
<Form.Check
type='switch'
id='isManged'
label='Mark as managed'
checked={isManaged}
onChange={(e) => setIsManaged(e.target.checked)}
/>
</Form.Group>

<Form.Group controlId='problem' className='mb-3'>
<Form.Label>Problem</Form.Label>
<Form.Control
as='textarea'
placeholder='Enter your reason'
value={problem}
onChange={(e) => setProblem(e.target.value)}
required={true}
></Form.Control>
</Form.Group>

<Row>
<Col md={6}>
<Form.Group controlId='bloodGroup' className='mb-3'>
<Form.Label>Required Blood Group</Form.Label>
<Form.Select
value={bloodGroup}
onChange={(e) => setBloodGroup(e.target.value)}
required={true}
>
<option></option>
<option>A+</option>
<option>A-</option>
<option>B+</option>
<option>B-</option>
<option>AB+</option>
<option>AB-</option>
<option>O+</option>
<option>O-</option>
</Form.Select>
</Form.Group>
</Col>

<Col md={6}>
<Form.Group controlId='numBag' className='mb-3'>
<Form.Label>Required number of bages</Form.Label>
<Form.Control
type='number'
placeholder='Num of bages'
value={numBag}
onChange={(e) => setNumBag(e.target.value)}
required={true}
min='1'
></Form.Control>
</Form.Group>
</Col>

<Col md={6}>
<Form.Group controlId='numManaged' className='mb-3'>
<Form.Label>Number of bag that is managed</Form.Label>
<Form.Control
type='number'
placeholder='Num of bages'
value={numManaged}
onChange={(e) => setNumManaged(e.target.value)}
required={true}
min='0'
></Form.Control>
</Form.Group>
</Col>

<Col md={6}>
<Form.Group controlId='location' className='mb-3'>
<Form.Label>Location</Form.Label>
<Form.Control
type='text'
placeholder='Enter location'
value={location}
onChange={(e) => setLocation(e.target.value)}
required={true}
></Form.Control>
</Form.Group>
</Col>

<Col md={6}>
<Form.Group controlId='district' className='mb-3'>
<Form.Label>District</Form.Label>
<Form.Control
type='text'
placeholder='Enter District'
value={district}
onChange={(e) => setDistrict(e.target.value)}
required={true}
></Form.Control>
</Form.Group>
</Col>

<Col md={6}>
<Form.Group controlId='time' className='mb-3'>
<Form.Label>Time</Form.Label>
<Form.Control
type='text'
placeholder='Time'
value={time}
onChange={(e) => setTime(e.target.value)}
required={true}
></Form.Control>
</Form.Group>
</Col>

<Col md={6}>
<Form.Group controlId='lastDonation' className='mb-3'>
<Form.Label>Date</Form.Label>
<Form.Control
type='date'
placeholder='Date'
value={date}
onChange={(e) => setDate(e.target.value)}
required={true}
></Form.Control>
</Form.Group>
</Col>

<Col md={6}>
<Form.Group controlId='contact' className='mb-3'>
<Form.Label>Contact Number</Form.Label>
<Form.Control
type='text'
placeholder='Contact Number'
value={contact}
onChange={(e) => setContact(e.target.value)}
required={true}
pattern='[0-9]{11}'
title='11 digits phone number'
></Form.Control>
</Form.Group>
</Col>
</Row>

<Button type='submit' varient='primary'>
Update
</Button>
</Form>
</>
)
}
Expand Down
Loading

0 comments on commit ba5219c

Please sign in to comment.