Skip to content

Commit

Permalink
feat: Show confirmation modal when publishing listings (#1847)
Browse files Browse the repository at this point in the history
* feat: Show confirmation modal when publishing listings

issue #1772

* Update changelog with #1772
  • Loading branch information
jaredcwhite authored Sep 22, 2021
1 parent 69ea88b commit 2de8062
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ All notable changes to this project will be documented in this file. The format

- Added:

- Show confirmation modal when publishing listings ([#1772](https://github.com/bloom-housing/bloom/pull/1772)) (Jared White)
- Split Listing form up into two main tabs ([#1644](https://github.com/bloom-housing/bloom/pull/1644)) (Jared White)
- Allow lottery results to be uploaded for a closed listing ([#1568](https://github.com/bloom-housing/bloom/pull/1568)) (Jared White)
- Update buttons / pages visibility depending on a user role ([#1609](https://github.com/bloom-housing/bloom/pull/1609)) (Dominik Barcikowski)
Expand Down
17 changes: 14 additions & 3 deletions sites/partners/src/listings/Aside.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type AsideProps = {
setStatus?: (status: ListingStatus) => void
showCloseListingModal?: () => void
showLotteryResultsDrawer?: () => void
showPublishModal?: () => void
}

type AsideType = "add" | "edit" | "details"
Expand All @@ -30,6 +31,7 @@ const Aside = ({
setStatus,
showCloseListingModal,
showLotteryResultsDrawer,
showPublishModal,
}: AsideProps) => {
const listing = useContext(ListingContext)

Expand Down Expand Up @@ -77,7 +79,7 @@ const Aside = ({
<Button
styleType={AppearanceStyleType.success}
fullWidth
onClick={() => setStatus(ListingStatus.active)}
onClick={() => showPublishModal && showPublishModal()}
>
{t("listings.actions.publish")}
</Button>
Expand Down Expand Up @@ -109,9 +111,10 @@ const Aside = ({
elements.push(
<GridCell key="btn-publish">
<Button
type="button"
styleType={AppearanceStyleType.success}
fullWidth
onClick={() => setStatus(ListingStatus.active)}
onClick={() => showPublishModal && showPublishModal()}
>
{t("listings.actions.publish")}
</Button>
Expand Down Expand Up @@ -213,7 +216,15 @@ const Aside = ({
}

return elements
}, [listing, listingId, setStatus, showCloseListingModal, showLotteryResultsDrawer, type])
}, [
listing,
listingId,
setStatus,
showCloseListingModal,
showLotteryResultsDrawer,
showPublishModal,
type,
])

return (
<>
Expand Down
36 changes: 36 additions & 0 deletions sites/partners/src/listings/PaperListingForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,11 @@ const ListingForm = ({ listing, editMode }: ListingFormProps) => {
*/
const [closeModal, setCloseModal] = useState(false)

/**
* Publish modal
*/
const [publishModal, setPublishModal] = useState(false)

/**
* Lottery results drawer
*/
Expand Down Expand Up @@ -662,6 +667,7 @@ const ListingForm = ({ listing, editMode }: ListingFormProps) => {
setStatus={setStatus}
showCloseListingModal={() => setCloseModal(true)}
showLotteryResultsDrawer={() => setLotteryResultsDrawer(true)}
showPublishModal={() => setPublishModal(true)}
/>
</aside>
</div>
Expand Down Expand Up @@ -701,6 +707,36 @@ const ListingForm = ({ listing, editMode }: ListingFormProps) => {
>
{t("listings.closeThisListing")}
</Modal>

<Modal
open={!!publishModal}
title={t("t.areYouSure")}
ariaDescription={t("listings.publishThisListing")}
onClose={() => setPublishModal(false)}
actions={[
<Button
styleType={AppearanceStyleType.success}
onClick={() => {
setStatus(ListingStatus.active)
triggerSubmit(getValues())
setPublishModal(false)
}}
>
{t("listings.actions.publish")}
</Button>,
<Button
styleType={AppearanceStyleType.secondary}
border={AppearanceBorderType.borderless}
onClick={() => {
setPublishModal(false)
}}
>
{t("t.cancel")}
</Button>,
]}
>
{t("listings.publishThisListing")}
</Modal>
</>
)
}
Expand Down
1 change: 1 addition & 0 deletions ui-components/src/locales/general.json
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,7 @@
"listings": {
"error": "There was an issue submitting the form.",
"closeThisListing": "Do you really want to close this listing?",
"publishThisListing": "Publishing will push the listing live on the public site.",
"active": "Accepting Applications",
"pending": "Coming Soon",
"closed": "Closed",
Expand Down

0 comments on commit 2de8062

Please sign in to comment.