Formatting

This commit is contained in:
Kurt Hutten
2021-06-29 17:17:21 +10:00
parent 726945c2ab
commit 7417499d4b
11 changed files with 92 additions and 66 deletions

View File

@@ -1,37 +1,55 @@
import {useState} from 'react'
import { useState } from 'react'
import { useMutation } from '@redwoodjs/web'
import { toast, Toaster } from '@redwoodjs/web/toast'
const SEND_EMAIL_MUTATION = gql`
mutation sendEmailMutation($email: Email!) {
sendAllUsersEmail(input: $email) {
accepted
sendAllUsersEmail(input: $email) {
accepted
}
}
}
`
const AdminEmailPage = () => {
const [subject, setSubject] = useState('')
const [body, setBody] = useState('')
const [sendEmailMutation] = useMutation(SEND_EMAIL_MUTATION, {
onCompleted: ({sendAllUsersEmail}) => {
onCompleted: ({ sendAllUsersEmail }) => {
toast.success(`Emails sent, ${sendAllUsersEmail?.accepted.join(', ')}`)
setSubject('')
setBody('')
},
})
const sendEmail = () => sendEmailMutation({ variables: { email: { subject, body } } })
const sendEmail = () =>
sendEmailMutation({ variables: { email: { subject, body } } })
return (
<div className="flex justify-center">
<div className="max-w-7xl pt-8">
<h2 className="" style={{width: '46rem'}}>Email all users</h2>
<h2 className="" style={{ width: '46rem' }}>
Email all users
</h2>
<label htmlFor="subject">Subject</label>
<input name="subject" className="rounded border border-gray-400 px-2 w-full" value={subject} onChange={({target}) => setSubject(target.value)}/>
<input
name="subject"
className="rounded border border-gray-400 px-2 w-full"
value={subject}
onChange={({ target }) => setSubject(target.value)}
/>
<label htmlFor="body">Body</label>
<textarea className="w-full rounded border border-gray-400 p-2" name="text" value={body} onChange={({target}) => setBody(target.value)}></textarea>
<button className="rounded px-2 p-1 mt-4 bg-ch-purple-400 text-indigo-200" onClick={sendEmail}>Send</button>
<textarea
className="w-full rounded border border-gray-400 p-2"
name="text"
value={body}
onChange={({ target }) => setBody(target.value)}
></textarea>
<button
className="rounded px-2 p-1 mt-4 bg-ch-purple-400 text-indigo-200"
onClick={sendEmail}
>
Send
</button>
</div>
<Toaster timeout={1500} />
</div>

View File

@@ -1,6 +1,6 @@
import { useState, useEffect } from 'react'
import SubjectAccessRequestsCell from 'src/components/SubjectAccessRequestsCell'
import { Flash, useQuery, useMutation, useFlash } from '@redwoodjs/web'
import { useQuery, useMutation } from '@redwoodjs/web'
import { Form, Submit } from '@redwoodjs/forms'
import MainLayout from 'src/layouts/MainLayout'