Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 55 additions & 4 deletions back-end/db/prod_schema.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,59 @@
-- \c production_database_name;
-- DROP DATABASE IF EXISTS chef_app_dev;
-- CREATE DATABASE chef_app_dev;
-- \c chef_app_dev;

DROP TABLE IF EXISTS test;
DROP TABLE IF EXISTS users;
CREATE TABLE users (
id TEXT PRIMARY KEY UNIQUE,
email VARCHAR(100) UNIQUE,
img_url TEXT,
bio TEXT,
first_name VARCHAR(100) NOT NULL,
last_name VARCHAR(100) NOT NULL,
is_chef BOOLEAN DEFAULT FALSE,
cuisine TEXT
);

DROP TABLE IF EXISTS bookings;

CREATE TABLE test (
CREATE TABLE bookings (
id SERIAL PRIMARY KEY,
name TEXT
chef_id TEXT REFERENCES users (id) NOT NULL,
user_id TEXT REFERENCES users (id) NOT NULL,
event_type TEXT NOT NULL,
party_size TEXT NOT NULL,
address TEXT NOT NULL,
address2 TEXT,
city TEXT NOT NULL,
state TEXT NOT NULL,
zip_code VARCHAR(5),
start_event TIMESTAMP,
end_event TIMESTAMP
);

DROP TABLE IF EXISTS ratings;

CREATE TABLE ratings (
id BIGSERIAL NOT NULL PRIMARY KEY,
chef_id TEXT NOT NULL REFERENCES users (id),
user_id TEXT NOT NULL REFERENCES users (id),
name VARCHAR(100) NOT NULL,
review TEXT NOT NULL,
rating INT NOT NULL CHECK (rating >=0 AND rating <= 5)
);

DROP TABLE IF EXISTS availability;

CREATE TABLE availability (
id SERIAL PRIMARY KEY,
chef_id TEXT REFERENCES users (id) NOT NULL,
sunday TEXT DEFAULT NULL,
monday TEXT DEFAULT NULL,
tuesday TEXT DEFAULT NULL,
wednesday TEXT DEFAULT NULL,
thursday TEXT DEFAULT NULL,
friday TEXT DEFAULT NULL,
saturday TEXT DEFAULT NULL,
is_booked BOOLEAN DEFAULT NULL,
booked_by TEXT REFERENCES users (id)
);
59 changes: 49 additions & 10 deletions back-end/db/prod_seed.sql
Original file line number Diff line number Diff line change
@@ -1,10 +1,49 @@
-- \c production_database_name;

INSERT INTO test (name) VALUES
('Monday'),
('Tuesday'),
('Wednesday'),
('Thursday'),
('Friday'),
('Saturday'),
('Sunday');
-- \c chef_app_dev;

INSERT INTO users (
id, email, img_url, bio, first_name, last_name, is_chef, cuisine)
VALUES
('285cfccb-2064-4794-a51d-6ca38e6580c6', 'kiara.azize@yahoo.com', 'https://i.imgur.com/T3JSBpH.jpg', 'Graduated from Culinary Insititue and worked at restaurants owned by Tom Colicchio', 'Kiara', 'Azize', true, 'French, Japanese, & New American' ),
('11389417-4ab2-44d5-90f0-e717ccd887f0', 'kellanwatanbe1@gmail.com', 'https://i.imgur.com/PdJtb04.jpg', 'Up and coming Chef', 'Kellan', 'Watanabe', true, 'Japanese' ),
('9e517784-98d3-43a5-bd2b-1e24772671f0', 'dannypetrose@hotmail.com', 'https://i.imgur.com/Bon7zjI.jpg', 'Cooked at many restaurants', 'Danny', 'Petrose', true, 'New American, Japanese, & Mediterranean '),
('ahdjw82iks','chef_boyardee@gmail.com', 'https://images.unsplash.com/photo-1576064535185-9f6e3f24b63e?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1740&q=80', 'I am an Italian-American chef who set up my own packaged food business named Chef Boyardee. Began my career as a kitchen helper, worked hard to eventually become the head chef of the Plaza Hotel in New York City.', 'Ettore', 'Boiardi', true, 'Italian'),
('bsujdyh822','juliaChild23@yahoo.com', 'https://images.unsplash.com/photo-1576064535185-9f6e3f24b63e?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1740&q=80', 'I am a cultural phenomenon who is the face of French cooking in America. I introduced Americans to culinary excellence but to fine dining as well. I made the drudgery and labour within the kitchen seem effortless and easy.' ,'Julia', 'Child', true, 'French' ),
('chgwq72ijd','lesliemann@gmail.com', NULL, NULL, 'Leslie', 'Mann', false, NULL),
('hytrkew345', 'morimoto4545@gmail.com', 'https://images.unsplash.com/photo-1576064535185-9f6e3f24b63e?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1740&q=80', 'Japanese chef who became famous for my appearances on the Food Networks program Iron Chef. I started out as an aspiring athlete from a poor family, turning to cooking after a severe injury. But once I set my heart on becoming a chef, it seemed like nothing could stand in my way.' ,'Masaharu', 'Morimoto', true, 'Japanese'),
('nhyt54pgtn', 'butter@gmail.com', 'https://images.unsplash.com/photo-1576064535185-9f6e3f24b63e?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1740&q=80', 'An American TV personality, cooking show host, author of numerous cookbooks and owner of various restaurants. I began my cooking career pretty late in my life with a catering service, but soon became popular with my southern cooking.', 'Paula', 'Dean', true, 'Southern'),
('p0ot54fdh8', 'vicCruz89@yahoo.com', NULL, NULL, 'Victor', 'Cruz', false, NULL);

INSERT INTO bookings (
chef_id,
user_id,
event_type,
party_size,
address,
address2,
city,
state,
zip_code,
start_event,
end_event)
VALUES
('ahdjw82iks','chgwq72ijd' , 'Birthday Party', '1-2', '511 Bakers St', NULL, 'Yonkers', 'NY', 10031, '2021-09-25 5:00:00', '2021-09-25 9:00:00'),
('ahdjw82iks','nhyt54pgtn' , 'Birthday Party', '1-2', '511 Bakers St', NULL, 'Yonkers', 'NY', 10031, '2021-09-25 5:00:00', '2021-09-25 9:00:00'),
('bsujdyh822','p0ot54fdh8' , 'Birthday Party', '1-2', '511 Bakers St', NULL, 'Yonkers', 'NY', 10031, '2021-09-25 5:00:00', '2021-09-25 9:00:00');

INSERT INTO availability (
chef_id, sunday, monday, tuesday, wednesday, thursday, friday, saturday, is_booked, booked_by
)
VALUES
('ahdjw82iks', NULL,'10am - 3pm','10am - 3pm', NULL, NULL, NULL, NULL, false, 'bsujdyh822');
-- ('bsujdyh822', NULL, NULL,'10am - 3pm','10am - 3pm', NULL, NULL, NULL, false, 'hytrkew345'),
-- ('hytrkew345', '10am - 3pm', NULL, NULL, NULL, NULL, '10am - 3pm', NULL, true, 'chgwq72ijd'),
-- ('nhyt54pgtn', '10am - 3pm', NULL, NULL, NULL, NULL,'10am - 3pm', NULL, false, 'chgwq72ijd');

INSERT INTO ratings (chef_id, user_id, name, review, rating)
VALUES
('ahdjw82iks', 'p0ot54fdh8', 'Victor Cruz', 'Always delicious food! Even my picky children ate all their veggies this time.', 5),
('ahdjw82iks', 'chgwq72ijd', 'Leslie Mann', 'Discovered this app through a friend and I love it! Have not stopped using it. I lost so much pandemic weight through the meal plans!', 4),
('bsujdyh822', 'p0ot54fdh8', 'Victor Cruz', 'An OK chef', 3),
('bsujdyh822', 'chgwq72ijd', 'Leslie Mann', 'Wow! Wow! Wow! The variety of cuisines is amazing!', 4),
('hytrkew345', 'chgwq72ijd', 'Leslie Mann', 'Since becoming a Savor client my life has been to much easier!', 4),
('nhyt54pgtn', 'p0ot54fdh8', 'Victor Cruz', 'Food is always delicious! Service is impeccable', 4);
6 changes: 3 additions & 3 deletions back-end/db/schema.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
DROP DATABASE IF EXISTS chef_app_dev;
CREATE DATABASE chef_app_dev;
\c chef_app_dev;
-- DROP DATABASE IF EXISTS chef_app_dev;
-- CREATE DATABASE chef_app_dev;
-- \c chef_app_dev;

DROP TABLE IF EXISTS users;
CREATE TABLE users (
Expand Down
2 changes: 1 addition & 1 deletion back-end/db/seed.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
\c chef_app_dev;
-- \c chef_app_dev;

INSERT INTO users (
id, email, img_url, bio, first_name, last_name, is_chef, cuisine)
Expand Down
61 changes: 30 additions & 31 deletions front-end/src/Components/BookingForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,39 +26,38 @@ const BookingForm = ({ chef }) => {
});
let history = useHistory();

const handleChange = (type) => {
return (e) => setRequest({ ...request, [type]: e.target.value });
};
const handleChange = (type) => {
return (e) => setRequest({ ...request, [type]: e.target.value });
};

const addNewRequest = async (newRequest) => {
try {
const chefRequest = {
chef_id: chef_id,
user_id: currentUser.uid,
...newRequest,
};

let res = await axios.post(
`${API}/users/${currentUser?.uid}/bookings`,
chefRequest
);
return res;
} catch (err) {
console.log(err);
return "error";
}
};
console.log("REQUEST", request);
const handleSubmit = async (e) => {
e.preventDefault();
let res = await addNewRequest(request);
if (res.data.payload.success === true) {
history.push(`/users/${currentUser.uid}/bookings`);
} else {
console.log(res);
}
};
const addNewRequest = async (newRequest) => {
try {
const chefRequest = {
chef_id: chef_id,
user_id: currentUser.uid,
...newRequest,
};

let res = await axios.post(
`${API}/users/${currentUser?.uid}/bookings`,
chefRequest
);
return res;
} catch (err) {
return "error";
}
};

const handleSubmit = async (e) => {
e.preventDefault();
let res = await addNewRequest(request);
if (res.data.payload.success === true) {
history.push(`/users/${currentUser.uid}/bookings`);
} else {
console.log(res);
}
};

return (
<section className="booking">
<div className="booking-container">
Expand Down
103 changes: 52 additions & 51 deletions front-end/src/Components/NavBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,68 +8,69 @@ import AuthModal from "./AuthModal";
import { apiURL } from "../util/apiURL";

const API = apiURL();

const NavBar = () => {
const [toggleMenu, setToggleMenu] = useState(false);
const [modalOpen, setModalOpen] = useState(false);
const { currentUser } = useAuth();
const handleToggle = () => {
setToggleMenu((isOpen) => !isOpen);
};
const [user, setUser] = useState(false);
const [toggleMenu, setToggleMenu] = useState(false);
const [modalOpen, setModalOpen] = useState(false);
const { currentUser } = useAuth();
const handleToggle = () => {
setToggleMenu((isOpen) => !isOpen);
};
const [user, setUser] = useState(false);

useEffect(() => {
const getUser = async () => {
let res = await axios.get(`${API}/users/${currentUser?.uid}`);
useEffect(() => {
const getUser = async () => {
let res = await axios.get(`${API}/users/${currentUser?.uid}`);

setUser(res.data.payload);
};
getUser();
}, [currentUser]);
setUser(res.data.payload);
};
getUser();
}, [currentUser]);

return (
<nav className="navBar">
<div className="nav-center">
<div className="nav-header">
<Link to={"/"}>
<h1 className="nav-logo">Savor</h1>
</Link>
<button type="button" className="nav-btn" onClick={handleToggle}>
<FaAlignRight className="nav-icon" />
</button>
</div>
<ul className={toggleMenu ? "nav-links show-nav" : "nav-links"}>
<li>
<Link to={"/chefs"}>Chefs</Link>
</li>
<li>
<Link to={`/users/${currentUser?.uid}/bookings`}>Requests</Link>
</li>
<li>
<button className="lgnBtn" onClick={() => setModalOpen(!modalOpen)}>
Login
</button>
</li>
<div className="nav-in-out">
{/* <Link>
return (
<nav className="navBar">
<div className="nav-center">
<div className="nav-header">
<Link to={"/"}>
<h1 className="nav-logo">Savor</h1>
</Link>
<button type="button" className="nav-btn" onClick={handleToggle}>
<FaAlignRight className="nav-icon" />
</button>
</div>
<ul className={toggleMenu ? "nav-links show-nav" : "nav-links"}>
<li>
<Link to={"/chefs"}>Chefs</Link>
</li>
<li>
<Link to={`/users/${currentUser?.uid}/bookings`}>Requests</Link>
</li>
<li>
<button className="lgnBtn" onClick={() => setModalOpen(!modalOpen)}>
Login
</button>
</li>
<div className="nav-in-out">
{/* <Link>
<button
className="lgnBtn"
onClick={() => setModalOpen(!modalOpen)}
>
Login/Sign Up
</button>
</Link> */}
<Link to={"/"} onClick={signOut}>
<button className="lgnBtn"> Logout</button>
</Link>
</div>
</ul>
</div>
<div className="login-name">
{user ? <p>Hi, {user.first_name}</p> : null}
{modalOpen ? <AuthModal setModalOpen={setModalOpen} /> : null}
</div>
</nav>
);
<Link to={"/"} onClick={signOut}>
<button className="lgnBtn"> Logout</button>
</Link>
</div>
</ul>
</div>
<div className="login-name">
{user ? <p>Hi, {user.first_name}</p> : null}
{modalOpen ? <AuthModal setModalOpen={setModalOpen} /> : null}
</div>
</nav>
);
};

export default NavBar;