Skip to content

Commit

Permalink
cant find apartment + question modal
Browse files Browse the repository at this point in the history
  • Loading branch information
ggsawatyanon committed Apr 24, 2024
1 parent a741f98 commit 77602d1
Show file tree
Hide file tree
Showing 6 changed files with 467 additions and 143 deletions.
36 changes: 36 additions & 0 deletions backend/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
LandlordWithLabel,
ApartmentWithLabel,
ApartmentWithId,
CantFindApartmentForm,
QuestionForm,
} from '@common/types/db-types';
// Import Firebase configuration and types
import { auth } from 'firebase-admin';
Expand All @@ -34,6 +36,8 @@ const landlordCollection = db.collection('landlords');
const buildingsCollection = db.collection('buildings');
const likesCollection = db.collection('likes');
const usersCollection = db.collection('users');
const pendingBuildingsCollection = db.collection('pendingBuildings');
const contactQuestionsCollection = db.collection('contactQuestions');

// Middleware setup
const app: Express = express();
Expand Down Expand Up @@ -861,4 +865,36 @@ app.put('/api/update-review-status/:reviewDocId/:newStatus', authenticate, async
}
});

// API endpoint to submit a "Can't Find Your Apartment?" form.
app.post('/api/add-pending-building', authenticate, async (req, res) => {
try {
const doc = pendingBuildingsCollection.doc();
const apartment = req.body as CantFindApartmentForm;
if (apartment.name === '') {
res.status(401).send('Error: missing fields');
}
doc.set({ ...apartment, date: new Date(apartment.date), status: 'PENDING' });
res.status(201).send(doc.id);
} catch (err) {
console.error(err);
res.status(401).send('Error');
}
});

// API endpoint to submit a "Ask Us A Question" form.
app.post('/api/add-contact-question', authenticate, async (req, res) => {
try {
const doc = contactQuestionsCollection.doc();
const question = req.body as QuestionForm;
if (question.name === '') {
res.status(401).send('Error: missing fields');
}
doc.set({ ...question, date: new Date(question.date), status: 'PENDING' });
res.status(201).send(doc.id);
} catch (err) {
console.error(err);
res.status(401).send('Error');
}
});

export default app;
10 changes: 9 additions & 1 deletion common/types/db-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,18 @@ export type LandlordOrApartmentWithLabel = LandlordWithLabel | ApartmentWithLabe

export type Likes = StringSet;

export type CantFindApartment = {
export type CantFindApartmentForm = {
readonly date: Date;
readonly name: string;
readonly address: string;
readonly photos: readonly string[];
readonly userId?: string | null;
};

export type QuestionForm = {
readonly date: Date;
readonly name: string;
readonly email: string;
readonly msg: string;
readonly userId?: string | null;
};
2 changes: 1 addition & 1 deletion frontend/src/assets/xIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 9 additions & 9 deletions frontend/src/components/LeaveReview/ReviewModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -585,16 +585,16 @@ const ReviewModal = ({
</Grid>
)}
</Grid>
<UploadPhotos
photosLimit={REVIEW_PHOTOS_LIMIT}
photoMaxMB={REVIEW_PHOTO_MAX_MB}
photos={review.localPhotos}
onPhotosChange={updatePhotos}
removePhoto={removePhoto}
addedPhoto={addedPhoto}
setAddedPhoto={setAddedPhoto}
/>
</Grid>
<UploadPhotos
photosLimit={REVIEW_PHOTOS_LIMIT}
photoMaxMB={REVIEW_PHOTO_MAX_MB}
photos={review.localPhotos}
onPhotosChange={updatePhotos}
removePhoto={removePhoto}
addedPhoto={addedPhoto}
setAddedPhoto={setAddedPhoto}
/>
</div>
</DialogContent>
<DialogActions
Expand Down
Loading

0 comments on commit 77602d1

Please sign in to comment.