Skip to content

Commit

Permalink
feat: submit for approval flow (#3598)
Browse files Browse the repository at this point in the history
  • Loading branch information
emilyjablonski committed Aug 21, 2023
1 parent 8a7f6cf commit 4693050
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 5 deletions.
2 changes: 2 additions & 0 deletions sites/partners/page_content/locale_overrides/general.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@
"listings.approval.listingPublished": "Listing Published",
"listings.approval.reopen": "Reopen",
"listings.approval.requestChanges": "Request Changes",
"listings.approval.submitForApprovalDescription": "This will notify an administrator to review and approve the publication of this listing.",
"listings.approval.submittedForReview": "Submitted for Review",
"listings.atAnotherAddress": "At another address",
"listings.atLeasingAgentAddress": "At the leasing agent address",
"listings.closeThisListing": "Do you really want to close this listing?",
Expand Down
8 changes: 4 additions & 4 deletions sites/partners/src/components/listings/ListingFormActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ type ListingFormActionsProps = {
type: ListingFormActionsType
showCloseListingModal?: () => void
showLotteryResultsDrawer?: () => void
showSubmitForApprovalModal?: () => void
submitFormWithStatus?: (confirm?: boolean, status?: ListingStatus) => void
}

const ListingFormActions = ({
type,
showCloseListingModal,
showLotteryResultsDrawer,
showSubmitForApprovalModal,
submitFormWithStatus,
}: ListingFormActionsProps) => {
const listing = useContext(ListingContext)
Expand Down Expand Up @@ -211,10 +213,7 @@ const ListingFormActions = ({
styleType={AppearanceStyleType.success}
type="button"
fullWidth
onClick={() => {
// TODO throw a modal
submitFormWithStatus(false, ListingStatus.pendingReview)
}}
onClick={() => showSubmitForApprovalModal && showSubmitForApprovalModal()}
>
{t("t.submit")}
</Button>
Expand Down Expand Up @@ -448,6 +447,7 @@ const ListingFormActions = ({
router,
showCloseListingModal,
showLotteryResultsDrawer,
showSubmitForApprovalModal,
submitFormWithStatus,
type,
])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ const ListingForm = ({ listing, editMode }: ListingFormProps) => {
*/
const [listingIsAlreadyLiveModal, setListingIsAlreadyLiveModal] = useState(false)

/**
* Submit for approval modal
*/
const [submitForApprovalModal, setSubmitForApprovalModal] = useState(false)

useEffect(() => {
if (listing?.units) {
const tempUnits = listing.units.map((unit, i) => ({
Expand Down Expand Up @@ -200,7 +205,11 @@ const ListingForm = ({ listing, editMode }: ListingFormProps) => {

if (result) {
setSiteAlertMessage(
editMode ? t("listings.listingUpdated") : t("listings.listingSubmitted"),
editMode
? t("listings.listingUpdated")
: formattedData.status === ListingStatus.pendingReview
? t("listings.approval.submittedForReview")
: t("listings.listingSubmitted"),
"success"
)

Expand Down Expand Up @@ -394,6 +403,7 @@ const ListingForm = ({ listing, editMode }: ListingFormProps) => {
type={editMode ? ListingFormActionsType.edit : ListingFormActionsType.add}
showCloseListingModal={() => setCloseModal(true)}
showLotteryResultsDrawer={() => setLotteryResultsDrawer(true)}
showSubmitForApprovalModal={() => setSubmitForApprovalModal(true)}
submitFormWithStatus={triggerSubmitWithStatus}
/>
</aside>
Expand Down Expand Up @@ -500,6 +510,39 @@ const ListingForm = ({ listing, editMode }: ListingFormProps) => {
>
{t("listings.listingIsAlreadyLive")}
</Modal>

<Modal
open={submitForApprovalModal}
title={t("t.areYouSure")}
ariaDescription={t("listings.approval.submitForApprovalDescription")}
onClose={() => setSubmitForApprovalModal(false)}
actions={[
<Button
id="submitListingForApprovalButtonConfirm"
type="button"
styleType={AppearanceStyleType.success}
onClick={() => {
setSubmitForApprovalModal(false)
triggerSubmitWithStatus(false, ListingStatus.pendingReview)
}}
size={AppearanceSizeType.small}
dataTestId={"submitForApprovalButton"}
>
{t("t.save")}
</Button>,
<Button
type="button"
onClick={() => {
setSubmitForApprovalModal(false)
}}
size={AppearanceSizeType.small}
>
{t("t.cancel")}
</Button>,
]}
>
{t("listings.approval.submitForApprovalDescription")}
</Modal>
</>
)
}
Expand Down

0 comments on commit 4693050

Please sign in to comment.