generated from ctc-uci/npo-template-merged
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from ctc-uci/67-implement-notifications-and-em…
…ail-system 67 implement notifications and email system
- Loading branch information
Showing
21 changed files
with
785 additions
and
266 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,62 @@ | ||
import React, { useState } from "react"; | ||
|
||
import { | ||
Button, | ||
Flex, | ||
Input, | ||
FormControl, | ||
FormErrorMessage | ||
} from "@chakra-ui/react"; | ||
|
||
import { useBackendContext } from "../../contexts/hooks/useBackendContext"; | ||
|
||
const SendEmailButton = () => { | ||
const { backend } = useBackendContext(); | ||
const [email, setEmail] = useState(""); | ||
const [error, setError] = useState(""); | ||
|
||
const validateEmail = (email) => { | ||
const regex = /\S+@\S+\.\S+/; | ||
return regex.test(email); | ||
}; | ||
|
||
const sendEmail = async () => { | ||
if (!validateEmail(email)) { | ||
setError("Please enter a valid email address."); | ||
return; | ||
} | ||
|
||
const response = await backend.post("/email/send", { | ||
to: email, | ||
subject: "Invoice", | ||
text: "This is a test email.", | ||
html: "<h1>This is a test email.</h1>" | ||
}); | ||
|
||
console.log(response.data); | ||
}; | ||
|
||
return ( | ||
<FormControl isInvalid={!!error}> | ||
<Flex direction="row" gap="1rem" width="100%"> | ||
<Input | ||
type="email" | ||
size="lg" | ||
placeholder="Enter invoice recipient email..." | ||
value={email} | ||
onChange={(e) => { | ||
setEmail(e.target.value); | ||
setError(""); | ||
}} | ||
> | ||
</Input> | ||
<Button size="lg" onClick={sendEmail}> | ||
Send Email | ||
</Button> | ||
</Flex> | ||
<FormErrorMessage>{error}</FormErrorMessage> | ||
</FormControl> | ||
); | ||
} | ||
|
||
export { SendEmailButton }; |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import Ckemail from "../../assets/icons/CkEmail.svg"; | ||
|
||
const EmailIcon = () => { | ||
return ( | ||
<img | ||
src={Ckemail} | ||
width={24} | ||
height={24} | ||
/> | ||
); | ||
}; | ||
|
||
export const InboxTab = () => { | ||
return ( | ||
<div | ||
style={{ | ||
display: "flex", | ||
flexDirection: "row", | ||
alignItems: "center", | ||
gap: "10px", | ||
fontSize: "20px", | ||
fontWeight: 600, | ||
color: "#7C15D4", | ||
borderBottom: "2px solid #9747FF", | ||
width: "200px", | ||
height: "46px", | ||
}} | ||
> | ||
<EmailIcon /> | ||
Primary Inbox | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.