Skip to content

Commit

Permalink
feat: crisis support sections (#677)
Browse files Browse the repository at this point in the history
# Pull Request type



Please check the type of change your PR introduces:

- [ ] Bugfix
- [x] Feature
- [ ] Code style update (formatting, renaming)
- [ ] Refactoring (no functional changes, no API changes)
- [ ] Build-related changes
- [ ] Documentation content changes
- [ ] Other (please describe):

## What is the current behavior?



Issue Number: 
- IN-909
- PLI-37
- IN-908

## What is the new behavior?



-
-
-

## Does this introduce a breaking change?

- [ ] Yes
- [ ] No



## Other information




PR-URL: #677
Co-authored-by: Joe Karow <[email protected]>
Co-authored-by: InReach [Automated User] <[email protected]>
  • Loading branch information
3 people authored Aug 1, 2023
2 parents c4e7010 + 2124ad5 commit 810d9e1
Show file tree
Hide file tree
Showing 138 changed files with 4,681 additions and 838 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/crowdin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ on:
# - dev
- main
- l10n_**
- renovate/*

jobs:
synchronize-with-crowdin:
runs-on: ubuntu-latest
# permissions:
# contents: write
# pull-requests: write

steps:
- name: Checkout
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,5 @@ _generated/*

packages/db/backup

# internal temp scripts
___*.ts
47 changes: 47 additions & 0 deletions apps/app/lib/prebuild.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { Listr, type ListrDefaultRenderer, type ListrTask as ListrTaskObj, PRESET_TIMER } from 'listr2'

import fs from 'fs'
import path from 'path'

import { getEnv } from '@weareinreach/env'

const renderOptions = {
bottomBar: 10,
persistentOutput: true,
timer: PRESET_TIMER,
} satisfies ListrJob['options']
const injectOptions = (job: ListrJob): ListrJob => ({ ...job, options: renderOptions })

const tasks = new Listr(
[
injectOptions({
title: 'Inject CRON_KEY into vercel.json',
task: (_, task) => {
if (getEnv('VERCEL_ENV') !== 'production') {
return task.skip(`${task.title} (Not production deployment)`)
}
const regex = /\{\{KEY\}\}/
const vercelConfigFile = path.resolve(__dirname, '../vercel.json')
const vercelConfig = fs.readFileSync(vercelConfigFile, 'utf8')
fs.writeFileSync(vercelConfigFile, vercelConfig.replace(regex, getEnv('CRON_KEY')))
},
}),
],
{
rendererOptions: {
formatOutput: 'wrap',
timer: PRESET_TIMER,
suffixSkips: true,
collapseSubtasks: false,
},
fallbackRendererOptions: {
timer: PRESET_TIMER,
},
exitOnError: false,
forceColor: true,
}
)

tasks.run()

export type ListrJob = ListrTaskObj<unknown, ListrDefaultRenderer>
34 changes: 7 additions & 27 deletions apps/app/next-i18next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
/* eslint-disable turbo/no-undeclared-env-vars */
/* eslint-disable node/no-process-env */
// @ts-check
/* eslint-disable import/no-unused-modules */
// import axios from 'axios'
import LanguageDetector from 'i18next-browser-languagedetector'
import ChainedBackend from 'i18next-chained-backend'
import HttpBackend from 'i18next-http-backend'
import intervalPlural from 'i18next-intervalplural-postprocessor'
// import LocalStorageBackend from 'i18next-localstorage-backend'
import MultiBackend from 'i18next-multiload-backend-adapter'
// import { z } from 'zod'

import path from 'path'

Expand Down Expand Up @@ -42,32 +40,22 @@ const getUrl = (path) => {
return `http://localhost:${process.env.PORT ?? 3000}${parsedPath}` // dev SSR should use localhost
}

// const crowdinBackend = new CrowdinOtaBackend(undefined, )
const apiPath = '/api/i18n/load?lng={{lng}}&ns={{ns}}'
// const httpBackend = new HttpBackend(null, {
// loadPath: getUrl(apiPath), //typeof window !== 'undefined' ? apiPath : `http://localhost:3000${apiPath}`,
// allowMultiLoading: true,
// })

const multi = new MultiBackend(null, {
backend: HttpBackend,
// debounceInterval: 200,
backendOption: {
loadPath: getUrl(apiPath), //typeof window !== 'undefined' ? apiPath : `http://localhost:3000${apiPath}`,
loadPath: getUrl(apiPath),
allowMultiLoading: true,
},
})

/**
* @template {import('next-i18next').UserConfig} T
* @type {import('next-i18next').UserConfig}
* @param {T} config
* @constraint {{import('next-i18next').UserConfig}}
*/
/** @type {import('next-i18next').UserConfig} */
const config = {
i18n: {
defaultLocale: 'en',
locales: ['en', 'es', 'fr', 'ar', 'ru'], // ['en', 'en-US', 'en-CA', 'en-MX', 'es', 'es-US', 'es-MX'],
locales: ['en', 'es', 'fr', 'ar', 'ru'],
},
defaultNS: 'common',
localePath: path.resolve('./public/locales'),
Expand All @@ -85,26 +73,19 @@ const config = {

backend: {
backendOptions: [
// {
// expirationTime: 60 * 60 * 1000,
// },
{
backend: HttpBackend,
// debounceInterval: 200,
backendOption: {
loadPath: getUrl(apiPath), //isBrowser ? apiPath : `http://localhost:3000${apiPath}`,
loadPath: getUrl(apiPath),
allowMultiLoading: true,
},
},
],
backends: isBrowser ? [multi] : [], //[LocalStorageBackend, multi] : [],
backends: isBrowser ? [multi] : [],
},

// saveMissing: true,

// updateMissing: true,
serializeConfig: false,
use: isBrowser ? [ChainedBackend, intervalPlural] : [intervalPlural],
use: isBrowser ? [ChainedBackend, intervalPlural, LanguageDetector] : [intervalPlural, LanguageDetector],
maxParallelReads: 20,
joinArrays: '',
interpolation: {
Expand All @@ -120,6 +101,5 @@ const config = {
return value
},
},
// postProcess: ['interval'],
}
export default config
34 changes: 10 additions & 24 deletions apps/app/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* eslint-disable turbo/no-undeclared-env-vars */
/* eslint-disable node/no-process-env */
// import { env } from './src/env/server.mjs'
/* eslint-disable import/first */

import bundleAnalyze from '@next/bundle-analyzer'
import { PrismaPlugin } from '@prisma/nextjs-monorepo-workaround-plugin'
Expand All @@ -12,20 +10,13 @@ import path from 'path'
import { fileURLToPath } from 'url'

import i18nConfig from './next-i18next.config.mjs'
// import * as otel from './otel.mjs'

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)

const isVercelActiveDev = process.env.VERCEL_ENV === 'preview' && process.env.VERCEL_GIT_COMMIT_REF !== 'dev'
const isDev = process.env.NODE_ENV === 'development'

// const loadOtel = async () => {
// if (process.env.NEXT_RUNTIME === 'nodejs') {
// await import('./otel.mjs')
// }
// }

/* eslint-disable-next-line turbo/no-undeclared-env-vars */
const withBundleAnalyzer = bundleAnalyze({ enabled: process.env.ANALYZE === 'true' })
/** @type {import('next').NextConfig} */
const nextConfig = {
Expand All @@ -37,24 +28,20 @@ const nextConfig = {
...(process.env.VERCEL_ENV === 'production' ? { removeConsole: { exclude: ['error'] } } : {}),
},
experimental: {
// fontLoaders: [{ loader: 'next/font/google', options: { subsets: ['latin'] } }],
outputFileTracingExcludes: {
'*': ['**swc+core**', '**esbuild**'],
},
outputFileTracingRoot: path.join(__dirname, '../../'),
instrumentationHook: true,
// turbotrace: {
// logDetail: true,
// },
},
eslint: {
ignoreDuringBuilds: isVercelActiveDev,
},
images: {
remotePatterns: [
{protocol: 'https', hostname: '**.4sqi.net'}
]
images: {
remotePatterns: [{ protocol: 'https', hostname: '**.4sqi.net' }],
},
rewrites: async () => [{ source: '/search', destination: '/' }],

typescript: {
ignoreBuildErrors: isVercelActiveDev,
},
Expand All @@ -63,6 +50,7 @@ const nextConfig = {
config.plugins = [...config.plugins, new PrismaPlugin()]
}
config.plugins.push(new webpack.DefinePlugin({ __SENTRY_DEBUG__: false }))

return config
},
}
Expand All @@ -75,8 +63,7 @@ const nextConfig = {
* @returns {T}
*/
function defineNextConfig(config) {
// loadOtel()
return withBundleAnalyzer(withRoutes()(config))
return withBundleAnalyzer(withRoutes({ outDir: './src/types' })(config))
}
/**
* Wraps NextJS config with the Sentry config.
Expand All @@ -94,7 +81,6 @@ const defineSentryConfig = (nextConfig) =>

// Suppresses source map uploading logs during build
silent: true,

org: 'weareinreach',
project: 'inreach-app',
},
Expand All @@ -106,7 +92,7 @@ const defineSentryConfig = (nextConfig) =>
widenClientFileUpload: true,

// Transpiles SDK to be compatible with IE11 (increases bundle size)
transpileClientSDK: true,
transpileClientSDK: false,

// Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load)
tunnelRoute: '/monitoring',
Expand All @@ -118,5 +104,5 @@ const defineSentryConfig = (nextConfig) =>
disableLogger: true,
}
)
// export default defineNextConfig(nextConfig)
export default defineSentryConfig(defineNextConfig(nextConfig))

export default isDev ? defineNextConfig(nextConfig) : defineSentryConfig(defineNextConfig(nextConfig))
4 changes: 3 additions & 1 deletion apps/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"license": "GPL-3.0-only",
"scripts": {
"build": "next build",
"build:prebuild": "SKIP_ENV_VALIDATION=true tsx ./lib/prebuild.ts",
"clean:node": "rm -rf ./node_modules/ || true && rm -rf ./.next || true",
"dev": "next dev",
"dev:verbose": "NEXT_VERBOSE=1 next dev",
Expand Down Expand Up @@ -66,6 +67,7 @@
"@trpc/react-query": "10.36.0",
"@trpc/server": "10.36.0",
"@vercel/analytics": "1.0.1",
"@vercel/edge-config": "0.2.1",
"@vercel/kv": "0.2.2",
"@weareinreach/api": "workspace:*",
"@weareinreach/auth": "workspace:*",
Expand Down Expand Up @@ -95,7 +97,7 @@
"next-auth": "4.22.3",
"next-i18next": "14.0.0",
"next-seo": "6.1.0",
"nextjs-routes": "1.0.9",
"nextjs-routes": "2.0.1",
"object-sizeof": "2.6.3",
"pretty-bytes": "6.1.1",
"react": "18.2.0",
Expand Down
8 changes: 7 additions & 1 deletion apps/app/public/locales/en/attribute.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@
"cost-fees": "Incurs a cost",
"cost-free": "Free of cost"
},
"crisis-support-community": {
"elders": "Elders",
"general-lgbtq": "General LGBTQ+"
},
"eligibility": {
"CATEGORYNAME": "Eligibility Requirements",
"elig-age_max": "Under {{max}}",
Expand Down Expand Up @@ -106,7 +110,9 @@
"accesslocation": "Access Instructions - Location",
"accessphone": "Access Instructions - Phone",
"accesspublictransit": "Access Instructions - Public Transit",
"accesstext": "Access Instructions - Text"
"accesssms": "Access Instructions - SMS",
"accesstext": "Access Instructions - Text",
"accesswhatsapp": "Access Instructions - WhatsApp"
},
"srvfocus": {
"CATEGORYNAME": "Service Focus",
Expand Down
18 changes: 18 additions & 0 deletions apps/app/public/locales/en/common.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"about-us": "About Us",
"access": {
"sms-with-body": "Text <strong>{{body}}</strong> to {{code}}"
},
"accessible-building_false": "This building is NOT wheelchair accessible",
"accessible-building_true": "This building is wheelchair accessible",
"account": "Account",
Expand Down Expand Up @@ -50,6 +53,15 @@
},
"country-select": "Choose a country",
"create-new-list": "Create new list",
"crisis-support": {
"intl-stay-safe": "<Title3>📣 Please stay safe online</Title3>\n<Text>Visiting any of these websites <strong>may leave a record on your computer or browser</strong>, just like any website does after you visit it. Please take steps to avoid unsafe situations in your own area.</Text>",
"intl-these-verified": "These verified resources can help the LGBTQ+ community anywhere in the world.",
"intl-we-recommend": "We recommend these international resources",
"natl-find-help-now": "Find help now",
"natl-these-verified": "<Text>These verified resources can help the LGBTQ+ community in the United States. These services are <strong>remotely available, confidential,</strong> and <strong>free</strong>.</Text>",
"outside-service-area": "Inreach does not operate in {{country}}",
"who-this-serves": "<Text><strong>Who this resource serves:</strong> {{targetPop}}</Text>"
},
"current-location": "Current location",
"delete-account": "Delete your account?",
"delete-account-password": "Enter your account password to confirm.",
Expand Down Expand Up @@ -212,9 +224,12 @@
"search": {
"include-remote": "Include remote services",
"location-placeholder": "Enter city or zip code...",
"location-placeholder-searchby": "Search by city or zip code...",
"look-up-org": "Look up an organization by name",
"no-results": "No results found. Please try again.",
"no-results-adjust": "No results found for your search. Try adjusting your selected location or filters.",
"organization-placeholder": "Enter organization name...",
"organization-placeholder-searchby": "Search by organization name...",
"suggest-resource": "Can't find it? <1>Suggest an organization</1> you think should be included."
},
"send-email": "Send email",
Expand Down Expand Up @@ -353,9 +368,11 @@
"email": "Email",
"home": "Home",
"hours": "Hours",
"location": "Location",
"more": "more",
"next": "Next",
"no": "No",
"organization": "Organization",
"password": "Password",
"phone": "Phone",
"please-wait": "Please wait...",
Expand All @@ -372,6 +389,7 @@
"sign-up": "Sign up",
"skip": "Skip",
"support": "Support",
"website": "Website",
"yes": "Yes"
}
}
Loading

0 comments on commit 810d9e1

Please sign in to comment.