-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1348/Add photo upload to the Listing form (#1491)
* First pass at a dropzone Cloudinary uploader * Style the progress control and provide more complete flow * Tighten up Dropzone usability * Add id for accessibility * Update Changelog with #1437 * Adding photo upload to Listings MVP (WIP) * Fix image data issue for edits, add detail preview * Upload to Cloudinary using a signed preset * Revert previous double-submit issue * Remove stray console call * Fix undefined error on new listing page * fix lint error * Add #1491 to changelog * Use state only for Cloudinary upload data Co-authored-by: seanmalbert <[email protected]>
- Loading branch information
1 parent
b650a05
commit ef05c8b
Showing
21 changed files
with
389 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
sites/partners/src/listings/PaperListingDetails/sections/DetailListingPhoto.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import React, { useContext } from "react" | ||
import { | ||
cloudinaryUrlFromId, | ||
t, | ||
GridSection, | ||
GridCell, | ||
MinimalTable, | ||
TableThumbnail, | ||
} from "@bloom-housing/ui-components" | ||
import { ListingContext } from "../../ListingContext" | ||
|
||
const DetailListingPhoto = () => { | ||
const listing = useContext(ListingContext) | ||
|
||
let listingFormPhoto = listing.image | ||
|
||
// Set listing photo from assets if necessary: | ||
if (listing.image == null && listing.assets.length > 0) { | ||
listingFormPhoto = listing.assets.find((asset) => asset.label == "building") | ||
} | ||
const listingPhotoUrl = /https?:\/\//.exec(listingFormPhoto.fileId) | ||
? listingFormPhoto.fileId | ||
: cloudinaryUrlFromId(listingFormPhoto.fileId) | ||
|
||
const photoTableHeaders = { | ||
preview: "t.preview", | ||
fileName: "t.fileName", | ||
} | ||
const photoTableData = [ | ||
{ | ||
preview: ( | ||
<TableThumbnail> | ||
<img src={listingPhotoUrl} /> | ||
</TableThumbnail> | ||
), | ||
fileName: listingFormPhoto.fileId.split("/").slice(-1).join(), | ||
}, | ||
] | ||
|
||
return ( | ||
<GridSection | ||
className="bg-primary-lighter" | ||
title={t("listings.sections.photoTitle")} | ||
grid={false} | ||
inset | ||
> | ||
<GridSection> | ||
<GridCell span={2}> | ||
<MinimalTable headers={photoTableHeaders} data={photoTableData}></MinimalTable> | ||
</GridCell> | ||
</GridSection> | ||
</GridSection> | ||
) | ||
} | ||
|
||
export default DetailListingPhoto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ import Units from "./sections/Units" | |
import { stringToBoolean, stringToNumber } from "../../../lib/helpers" | ||
import BuildingDetails from "./sections/BuildingDetails" | ||
import ListingIntro from "./sections/ListingIntro" | ||
import ListingPhoto from "./sections/ListingPhoto" | ||
import BuildingFeatures from "./sections/BuildingFeatures" | ||
import RankingsAndResults from "./sections/RankingsAndResults" | ||
import ApplicationAddress from "./sections/ApplicationAddress" | ||
|
@@ -120,6 +121,7 @@ const defaults: FormListing = { | |
disableUnitsAccordion: false, | ||
displayWaitlistSize: false, | ||
events: [], | ||
image: { fileId: "", label: "" }, | ||
leasingAgentAddress: defaultAddress, | ||
leasingAgentEmail: "[email protected]", | ||
leasingAgentName: "", | ||
|
@@ -401,6 +403,7 @@ const ListingForm = ({ listing, editMode }: ListingFormProps) => { | |
<div className="flex flex-row flex-wrap"> | ||
<div className="info-card md:w-9/12"> | ||
<ListingIntro /> | ||
<ListingPhoto /> | ||
<BuildingDetails /> | ||
<Units | ||
units={units} | ||
|
Oops, something went wrong.