From f69ad686021d96b97094ec947e3bff756909ed6c Mon Sep 17 00:00:00 2001 From: Justin Walters Date: Tue, 28 Nov 2023 12:23:46 -0800 Subject: [PATCH 1/8] Send comp to CompPlex before Webapp Release urls still need to be updated --- .github/workflows/build.yml | 1 + .github/workflows/release.yml | 4 ++ scripts/env.js | 1 + src/app/UnitRentComp/RentCompForm.svelte | 10 ++--- src/services/BoweryService.js | 6 ++- src/services/CompPlexService.js | 55 ++++++++++++++++++++++++ webpack.config.js | 1 + 7 files changed, 72 insertions(+), 6 deletions(-) create mode 100644 src/services/CompPlexService.js diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 290f668..ea512d6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,6 +22,7 @@ jobs: NODE_ENV: production APP_ENV: ci BOWERY_APP_DOMAIN: https://webapp.bowery-dev.systems + COMPPLEX_DOMAIN: https://compplex-server.development.bowery.link/graphql GOOGLE_API_KEY: ${{secrets.GOOGLE_API_KEY}} AMPLITUDE_API_KEY: ${{secrets.CI_AMPLITUDE_KEY}} GENERATE_ARTIFACT: false diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 56b8428..f67b3c5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,10 +12,13 @@ jobs: include: - APP_ENV: production BOWERY_APP_DOMAIN: https://app.boweryvaluation.com + COMPPLEX_DOMAIN: https://compplex-server.development.bowery.link/graphql - APP_ENV: staging BOWERY_APP_DOMAIN: https://webapp.bowery-stg.systems + COMPPLEX_DOMAIN: https://compplex-server.development.bowery.link/graphql - APP_ENV: development BOWERY_APP_DOMAIN: https://webapp.bowery-dev.systems + COMPPLEX_DOMAIN: https://compplex-server.development.bowery.link/graphql steps: - name: Checkout uses: actions/checkout@v2 @@ -31,6 +34,7 @@ jobs: NODE_ENV: production APP_ENV: ${{matrix.APP_ENV}} BOWERY_APP_DOMAIN: ${{matrix.BOWERY_APP_DOMAIN}} + COMPPLEX_DOMAIN: ${{matrix.COMPPLEX_DOMAIN}} GOOGLE_API_KEY: ${{secrets.GOOGLE_API_KEY}} AMPLITUDE_API_KEY: ${{secrets[format('{0}_AMPLITUDE_KEY', matrix.APP_ENV)]}} - name: Release diff --git a/scripts/env.js b/scripts/env.js index a4b428f..1db5854 100644 --- a/scripts/env.js +++ b/scripts/env.js @@ -6,5 +6,6 @@ module.exports = { PORT: process.env.PORT || 3000, GOOGLE_API_KEY: process.env.GOOGLE_API_KEY, BOWERY_APP_DOMAIN: process.env.BOWERY_APP_DOMAIN, + COMPPLEX_DOMAIN: process.env.COMPPLEX_DOMAIN, AMPLITUDE_API_KEY: process.env.AMPLITUDE_API_KEY, } diff --git a/src/app/UnitRentComp/RentCompForm.svelte b/src/app/UnitRentComp/RentCompForm.svelte index 55a36c9..9822697 100644 --- a/src/app/UnitRentComp/RentCompForm.svelte +++ b/src/app/UnitRentComp/RentCompForm.svelte @@ -16,7 +16,7 @@ $: invalid = validateRentComp(values) -

Rent Comp

+

Rent Comp

