Skip to content

Commit

Permalink
fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ilgazer committed Nov 28, 2023
1 parent 13b6dc9 commit 18ea594
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 136 deletions.
20 changes: 3 additions & 17 deletions resq/frontend/src/components/Countries.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,7 @@ const customTheme = createTheme({
},
});

const customStyles = {
marginBottom: '16px',
height: '100%',
};


const Select = React.forwardRef(function CustomSelect(props, ref) {
const slots = {
Expand Down Expand Up @@ -110,18 +107,7 @@ const red = {
900: '#B20000', // dark red
};

const grey = {
50: '#F3F6F9',
100: '#E5EAF2',
200: '#DAE2ED',
300: '#C7D0DD',
400: '#B0B8C4',
500: '#9DA8B7',
600: '#6B7A90',
700: '#434D5B',
800: '#303740',
900: '#1C2025',
};


const Button = React.forwardRef(function Button(props, ref) {
const { ownerState, ...other } = props;
Expand Down Expand Up @@ -214,7 +200,7 @@ const Listbox = styled('ul')(
`,
);

const Option = styled(BaseOption)(
styled(BaseOption)(
({ theme }) => `
list-style: none;
padding: 8px;
Expand Down
5 changes: 2 additions & 3 deletions resq/frontend/src/components/Geolocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ const GOOGLE_API_KEY = "AIzaSyCehlfJwJ-V_xOWZ9JK3s0rcjkV2ga0DVg";
// Function to perform reverse geocoding
const reverseGeocode = async (latitude, longitude) => {
try {
const response = await axios.get(`https://maps.googleapis.com/maps/api/geocode/json?latlng=${latitude},${longitude}&key=AIzaSyCehlfJwJ-V_xOWZ9JK3s0rcjkV2ga0DVg`);
const cityName = response.data.results[0]?.formatted_address || 'Unknown Location';
return cityName;
const response = await axios.get(`https://maps.googleapis.com/maps/api/geocode/json?latlng=${latitude},${longitude}&key=${GOOGLE_API_KEY}`);
return response.data.results[0]?.formatted_address || 'Unknown Location';
} catch (error) {
console.error('Error fetching location name:', error);
return 'Unknown Location';
Expand Down
27 changes: 1 addition & 26 deletions resq/frontend/src/components/Request/RequestAddress.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import React, { useState } from 'react';
import { TextField, Button, FormControl, InputLabel, Select, MenuItem, Box } from '@mui/material';
import { TextField, Box } from '@mui/material';
import '@fontsource/inter';
import Grid from '@mui/material/Grid';
import Typography from '@mui/material/Typography';
import FormControlLabel from '@mui/material/FormControlLabel';
import Checkbox from '@mui/material/Checkbox';
import { createTheme, ThemeProvider } from '@mui/material/styles';
import disasterImage from '../../disaster.png';
import Avatar from '@mui/material/Avatar';
import CssBaseline from '@mui/material/CssBaseline';
import Container from '@mui/material/Container';

Expand All @@ -21,29 +19,6 @@ const customTheme = createTheme({
});

export default function CreateRequestForm() {
const [request, setRequest] = useState({
type: '',
status: '',
urgency: '',
location: '',
quantity: '',
description: '',
});

const handleChange = (event) => {
const { name, value } = event.target;
setRequest(prevState => ({
...prevState,
[name]: value
}));
};

const handleSubmit = (event) => {
event.preventDefault();
console.log(request);
//send this data to a backend server
};

return (
<ThemeProvider theme={customTheme}>
<Container component="main" maxWidth="xs">
Expand Down
1 change: 0 additions & 1 deletion resq/frontend/src/components/Request/RequestCreation.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import CssBaseline from '@mui/material/CssBaseline';
import AppBar from '@mui/material/AppBar';
import Box from '@mui/material/Box';
import Container from '@mui/material/Container';
import Toolbar from '@mui/material/Toolbar';
import Paper from '@mui/material/Paper';
import Stepper from '@mui/material/Stepper';
import Step from '@mui/material/Step';
Expand Down
18 changes: 0 additions & 18 deletions resq/frontend/src/components/Request/RequestDetails1.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import * as React from 'react';
import { useState } from 'react';
import { styled } from '@mui/material/styles';
import NativeSelect from '@mui/material/NativeSelect';
import InputBase from '@mui/material/InputBase';
import { Typography, Grid, FormControlLabel, Checkbox, TextField, Chip, Box, FormControl, InputLabel, Select, MenuItem, OutlinedInput } from '@mui/material';
import { useTheme } from '@mui/material/styles';
import { createTheme } from '@mui/material/styles';
import { FormHelperText } from '@mui/material';

Expand Down Expand Up @@ -128,24 +124,10 @@ function CustomizedSelects() {

export default function RequestDetails() {

const [otherRestrictions, setOtherRestrictions] = useState('');
const [isWaterChecked, setIsWaterChecked] = useState(true);
const [isFoodChecked, setIsFoodChecked] = useState(true);
const [selectedIllnesses, setSelectedIllnesses] = useState([]);

const handleOtherRestrictionsChange = (event) => {
setOtherRestrictions(event.target.value);
};

const handleIllnessSelection = (illness) => {
// Toggle illness in the selected illnesses array
if (selectedIllnesses.includes(illness)) {
setSelectedIllnesses(selectedIllnesses.filter(item => item !== illness));
} else {
setSelectedIllnesses([...selectedIllnesses, illness]);
}
};

// Handle change in selected illnesses
const handleIllnessChange = (event) => {
setSelectedIllnesses(event.target.value);
Expand Down
20 changes: 2 additions & 18 deletions resq/frontend/src/components/Request/RequestDetails2.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React, { useState } from 'react';
import { styled } from '@mui/material/styles';
import { Typography, Grid, FormControlLabel, Checkbox, TextField, Chip, Box, FormControl, InputLabel, Select, MenuItem, OutlinedInput } from '@mui/material';
import { Typography, Grid, FormControlLabel, Checkbox, TextField, Chip, Box } from '@mui/material';
import { createTheme } from '@mui/material/styles';
import { FormHelperText } from '@mui/material';
import { InputAdornment } from '@mui/material';


const customTheme = createTheme({
createTheme({
palette: {
primary: {
main: '#FF0000',
Expand Down Expand Up @@ -336,21 +335,6 @@ export default function RequestDetails2() {
};
const handleDelete16 = (value) => setSelectedValues16(selectedValues16.filter(item => item !== value));


// Menu properties
const ITEM_HEIGHT = 48;
const ITEM_PADDING_TOP = 8;
const MenuProps = {
PaperProps: {
style: {
maxHeight: ITEM_HEIGHT * 4.5 + ITEM_PADDING_TOP,
width: 250,
},
},
};

// Add your handler functions here

return (
<React.Fragment>
<Typography variant="h6" gutterBottom>
Expand Down
3 changes: 0 additions & 3 deletions resq/frontend/src/components/Request/RequestReview.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import React from 'react';
import Typography from '@mui/material/Typography';
import List from '@mui/material/List';
import ListItem from '@mui/material/ListItem';
import ListItemText from '@mui/material/ListItemText';
import Grid from '@mui/material/Grid';

const primaryNeeds = [
Expand Down
55 changes: 27 additions & 28 deletions resq/frontend/src/components/Resource/ResourceAddress.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, {useState, useEffect} from 'react';
import {TextField, Button, FormControl, InputLabel, Select, MenuItem, Box} from '@mui/material';
import {TextField, Box} from '@mui/material';
import '@fontsource/inter';
import Grid from '@mui/material/Grid';
import Typography from '@mui/material/Typography';
Expand All @@ -8,8 +8,6 @@ import Checkbox from '@mui/material/Checkbox';
import {createTheme, ThemeProvider} from '@mui/material/styles';
import CssBaseline from '@mui/material/CssBaseline';
import Container from '@mui/material/Container';
import {ResourceContext} from './ResourceContext';
import {useContext} from 'react';

const customTheme = createTheme({
palette: {
Expand All @@ -27,39 +25,40 @@ export default function ResourceAddress({resourceData, setResourceData}) {
const [country, setCountry] = useState("")
const [nop, setNop] = useState("")

useEffect(() => {

const handleGeocode = async () => {
const address = `${address1}, ${address2}, ${city}, ${state}, ${country}`;
const apiKey = 'AIzaSyCehlfJwJ-V_xOWZ9JK3s0rcjkV2ga0DVg';
const handleGeocode = async () => {
const address = `${address1}, ${address2}, ${city}, ${state}, ${country}`;
const apiKey = 'AIzaSyCehlfJwJ-V_xOWZ9JK3s0rcjkV2ga0DVg';

try {
const response = await fetch(
`https://maps.googleapis.com/maps/api/geocode/json?address=${encodeURIComponent(
address
)}&key=${apiKey}`
);
try {
const response = await fetch(
`https://maps.googleapis.com/maps/api/geocode/json?address=${encodeURIComponent(
address
)}&key=${apiKey}`
);

if (response.ok) {
const data = await response.json();
if (data.results && data.results.length > 0) {
const location = data.results[0].geometry.location;
setResourceData(
{...resourceData, latitude: location.lat, longitude: location.lng}
)
if (response.ok) {
const data = await response.json();
if (data.results && data.results.length > 0) {
const location = data.results[0].geometry.location;
setResourceData(
{...resourceData, latitude: location.lat, longitude: location.lng}
)
} else {
console.error('Geocoding failed: No results found');
}
} else {
console.error('Geocoding failed: No results found');
console.error('Geocoding request failed');
}
} else {
console.error('Geocoding request failed');
} catch (error) {
console.error('Geocoding error:', error);
}
} catch (error) {
console.error('Geocoding error:', error);
}
};
};

useEffect(() => {
// noinspection JSIgnoredPromiseFromCall
handleGeocode();
}, [address1, address2, city, state, country, nop]);
}, [address1, address2, city, state, country, nop, setResourceData, resourceData]);

return (
<ThemeProvider theme={customTheme}>
Expand Down
6 changes: 2 additions & 4 deletions resq/frontend/src/components/Resource/ResourceCreation.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React, {createContext, useState, useContext} from 'react';
import React, {useState} from 'react';
import CssBaseline from '@mui/material/CssBaseline';
import AppBar from '@mui/material/AppBar';
import Box from '@mui/material/Box';
import Container from '@mui/material/Container';
import Toolbar from '@mui/material/Toolbar';
import Paper from '@mui/material/Paper';
import Stepper from '@mui/material/Stepper';
import Step from '@mui/material/Step';
Expand All @@ -12,9 +11,8 @@ import Button from '@mui/material/Button';
import Link from '@mui/material/Link';
import Typography from '@mui/material/Typography';
import {createTheme, ThemeProvider} from '@mui/material/styles';
import axios from 'axios';

import {ResourceContext, ResourceProvider, useResource} from './ResourceContext';
import {ResourceProvider} from './ResourceContext';
import ResourceDetail1 from "./ResourceDetail1";
import ResourceDetail2 from "./ResourceDetail2";
import ResourceAddress from "./ResourceAddress";
Expand Down
7 changes: 1 addition & 6 deletions resq/frontend/src/components/Resource/ResourceDetail1.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,12 @@ import {
FormControlLabel,
Checkbox,
FormControl,
InputLabel,
Select,
MenuItem,
OutlinedInput,
Autocomplete, TextField
} from '@mui/material';
import {createTheme} from '@mui/material/styles';
import {Theme, useTheme} from '@mui/material/styles';
import {useResource} from './ResourceContext';
import {useContext} from 'react';
import {ResourceContext} from './ResourceContext';
import {useTheme} from '@mui/material/styles';
import {useQuery} from "@tanstack/react-query";
import {getCategoryTree} from "../../AppService";

Expand Down
12 changes: 0 additions & 12 deletions resq/frontend/src/components/Resource/ResourceDetail2.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
import React, {useState, useEffect} from 'react';
import {Typography, Grid, TextField} from '@mui/material';
import {ResourceContext} from './ResourceContext';
import {useContext} from 'react';

export default function ResourceDetail2({resourceData, setResourceData}) {

const ITEM_HEIGHT = 48;
const ITEM_PADDING_TOP = 8;
const MenuProps = {
PaperProps: {
style: {
maxHeight: ITEM_HEIGHT * 4.5 + ITEM_PADDING_TOP, width: 250,
},
},
};

const [materialQuantity, setMaterialQuantity] = useState('');
const [materialDescription, setMaterialDescription] = useState('');

Expand Down

0 comments on commit 18ea594

Please sign in to comment.