diff --git a/src/lib/airtable/tables/requests.js b/src/lib/airtable/tables/requests.js index 98efe2a7..d9f07c8e 100644 --- a/src/lib/airtable/tables/requests.js +++ b/src/lib/airtable/tables/requests.js @@ -1,6 +1,6 @@ const { merge } = require("lodash"); const _ = require("lodash"); -const { airbase } = require("~airtable/bases"); +const { airbase } = require("../bases"); const requestNotInSlack = (r) => { const meta = r.get(fields.meta); @@ -322,6 +322,8 @@ const fields = (exports.fields = { neighborhood: "Neighborhood MA-NYC", householdSize: "Household Size", forDrivingClusters: "For Driving Clusters", + slackChannel: "slack_channel", + slackTimestamp: "slack_ts", }); exports.SENSITIVE_FIELDS = [ fields.phone, diff --git a/src/webapp/components/RequestPopup.js b/src/webapp/components/RequestPopup.js index e1db31c1..0edc9fa9 100644 --- a/src/webapp/components/RequestPopup.js +++ b/src/webapp/components/RequestPopup.js @@ -12,6 +12,7 @@ import HouseholdSizeChip from "./HouseholdSizeChip"; import DrivingClusterChip from "./DrivingClusterChip"; import { daysSinceSlackMessage } from "../helpers/time"; import ClusterMapContext from "../context/ClusterMapContext"; +import { fields } from "../../lib/airtable/tables/requests"; const useStyles = makeStyles((theme) => ({ divider: { @@ -70,17 +71,17 @@ const RequestPopup = ({ requests, closePopup }) => { underline="always" target="_blank" > - {meta["First Name"] || ""} + {meta[fields.firstName] || ""} ) : ( - meta["First Name"] + meta[fields.firstName] )} - {meta["Cross Street #1"]} + {meta[fields.crossStreetFirst]} {" and "} - {meta["Cross Street #2"]} + {meta[fields.crossStreetSecond]} @@ -91,9 +92,9 @@ const RequestPopup = ({ requests, closePopup }) => { - + - {meta["For Driving Clusters"] && } + {meta[fields.forDrivingClusters] && } {meta.slackPermalink ? ( diff --git a/src/workers/airtable-sync/actions/updateMessageContent.js b/src/workers/airtable-sync/actions/updateMessageContent.js index 19d06439..9bbbbce5 100644 --- a/src/workers/airtable-sync/actions/updateMessageContent.js +++ b/src/workers/airtable-sync/actions/updateMessageContent.js @@ -24,7 +24,7 @@ const mappings = { module.exports = async function updateMessageContent(record) { /* eslint dot-notation: ["error", { "allowPattern": "^[a-z]+(_[a-z]+)+$" }] */ const meta = record.getMeta(); - if (!meta["slack_ts"]) { + if (!requestFields.slackTimestamp) { return; } const existingMessage = await getExistingMessage( @@ -69,8 +69,8 @@ module.exports = async function updateMessageContent(record) { } await slackapi.chat.update({ - channel: meta["slack_channel"], - ts: meta["slack_ts"], + channel: requestFields.slackChannel, + ts: requestFields.slackTimestamp, text: newContent, }); };