dispatch('submit', values)}> { const [reportUrl] = url.match(/((\d|\w){24})/) @@ -12,8 +13,9 @@ const normalizeReportUrl = (url = '', domain) => { } class BoweryService { - constructor({ domain = BOWERY_APP_DOMAIN }) { + constructor({ domain = BOWERY_APP_DOMAIN, compPlexService = new CompPlexService() }) { this.domain = domain + this.compPlexService = compPlexService } async getAuthenticatedUser({ token }) { @@ -46,6 +48,8 @@ class BoweryService { } async addUnitComp(url, unitCompData) { + await this.compPlexService.addUnitComp(unitCompData) + const [id] = url.match(/((\d|\w){24})/) || [] if (!id) { throw new Error('Invalid parameters') diff --git a/src/services/CompPlexService.js b/src/services/CompPlexService.js new file mode 100644 index 0000000..c9e6476 --- /dev/null +++ b/src/services/CompPlexService.js @@ -0,0 +1,55 @@ +import axios from 'axios' +import get from 'lodash/get' +import { COMPPLEX_DOMAIN } from 'secrets' + +class CompPlexService { + constructor({ domain = COMPPLEX_DOMAIN } = {}) { + this.domain = domain + } + + async addUnitComp(unitCompData) { + const residentialLeaseInput = { + address: { + streetAddress: unitCompData.address, + city: unitCompData.city, + state: unitCompData.state, + postalCode: unitCompData.zip, + }, + leaseDate: unitCompData.dateOfValue, + unitNumber: unitCompData.unitNumber, + numberOfBedrooms: unitCompData.bedrooms, + propertyAndVersionReference: { propertyId: 'none', versionNumber: 0 }, // TODO: Remove this + leaseInformation: { + monthlyRent: unitCompData.rent, + rentType: 'marketRate', // TODO: confirm + }, + createdBy: 'justin.walters@boweryvaluation.com', // TODO: get user from AuthService + propertyInformation: {}, + resourceInformation: {}, + verificationInformation: {}, + } + + const body = { + query: `mutation upsertResidentialLeaseByAddress($input: CreateResidentialLeaseInput!) { + upsertResidentialLeaseByAddress(input: $input) { + id + } + }`, + variables: { input: residentialLeaseInput }, + } + + const response = await axios.post(this.domain, JSON.stringify(body), { + headers: { 'Content-Type': 'application/json' }, + }) + const errors = get(response, 'data.errors') + if (errors) { + console.warn('[CompPlexService] addUnitComp', errors) + const stringifiedErrors = JSON.stringify(errors) + throw new Error(stringifiedErrors) + } + const data = get(response, 'data.data') + return data + } +} + +export default CompPlexService diff --git a/webpack.config.js b/webpack.config.js index 33b56ef..d0769e8 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -88,6 +88,7 @@ const options = { 'process.env.VERSION': JSON.stringify(process.env.npm_package_version), 'process.env.GOOGLE_API_KEY': JSON.stringify(env.GOOGLE_API_KEY), 'process.env.BOWERY_APP_DOMAIN': JSON.stringify(env.BOWERY_APP_DOMAIN), + 'process.env.COMPPLEX_DOMAIN': JSON.stringify(env.COMPPLEX_DOMAIN), 'process.env.AMPLITUDE_API_KEY': JSON.stringify(env.AMPLITUDE_API_KEY), }), new CopyWebpackPlugin([ From ba12e056e136c93f9a52443072b240ced3d66e7b Mon Sep 17 00:00:00 2001 From: Justin Walters Date: Tue, 28 Nov 2023 15:44:21 -0800 Subject: [PATCH 2/8] Disable submit button if no report is filled in --- README.md | 2 ++ src/app/UnitRentComp/RentCompForm.svelte | 2 ++ src/app/components/DatePicker.svelte | 6 +++++- src/validation/index.js | 5 +++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index dceabfc..d3b0a6f 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ ``` GOOGLE_API_KEY=*** BOWERY_APP_DOMAIN=*** + COMPPLEX_DOMAIN=*** AMPLITUDE_API_KEY=*** APP_ENV=ci ``` @@ -38,6 +39,7 @@ Create `.env` file with the following content: ``` GOOGLE_API_KEY= BOWERY_APP_DOMAIN= +COMPPLEX_DOMAIN= AMPLITUDE_API_KEY= APP_ENV= NODE_ENV=production diff --git a/src/app/UnitRentComp/RentCompForm.svelte b/src/app/UnitRentComp/RentCompForm.svelte index 9822697..ed35602 100644 --- a/src/app/UnitRentComp/RentCompForm.svelte +++ b/src/app/UnitRentComp/RentCompForm.svelte @@ -7,12 +7,14 @@ import HelperText from '@smui/textfield/helper-text/index' import DatePicker from './../components/DatePicker.svelte' import Select from './../components/Select.svelte' + import { targetReport } from './../stores.js' import { UNIT_AMENITIES_LIST, UNIT_TYPES_LIST } from '../../constants' import validateRentComp from '../../validation' export let values const dispatch = createEventDispatcher() $: values.pricePerSqft = values.sqft ? (values.rent * 12) / values.sqft : NaN + $: values.report = $targetReport.value $: invalid = validateRentComp(values) diff --git a/src/app/components/DatePicker.svelte b/src/app/components/DatePicker.svelte index c85ecc2..386547c 100644 --- a/src/app/components/DatePicker.svelte +++ b/src/app/components/DatePicker.svelte @@ -5,6 +5,7 @@ import "flatpickr/dist/themes/light.css"; export let value; export let label; + export let required; const flatpickrOptions = { element: "#picker", dateFormat: "m-d-Y" @@ -29,6 +30,9 @@ label { height: 36px !important; } + .required::after { + content: " *"; + } @@ -37,7 +41,7 @@ id="picker" class="mdc-text-field flatpickr mdc-text-field--outlined mdc-text-field--dense"> - {label} + {label}
=0.0.4" @@ -10052,7 +10078,7 @@ "strip-indent": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-1.0.1.tgz", - "integrity": "sha1-DHlipq3vp7vUrDZkYKY4VSrhoKI=", + "integrity": "sha512-I5iQq6aFMM62fBEAIB/hXzwJD6EEZ0xEGCX2t7oXqaKPIRgt4WruAQ285BISgdkP+HLGWyeGmNJcpIwFeRYRUA==", "dev": true, "requires": { "get-stdin": "^4.0.1" @@ -10522,7 +10548,7 @@ "trim-newlines": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz", - "integrity": "sha1-WIeWa7WCpFA6QetST301ARgVphM=", + "integrity": "sha512-Nm4cF79FhSTzrLKGDMi3I4utBtFv8qKy4sq1enftf2gMdpqI8oVQTAfySkTz5r49giVzDj88SVZXP4CeYQwjaw==", "dev": true }, "true-case-path": { @@ -10561,7 +10587,7 @@ "tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "integrity": "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==", "dev": true, "requires": { "safe-buffer": "^5.0.1" @@ -10570,7 +10596,7 @@ "tweetnacl": { "version": "0.14.5", "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", - "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", + "integrity": "sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA==", "dev": true }, "type-check": { @@ -10868,7 +10894,7 @@ "verror": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", - "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", + "integrity": "sha512-ZZKSmDAEFOijERBLkmYfJ+vmk3w+7hOLYDNkRCuRuMJGEmqYNCNLyBBFwWKVMhfwaEF3WOd0Zlw86U/WC/+nYw==", "dev": true, "requires": { "assert-plus": "^1.0.0", @@ -10931,6 +10957,7 @@ "requires": { "anymatch": "~3.1.2", "braces": "~3.0.2", + "fsevents": "~2.3.2", "glob-parent": "~5.1.2", "is-binary-path": "~2.1.0", "is-glob": "~4.0.1", @@ -10948,6 +10975,13 @@ "to-regex-range": "^5.0.1" } }, + "fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "optional": true + }, "glob-parent": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", @@ -11329,7 +11363,7 @@ "yallist": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", - "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", + "integrity": "sha512-ncTzHV7NvsQZkYe1DW7cbDLm0YpzHmZF5r/iyP3ZnQtMiJ+pjzisCiMNI+Sj+xQF5pXhSHxSB3uDbsBTzY/c2A==", "dev": true }, "yaml": { diff --git a/package.json b/package.json index a2956e7..6c832b9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bowery-chrome-extension", - "version": "2.3.6", + "version": "2.4.0", "description": "Chrome extension for Bowery appraisers using the Bowery Authorship Application.", "scripts": { "build": "node scripts/build.js",