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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app), using MongoDB.


### Development Server
Expand Down
39 changes: 39 additions & 0 deletions app/actions/addProperty.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"use server";

async function addProperty(formData) {
const amenities = formData.getAll("amenities"); // gets all values by form field "name" as an Array

const images = formData
.getAll("images")
.filter((image) => image.name !== "") // filter out with no name
.map((image) => image.name); // only save image name in DB

const propertyData = {
type: formData.get("type"),
name: formData.get("name"),
description: formData.get("description"),
location: {
street: formData.get("location.street"),
city: formData.get("location.city"),
state: formData.get("location.state"),
zipcode: formData.get("location.zipcode"),
},
beds: formData.get("beds"),
baths: formData.get("baths"),
square_feet: formData.get("square_feet"),
amenities,
rates: {
nightly: formData.get("rates.nightly"),
weekly: formData.get("rates.weekly"),
monthly: formData.get("rates.monthly"),
},
seller_info: {
name: FormDataEvent.get("seller_info.name"),
email: FormDataEvent.get("seller_info.email"),
phone: FormDataEvent.get("seller_info.phone"),
},
images,
}
}

export default addProperty;
17 changes: 10 additions & 7 deletions app/properties/add/page.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import Link from 'next/link'
import PropertyAddForm from "@/components/propertyAddForm"

const PropertiesPage = () => {
const AddPropertiesPage = () => {
return (
<div>
<h1 className="text-3xl">PropertiesPage</h1>
<Link href="/">Go Home</Link>
</div>
<section className="bg-blue-50">
<div className="container m-auto max-w-2xl py-24">
<div className="bg-white px-6 py-8 mb-4 shadow-md rounded-md border m-4 md:m-0">
<PropertyAddForm />
</div>
</div>
</section>
)
}

export default PropertiesPage
export default AddPropertiesPage
2 changes: 1 addition & 1 deletion components/Navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ const Navbar = () => {
<button
onClick={() => {
setIsProfileMenuOpen(false);
// signOut();
signOut();
}}
className='block px-4 py-2 text-sm text-gray-700'
role='menuitem'
Expand Down
Loading