Skip to content

Commit

Permalink
feat: export with terms for partners (#4218)
Browse files Browse the repository at this point in the history
  • Loading branch information
emilyjablonski authored Jul 24, 2024
1 parent 2eea0b7 commit 161fef5
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 1 deletion.
48 changes: 48 additions & 0 deletions sites/partners/__tests__/pages/listings/lottery.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,54 @@ describe("lottery", () => {
expect(getAllByText("Export")).toHaveLength(2)
})

it("should show export with terms modal if user is a partner", async () => {
mockNextRouter({ id: "Uvbk5qurpB2WI9V6WnNdH" })
document.cookie = "access-token-available=True"
server.use(
rest.get("http://localhost/api/adapter/user", (_req, res, ctx) => {
return res(
ctx.json({
id: "user1",
userRoles: { isAdmin: false, isPartner: true },
listings: [{ id: "Uvbk5qurpB2WI9V6WnNdH" }],
})
)
}),
rest.post("http://localhost:3100/auth/token", (_req, res, ctx) => {
return res(ctx.json(""))
}),
rest.get("http://localhost/api/adapter/applicationFlaggedSets/meta", (_req, res, ctx) => {
return res(ctx.json({ totalCount: 5, totalPendingCount: 5 }))
})
)

const updatedListing = {
...listing,
lotteryLastRunAt: new Date("September 6, 2025 8:15:00"),
lotteryStatus: LotteryStatusEnum.publishedToPublic,
}
const { getByText, findByText, findAllByText, getAllByText } = render(
<Lottery listing={updatedListing} />
)

const header = await findByText("Partners Portal")
expect(header).toBeInTheDocument()

fireEvent.click(getByText("Export"))
expect(await findAllByText("Export lottery data")).toHaveLength(2)

expect(
getByText("This data was generated from the lottery that was run on 09/06/2025 at 8:15 am.", {
exact: false,
})
).toBeInTheDocument()
expect(
getByText("You must accept the Terms of Use before exporting this data.")
).toBeInTheDocument()

expect(getAllByText("Export")).toHaveLength(2)
})

it("should show no lottery released state as a partner", async () => {
mockNextRouter({ id: "Uvbk5qurpB2WI9V6WnNdH" })
document.cookie = "access-token-available=True"
Expand Down
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 @@ -257,6 +257,8 @@
"listings.lottery.runLottery": "Run lottery",
"listings.lottery.runLotteryContent": "Make sure to add all paper applications before running the lottery.",
"listings.lottery.runLotteryDuplicates": "Run lottery without resolving duplicates",
"listings.lottery.terms": "I acknowledge that downloading and using the information contained in the Application(s), Excel or CSV files is subject to the <a className='lined' href='https://www.exygy.com' target='_blank'>Terms of Use</a>, and further, the use, storage, possession and retention of personal identifiable information contained in the Application is subject to state and federal privacy laws. I agree on behalf of the Local Government or Professional Partner that such Professional Partner or Local Government will comply with the Terms of Use and applicable state and federal privacy laws in viewing, using, storing and possessing the Application and the information contained therein. I warrant that I am authorized to enter into agreements such as the Terms of Use on behalf of such Professional Partner or Local Government. <span className='font-semibold'>I agree to review for accuracy the spreadsheet(s) I download, per the guidance in the <a className='lined' href='https://www.exygy.com' target='_blank'>Partners Manual</a>, and to notify staff of any errors within 30 days of the close of the listing, or if a lottery will be conducted, at least three working days before the lottery is scheduled to be conducted.</span>",
"listings.lottery.termsAccept": "You must accept the Terms of Use before exporting this data.",
"listings.lotteryDateNotes": "Lottery Date Notes",
"listings.lotteryDateQuestion": "When will the lottery be run?",
"listings.lotteryEndTime": "Lottery End Time",
Expand Down
60 changes: 59 additions & 1 deletion sites/partners/src/pages/listings/[id]/lottery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import dayjs from "dayjs"
import Ticket from "@heroicons/react/24/solid/TicketIcon"
import Download from "@heroicons/react/24/solid/ArrowDownTrayIcon"
import ExclamationCirleIcon from "@heroicons/react/24/solid/ExclamationCircleIcon"
import Markdown from "markdown-to-jsx"
import { t, Breadcrumbs, BreadcrumbLink } from "@bloom-housing/ui-components"
import { Button, Card, Dialog, Heading, Icon, Message } from "@bloom-housing/ui-seeds"
import { CardHeader, CardSection } from "@bloom-housing/ui-seeds/src/blocks/Card"
Expand Down Expand Up @@ -37,6 +38,7 @@ const Lottery = (props: { listing: Listing }) => {
const [reRunModal, setReRunModal] = useState(false)
const [releaseModal, setReleaseModal] = useState(false)
const [exportModal, setExportModal] = useState(false)
const [termsExportModal, setTermsExportModal] = useState(false)
const [publishModal, setPublishModal] = useState(false)
const [retractModal, setRetractModal] = useState(false)
const [newApplicationsModal, setNewApplicationsModal] = useState(false)
Expand Down Expand Up @@ -82,7 +84,16 @@ const Lottery = (props: { listing: Listing }) => {
: t("listings.lottery.exportFileNoPreferences")}
</div>
<div>
<Button disabled={loading || csvExportLoading} onClick={() => setExportModal(true)}>
<Button
disabled={loading || csvExportLoading}
onClick={() => {
if (profile?.userRoles?.isAdmin) {
setExportModal(true)
} else {
setTermsExportModal(true)
}
}}
>
{t("t.export")}
</Button>
</div>
Expand Down Expand Up @@ -597,6 +608,53 @@ const Lottery = (props: { listing: Listing }) => {
</Button>
</Dialog.Footer>
</Dialog>
<Dialog
isOpen={!!termsExportModal}
ariaLabelledBy="terms-export-lottery-modal-header"
ariaDescribedBy="terms-export-lottery-modal-content"
onClose={() => setTermsExportModal(false)}
>
<Dialog.Header id="terms-export-lottery-modal-header">
{t("listings.lottery.export")}
</Dialog.Header>
<Dialog.Content id="terms-export-lottery-modal-content">
<p>
{listing.listingMultiselectQuestions.length
? t("listings.lottery.exportFile")
: t("listings.lottery.exportFileNoPreferences")}{" "}
{t("listings.lottery.exportContentTimestamp", {
date: dayjs(listing.lotteryLastRunAt).format("MM/DD/YYYY"),
time: dayjs(listing.lotteryLastRunAt).format("h:mm a"),
})}
</p>
<p>{t("listings.lottery.termsAccept")}</p>
<h2 className={styles["terms-of-use-header"]}>
{t("authentication.terms.termsOfUse")}
</h2>
<Markdown>{t("listings.lottery.terms")}</Markdown>
</Dialog.Content>
<Dialog.Footer>
<Button
variant="primary"
onClick={() => {
// export lottery
setTermsExportModal(false)
}}
size="sm"
>
{t("t.export")}
</Button>
<Button
variant="primary-outlined"
onClick={() => {
setTermsExportModal(false)
}}
size="sm"
>
{t("t.cancel")}
</Button>
</Dialog.Footer>
</Dialog>
<Dialog
isOpen={!!publishModal}
ariaLabelledBy="publish-lottery-modal-header"
Expand Down
6 changes: 6 additions & 0 deletions sites/partners/styles/lottery.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,9 @@
--message-max-width: 100%;
margin-bottom: var(--seeds-s4);
}

.terms-of-use-header {
font-size: var(--seeds-font-size-lg);
font-weight: var(--seeds-font-weight-semibold);
font-family: var(--seeds-font-sans);
}

0 comments on commit 161fef5

Please sign in to comment.