Skip to content

Commit

Permalink
Updated db to provide contact email address shown in footers
Browse files Browse the repository at this point in the history
  • Loading branch information
zachsa committed Oct 14, 2022
1 parent 3eeacd1 commit de81d79
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 11 deletions.
3 changes: 3 additions & 0 deletions src/api/src/graphql/resolvers/queries/client-context/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default async (self, args, ctx) => {
isDefault,
title,
shortTitle,
contactEmailAddress,
coalesce(frontMatter, ( select frontMatter from Tenants where shortTitle = '${DEFAULT_SHORTNAME}' ) ) frontMatter,
description,
theme,
Expand All @@ -34,6 +35,7 @@ export default async (self, args, ctx) => {
title,
isDefault,
description,
contactEmailAddress,
regionId,
shortTitle,
frontMatter,
Expand All @@ -48,6 +50,7 @@ export default async (self, args, ctx) => {
userAgent,
origin,
isDefault,
contactEmailAddress,
regionId,
title,
shortTitle,
Expand Down
1 change: 1 addition & 0 deletions src/api/src/graphql/schema/type-defs/main.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type ClientContext {
origin: String
isDefault: Boolean!
title: String
contactEmailAddress: String
shortTitle: String
frontMatter: JSON
description: String
Expand Down
10 changes: 7 additions & 3 deletions src/api/src/mssql/install-default-tenant/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default async () => {
.input('frontMatter', JSON.stringify(frontMatter))
.input('flagUrl', 'http/public-image/sa-flag.jpg')
.input('includeUnboundedSubmissions', 1)
.input('contactEmailAddress', '')
.input('theme', JSON.stringify(theme)).query(`
merge Tenants t
using (
Expand All @@ -49,7 +50,8 @@ export default async () => {
@logoUrl logoUrl,
@flagUrl flagUrl,
( select id from Regions where code = 'ZA') regionId,
@includeUnboundedSubmissions includeUnboundedSubmissions
@includeUnboundedSubmissions includeUnboundedSubmissions,
@contactEmailAddress contactEmailAddress
) s on s.hostname = t.hostname
when not matched
Expand All @@ -64,7 +66,8 @@ export default async () => {
logoUrl,
flagUrl,
regionId,
includeUnboundedSubmissions
includeUnboundedSubmissions,
contactEmailAddress
) values (
s.hostname,
s.isDefault,
Expand All @@ -76,7 +79,8 @@ export default async () => {
s.logoUrl,
s.flagUrl,
s.regionId,
s.includeUnboundedSubmissions
s.includeUnboundedSubmissions,
s.contactEmailAddress
)
when matched
Expand Down
1 change: 1 addition & 0 deletions src/api/src/mssql/sql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ create table Tenants (
flagUrl nvarchar(500),
regionId uniqueidentifier foreign key references Regions (id),
includeUnboundedSubmissions bit default 0 not null,
contactEmailAddress nvarchar(2000),
constraint frontMatter_json check ( isjson(frontMatter) = 1 ),
constraint json_theme check ( isjson(theme) = 1 )
);
Expand Down
10 changes: 6 additions & 4 deletions src/client/src/components/download-template/index.jsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import { useContext } from 'react'
import { context as authenticationContext } from '../../contexts/authentication'
import { context as clientContext } from '../../contexts/client-context'
import Icon from 'mdi-react/MicrosoftExcelIcon'
import Button from '@mui/material/Button'
import MessageDialogue from '../message-dialogue'
import Link from '@mui/material/Link'
import Typography from '@mui/material/Typography'
import { useTheme } from '@mui/material/styles'
import { NCCRD_API_HTTP_ADDRESS, NCCRD_DFFE_CONTACT } from '../../config'
import { NCCRD_API_HTTP_ADDRESS } from '../../config'
import useMediaQuery from '@mui/material/useMediaQuery'

export default () => {
const theme = useTheme()
const lgUp = useMediaQuery(theme.breakpoints.up('lg'))
const isAuthenticated = useContext(authenticationContext)
const { contactEmailAddress } = useContext(clientContext)

return (
<MessageDialogue
Expand All @@ -23,9 +25,9 @@ export default () => {
Download excel template for capturing submission data offline
</Typography>
<Typography variant="body2">
Please submit filled in templates to {NCCRD_DFFE_CONTACT.replace('@', ' [ at ] ')}. Note
that the online form is much easier to fill in, and the offline template is provided as
a backup in case the online form is not accessible for whatever reason
Please submit filled in templates to {contactEmailAddress.replace('@', ' [ at ] ')}.
Note that the online form is much easier to fill in, and the offline template is
provided as a backup in case the online form is not accessible for whatever reason
</Typography>
</>
}
Expand Down
10 changes: 8 additions & 2 deletions src/client/src/components/footer/_contact.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { useContext } from 'react'
import { context as clientContext } from '../../contexts/client-context'
import Grid from '@mui/material/Grid'
import Typography from '@mui/material/Typography'
import { NCCRD_TECHNICAL_CONTACT, NCCRD_DFFE_CONTACT } from '../../config'
import { NCCRD_TECHNICAL_CONTACT } from '../../config'

export default () => {
const { contactEmailAddress } = useContext(clientContext)

return (
<Grid container spacing={2}>
<Grid item xs={12}>
Expand All @@ -14,7 +18,9 @@ export default () => {
</Grid>
<Grid item xs={12}>
<Typography variant="body1">Data enquiries</Typography>
<Typography variant="body2">{NCCRD_DFFE_CONTACT.replace('@', ' [ at ] ')}</Typography>
<Typography variant="body2">
{contactEmailAddress?.replace('@', ' [ at ] ') || 'Missing contact address'}
</Typography>
</Grid>
</Grid>
)
Expand Down
2 changes: 0 additions & 2 deletions src/client/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,3 @@ export const PACKAGE_DESCRIPTION = process.env.PACKAGE_DESCRIPTION.toString()
export const PACKAGE_KEYWORDS = process.env.PACKAGE_KEYWORDS.toString().split(',')
export const NCCRD_TECHNICAL_CONTACT =
process.env.NCCRD_TECHNICAL_CONTACT || '[email protected]'

export const NCCRD_DFFE_CONTACT = process.env.NCCRD_DFFE_CONTACT || '[email protected]'
1 change: 1 addition & 0 deletions src/client/src/contexts/client-context/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default ({ routes, children }) => {
shortTitle
frontMatter
description
contactEmailAddress
logoUrl
flagUrl
region {
Expand Down

0 comments on commit de81d79

Please sign in to comment.