forked from bloom-housing/bloom
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add user csv export (#1560) * feat: listing export (#1548) * feat: starting listing export * fix: wip building listing query * fix: csv support * fix: adding column definitions wip * fix: wip address query * fix: updates to fix query * fix: wip listing selects * fix: reformatted testing output * fix: completed select statements * fix: exporter service wip * fix: a11y features formatting * fix: wip adding to exporter * fix: wip lottery info formatting * fix: wip date formatting * fix: listings exporter service fields (95%) * fix: complete units csv building * fix: functioning zip download * fix: req.user type casting * fix: refactor to config approach * fix: various csv bugs * fix: debugging column values * fix: user access array * fix: clean up * fix: clean up pt 2 * fix: ui content and error handling * fix: ui content and error handling actually * fix: cleanup + cypress test * fix: cypress test and naming clean up * fix: unit test draft * fix: error handling fix * fix: removed unused seed * fix: functional cypress and wip unit tests * fix: one functional unit test * fix: functional unit tests * fix: wip error test * fix: error message test * fix: wip module mocking * fix: generateAsnyc readded to test * fix: controller cleanup * fix: functional success message testing * fix: testing cleanup * fix: further testing and comment cleanup * fix: toast timeout * fix: clean up formatting * fix: column cleanup * fix: console log cleanup * fix: rebase cleanup * fix: wip bug fixes * fix: wip data bug resolutions * fix: unit bug fixes * fix: formatting contd * fix: clean up * fix: button focus issue * fix: testing repository error * fix: include csv exporter service in test * fix: refined testing fix * fix: button color correction * fix: align sizing and export language --------- Co-authored-by: Yazeed Loonat <[email protected]> * fix: listings export clean up (#1590) * fix: local import * fix: unit tests fix * fix: add aria label to min/max rent fields (#1582) * fix: remove the due date question (#1584) * 1525/user access issue (#1592) * fix: include admin who are not partners * fix: correct user seed * fix: remove admin from permissions column * fix: testing cleanup * fix: change test location * fix: add undefined check * fix: add aria label to table (#1585) * fix: add aria label to table * fix: add aria labels to detail tables * fix: unit labeling on detailed page * fix: add aria-label to grouped table * fix: add descriptive alt tags to listings images (#1587) * fix: add descriptive alt tags to listings images * fix: add empty value to alt text * fix: remove redundant photo string * fix: remove redundant image string from translations * fix: change min/max rent inputs from number to text with only numbers (#1599) * fix: resolve bugs from bash (#1597) * fix: resolve bugs from bash * fix: paper app helper * fix: refine helper * fix: user export fixes (#1600) * fix: user export fixes * fix: fix tests * fix: add cypress downloads to gitignore file * fix: release scrub (#1604) * fix: align csv error messages * fix: timezone temporary approach * fix: align application export * fix: formatting case consistency * fix: missing UTC * feat: focus title on modal open (#1558) * feat: focus title on modal open * feat: bring back id to h1 in modal header * fix: add a11y statement (#1601) * fix: added english a11y statement * fix: formatting feedback * fix: spanish added * fix: add ar and bn * fix: remove unused div and styling --------- Co-authored-by: ColinBuyck <[email protected]> Co-authored-by: Yazeed Loonat <[email protected]> Co-authored-by: Krzysztof Zięcina <[email protected]> Co-authored-by: Emily Jablonski <[email protected]>
- Loading branch information
1 parent
8051ae7
commit b6fcd32
Showing
59 changed files
with
2,169 additions
and
335 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,67 @@ | ||
language: node_js | ||
node_js: | ||
- 14 | ||
- 14 | ||
cache: | ||
yarn: true | ||
services: | ||
- redis-server | ||
- redis-server | ||
before_install: | ||
- sudo sed -i -e '/local.*peer/s/postgres/all/' -e 's/peer\|md5/trust/g' /etc/postgresql/*/main/pg_hba.conf | ||
- sudo systemctl restart postgresql@11-main | ||
- sleep 1 | ||
- sudo sed -i -e '/local.*peer/s/postgres/all/' -e 's/peer\|md5/trust/g' /etc/postgresql/*/main/pg_hba.conf | ||
- sudo systemctl restart postgresql@11-main | ||
- sleep 1 | ||
before_script: | ||
- cp sites/public/.env.template sites/public/.env | ||
- cp sites/partners/.env.template sites/partners/.env | ||
- cp backend/core/.env.template backend/core/.env | ||
- cp sites/public/.env.template sites/public/.env | ||
- cp sites/partners/.env.template sites/partners/.env | ||
- cp backend/core/.env.template backend/core/.env | ||
jobs: | ||
include: | ||
- script: yarn build:app:public | ||
name: Build public site | ||
- script: yarn build:app:partners | ||
name: Build partners site | ||
- script: yarn test:backend:core:testdbsetup && yarn test:backend:core | ||
name: Backend unit tests | ||
- script: yarn test:e2e:backend:core | ||
name: Backend e2e tests | ||
- script: yarn test:app:public:unit | ||
name: Public site unit tests | ||
- stage: longer tests | ||
name: Partners site Cypress tests | ||
script: | ||
- yarn cypress install | ||
- cd backend/core | ||
- yarn db:reseed:detroit | ||
- yarn nest start & | ||
- cd ../../sites/partners | ||
- yarn build | ||
- yarn start -p 3001 & | ||
- yarn wait-on "http-get://localhost:3001" && yarn cypress run | ||
- kill $(jobs -p) || true | ||
- stage: longer tests | ||
name: Public site Cypress tests | ||
script: | ||
- yarn cypress install | ||
- yarn db:reseed | ||
- cd backend/core | ||
- yarn nest start & | ||
- cd ../../sites/public | ||
- yarn build | ||
- yarn start -p 3000 & | ||
- yarn wait-on "http-get://localhost:3000" && yarn cypress run | ||
- kill $(jobs -p) || true | ||
- script: yarn build:app:public | ||
name: Build public site | ||
- script: yarn build:app:partners | ||
name: Build partners site | ||
- script: yarn test:backend:core:testdbsetup && yarn test:backend:core | ||
name: Backend unit tests | ||
- script: yarn test:e2e:backend:core | ||
name: Backend e2e tests | ||
- script: yarn test:app:public:unit | ||
name: Public site unit tests | ||
- script: yarn test:app:partners:unit | ||
name: Partners site unit tests | ||
- stage: longer tests | ||
name: Partners site Cypress tests | ||
script: | ||
- yarn cypress install | ||
- cd backend/core | ||
- yarn db:reseed:detroit | ||
- yarn nest start & | ||
- cd ../../sites/partners | ||
- yarn build | ||
- yarn start -p 3001 & | ||
- yarn wait-on "http-get://localhost:3001" && yarn cypress run | ||
- kill $(jobs -p) || true | ||
- stage: longer tests | ||
name: Public site Cypress tests | ||
script: | ||
- yarn cypress install | ||
- yarn db:reseed | ||
- cd backend/core | ||
- yarn nest start & | ||
- cd ../../sites/public | ||
- yarn build | ||
- yarn start -p 3000 & | ||
- yarn wait-on "http-get://localhost:3000" && yarn cypress run | ||
- kill $(jobs -p) || true | ||
addons: | ||
postgresql: '11' | ||
postgresql: "11" | ||
apt: | ||
packages: | ||
- postgresql-11 | ||
- postgresql-client-11 | ||
- libgconf-2-4 | ||
- postgresql-11 | ||
- postgresql-client-11 | ||
- libgconf-2-4 | ||
env: | ||
global: PGPORT=5433 | ||
PGUSER=travis | ||
TEST_DATABASE_URL=postgres://localhost:5433/bloom_test | ||
REDIS_TLS_URL=redis://127.0.0.1:6379/0 | ||
NEW_RELIC_ENABLED=false | ||
NEW_RELIC_LOG_ENABLED=false | ||
NEW_RELIC_LOG_ENABLED=false |
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
36 changes: 36 additions & 0 deletions
36
backend/core/src/auth/services/user-csv-exporter.service.ts
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,36 @@ | ||
import { Injectable, Scope } from "@nestjs/common" | ||
import dayjs from "dayjs" | ||
import { Pagination } from "nestjs-typeorm-paginate" | ||
import { CsvBuilder } from "../../applications/services/csv-builder.service" | ||
import { User } from "../entities/user.entity" | ||
|
||
@Injectable({ scope: Scope.REQUEST }) | ||
export class UserCsvExporterService { | ||
constructor(private readonly csvBuilder: CsvBuilder) {} | ||
|
||
exportFromObject(users: Pagination<User>): string { | ||
const userObj = users.items.reduce((obj, user) => { | ||
const status = [] | ||
if (user.roles?.isAdmin) { | ||
status.push("Administrator") | ||
} | ||
if (user.roles?.isPartner) { | ||
status.push("Partner") | ||
} | ||
obj[user.id] = { | ||
"First Name": user.firstName, | ||
"Last Name": user.lastName, | ||
Email: user.email, | ||
Role: status.join(", "), | ||
"Date Created (UTC)": dayjs(user.createdAt).format("MM-DD-YYYY hh:mmA"), | ||
Status: user.confirmedAt ? "Confirmed" : "Unconfirmed", | ||
"Listing Names": | ||
user.leasingAgentInListings?.map((listing) => listing.name).join(", ") || "", | ||
"Listing Ids": user.leasingAgentInListings?.map((listing) => listing.id).join(", ") || "", | ||
"Last Logged In (UTC)": dayjs(user.lastLoginAt).format("MM-DD-YYYY hh:mmA"), | ||
} | ||
return obj | ||
}, {}) | ||
return this.csvBuilder.buildFromIdIndex(userObj) | ||
} | ||
} |
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,98 @@ | ||
import dayjs from "dayjs" | ||
import { MinMax } from "../../types" | ||
import { UnitGroupAmiLevelDto } from "../../src/units-summary/dto/unit-group-ami-level.dto" | ||
import { PaperApplication } from "../../src/paper-applications/entities/paper-application.entity" | ||
|
||
export const isDefined = (item: number | string): boolean => { | ||
return item !== null && item !== undefined && item !== "" | ||
} | ||
|
||
export const cloudinaryPdfFromId = (publicId: string): string => { | ||
if (isDefined(publicId)) { | ||
const cloudName = process.env.cloudinaryCloudName || process.env.CLOUDINARY_CLOUD_NAME | ||
return `https://res.cloudinary.com/${cloudName}/image/upload/${publicId}.pdf` | ||
} else return "" | ||
} | ||
|
||
export const formatDate = (rawDate: string, format: string): string => { | ||
if (isDefined(rawDate)) { | ||
return dayjs(rawDate).format(format) | ||
} else return "" | ||
} | ||
|
||
export const getPaperAppUrls = (paperApps: PaperApplication[]) => { | ||
if (!paperApps || paperApps?.length === 0) return "" | ||
const urlArr = paperApps.map((paperApplication) => | ||
cloudinaryPdfFromId(paperApplication.file?.fileId) | ||
) | ||
const formattedResults = urlArr.join(", ") | ||
return formattedResults | ||
} | ||
|
||
export const getRentTypes = (amiLevels: UnitGroupAmiLevelDto[]): string => { | ||
if (!amiLevels || amiLevels?.length === 0) return "" | ||
const uniqueTypes = [] | ||
amiLevels?.forEach((elem) => { | ||
if (!uniqueTypes.includes(elem.monthlyRentDeterminationType)) | ||
uniqueTypes.push(elem.monthlyRentDeterminationType) | ||
}) | ||
const formattedResults = uniqueTypes.map((elem) => convertToTitleCase(elem)).join(", ") | ||
return formattedResults | ||
} | ||
|
||
export const formatYesNo = (value: boolean | null): string => { | ||
if (value === null || typeof value == "undefined") return "" | ||
else if (value) return "Yes" | ||
else return "No" | ||
} | ||
|
||
export const formatStatus = { | ||
active: "Public", | ||
pending: "Draft", | ||
} | ||
|
||
export const formatBedroom = { | ||
oneBdrm: "1 BR", | ||
twoBdrm: "2 BR", | ||
threeBdrm: "3 BR", | ||
fourBdrm: "4 BR", | ||
fiveBdrm: "5 BR", | ||
studio: "Studio", | ||
} | ||
|
||
export const formatCurrency = (value: string): string => { | ||
return value ? `$${value}` : "" | ||
} | ||
|
||
export const convertToTitleCase = (value: string): string => { | ||
if (!isDefined(value)) return "" | ||
const spacedValue = value.replace(/([A-Z])/g, (match) => ` ${match}`) | ||
const result = spacedValue.charAt(0).toUpperCase() + spacedValue.slice(1) | ||
return result | ||
} | ||
|
||
export const formatRange = ( | ||
min: string | number, | ||
max: string | number, | ||
prefix: string, | ||
postfix: string | ||
): string => { | ||
if (!isDefined(min) && !isDefined(max)) return "" | ||
if (min == max || !isDefined(max)) return `${prefix}${min}${postfix}` | ||
if (!isDefined(min)) return `${prefix}${max}${postfix}` | ||
return `${prefix}${min}${postfix} - ${prefix}${max}${postfix}` | ||
} | ||
|
||
export function formatRentRange(rent: MinMax, percent: MinMax): string { | ||
let toReturn = "" | ||
if (rent) { | ||
toReturn += formatRange(rent.min, rent.max, "", "") | ||
} | ||
if (rent && percent) { | ||
toReturn += ", " | ||
} | ||
if (percent) { | ||
toReturn += formatRange(percent.min, percent.max, "", "%") | ||
} | ||
return toReturn | ||
} |
Oops, something went wrong.