Skip to content

Commit

Permalink
Add UI in admin dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
aviupadhyayula committed Feb 23, 2025
1 parent fc43d59 commit 52e7e67
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
59 changes: 59 additions & 0 deletions frontend/components/Settings/BulkEditTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,65 @@ const BulkEditTab = ({ tags, clubfairs, badges }: BulkEditTabProps) => {

return (
<>
<div className="box">
<div className="is-size-4">Email Blast</div>
<Text>
Sends an email blast to the selected group of users. Select a target
group and provide the message content. All active users with roles
equivalent to or higher than the selected group will be notified.
</Text>
<Formik
initialValues={{ target: '', content: '' }}
onSubmit={async (values, { setSubmitting, resetForm }) => {
try {
const resp = await doApiRequest(
'/clubs/email-blast/?format=json',
{
method: 'POST',
body: values,
},
)
const data = await resp.json()
if (data.detail) {
toast.success(data.detail, { hideProgressBar: true })
} else if (data.error) {
toast.error(data.error, { hideProgressBar: true })
}
} finally {
setSubmitting(false)
resetForm()
}
}}
>
{({ isSubmitting }) => (
<Form>
<Field
name="target"
as={SelectField}
choices={[
{ value: 'leaders', label: 'Leaders' },
{ value: 'officers', label: 'Officers' },
{ value: 'all', label: 'All' },
]}
label="Target Group"
/>
<Field
name="content"
as={TextField}
type="textarea"
label="Message Content"
/>
<button
type="submit"
className="button is-primary"
disabled={isSubmitting}
>
<Icon name="mail" /> Send Email Blast
</button>
</Form>
)}
</Formik>
</div>
<div className="box">
<div className="is-size-4">{OBJECT_NAME_TITLE_SINGULAR} Editing</div>
<Text>
Expand Down
2 changes: 1 addition & 1 deletion frontend/pages/admin/[[...slug]].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function AdminPage({
const tabs = [
{
name: 'bulk',
label: 'Bulk Editing',
label: 'Club Management',
content: () => (
<BulkEditTab badges={badges} clubfairs={clubfairs} tags={tags} />
),
Expand Down

0 comments on commit 52e7e67

Please sign in to comment.