-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: allow users to request registration codes
- Loading branch information
1 parent
c6c2124
commit 08c580e
Showing
6 changed files
with
277 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...src/auth/components/requestRegistrationFormModal/RequestRegistrationFormModal.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import RequestRegistrationFormModal from "./RequestRegistrationFormModal"; | ||
import { Meta, StoryObj } from "@storybook/react"; | ||
|
||
const meta: Meta<typeof RequestRegistrationFormModal> = { | ||
title: "Invitations/RequestRegistrationFormModal", | ||
component: RequestRegistrationFormModal, | ||
tags: ["autodocs"], | ||
argTypes: { | ||
onClose: { action: "close" }, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof RequestRegistrationFormModal>; | ||
|
||
export const Shown: Story = { | ||
args: { | ||
open: true, | ||
}, | ||
}; |
123 changes: 123 additions & 0 deletions
123
...end-new/src/auth/components/requestRegistrationFormModal/RequestRegistrationFormModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
import React, { useState } from "react"; | ||
import * as Sentry from "@sentry/react"; | ||
import { useSnackbar } from "src/theme/SnackbarProvider/SnackbarProvider"; | ||
import { Box, Modal, TextField, Typography, useTheme } from "@mui/material"; | ||
import PrimaryButton from "src/theme/PrimaryButton/PrimaryButton"; | ||
import PrimaryIconButton from "src/theme/PrimaryIconButton/PrimaryIconButton"; | ||
import CloseIcon from "@mui/icons-material/Close"; | ||
|
||
export interface RequestRegistrationFormModalProps { | ||
open: boolean; | ||
onClose: () => void; | ||
} | ||
|
||
const style = { | ||
position: "absolute", | ||
top: "50%", | ||
left: "50%", | ||
transform: "translate(-50%, -50%)", | ||
maxWidth: 400, | ||
width: "100%", | ||
bgcolor: "background.paper", | ||
boxShadow: 24, | ||
borderRadius: 1, | ||
p: 4, | ||
}; | ||
|
||
const RequestRegistrationFormModal: React.FC<RequestRegistrationFormModalProps> = ({ open, onClose }) => { | ||
const theme = useTheme(); | ||
const { enqueueSnackbar } = useSnackbar(); | ||
|
||
const [name, setName] = useState(""); | ||
const [email, setEmail] = useState(""); | ||
const [message, setMessage] = useState(""); | ||
|
||
const handleSubmit = async () => { | ||
// Send the user information to Sentry | ||
Sentry.captureFeedback({ | ||
name, | ||
email, | ||
message: `User requested a registration code. Additional info: ${message || "None"}`, | ||
}); | ||
|
||
enqueueSnackbar("Registration code request submitted successfully. We will get back to you soon.", { | ||
variant: "success", | ||
}); | ||
|
||
resetForm(); | ||
}; | ||
|
||
// Reset the form fields and close the modal | ||
const resetForm = () => { | ||
setName(""); | ||
setEmail(""); | ||
setMessage(""); | ||
onClose(); | ||
}; | ||
|
||
return ( | ||
<Modal open={open} onClose={onClose}> | ||
<Box sx={style}> | ||
<PrimaryIconButton | ||
title="Close request registration code form" | ||
onClick={onClose} | ||
sx={{ | ||
position: "absolute", | ||
right: 8, | ||
top: 8, | ||
color: theme.palette.grey[500], | ||
}} | ||
> | ||
<CloseIcon /> | ||
</PrimaryIconButton> | ||
<Typography variant="h4" gutterBottom> | ||
Registration Code Request | ||
</Typography> | ||
<Typography variant="body2" gutterBottom> | ||
Your request will be reviewed, and we will reach out to you soon. | ||
</Typography> | ||
<TextField | ||
fullWidth | ||
label="Name" | ||
type="text" | ||
variant="outlined" | ||
margin="normal" | ||
required | ||
value={name} | ||
onChange={(e) => setName(e.target.value)} | ||
/> | ||
<TextField | ||
fullWidth | ||
label="Email" | ||
type="email" | ||
variant="outlined" | ||
margin="normal" | ||
required | ||
value={email} | ||
onChange={(e) => setEmail(e.target.value)} | ||
/> | ||
<TextField | ||
fullWidth | ||
placeholder="Tell us how you intend to use compass" | ||
variant="outlined" | ||
margin="normal" | ||
required | ||
multiline | ||
rows={3} | ||
value={message} | ||
onChange={(e) => setMessage(e.target.value)} | ||
/> | ||
<PrimaryButton | ||
disableWhenOffline={true} | ||
fullWidth | ||
onClick={handleSubmit} | ||
disabled={!name || !email || !message} | ||
> | ||
Submit | ||
</PrimaryButton> | ||
</Box> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default RequestRegistrationFormModal; |
Oops, something went wrong.