-
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.
Signed-off-by: LoriaLawrenceZ <[email protected]>
- Loading branch information
1 parent
34556f2
commit 9b5fb72
Showing
8 changed files
with
204 additions
and
3 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
61 changes: 61 additions & 0 deletions
61
src/components/alertMessages/KnowledgeAlerts/KnowledgeAlerts.jsx
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,61 @@ | ||
import "../../../style/alertMessages/KnowledgeAlerts/KnowledgeAlerts.css"; | ||
import useKnowledgeContext from "../../../hook/Knowledge/useKnowledgeContext.jsx"; | ||
import {useEffect} from "react"; | ||
|
||
function KnowledgeAlerts() { | ||
|
||
const { | ||
isFileUploadErrorAlertVisible, setIsFileUploadErrorAlertVisible, | ||
fileUploadErrorMessage, | ||
isFileUploadSuccessAlertVisible, setIsFileUploadSuccessAlertVisible, | ||
fileUploadSuccessMessage | ||
} = useKnowledgeContext(); | ||
|
||
useEffect(() => { | ||
if (location.pathname === "/knowledge") { | ||
return; | ||
} | ||
|
||
setIsFileUploadErrorAlertVisible(false); | ||
setIsFileUploadSuccessAlertVisible(false); | ||
}, [location.pathname]); | ||
|
||
useEffect(() => { | ||
if (isFileUploadErrorAlertVisible) { | ||
const timer = setTimeout(() => { | ||
setIsFileUploadErrorAlertVisible(false); | ||
}, 2500); | ||
|
||
return () => clearTimeout(timer); | ||
} | ||
|
||
if (isFileUploadSuccessAlertVisible) { | ||
const timer = setTimeout(() => { | ||
setIsFileUploadSuccessAlertVisible(false); | ||
}, 2500); | ||
|
||
return () => clearTimeout(timer); | ||
} | ||
|
||
}, [isFileUploadErrorAlertVisible, isFileUploadSuccessAlertVisible]); | ||
|
||
return ( | ||
<section className="knowledge-card-alerts"> | ||
<span className={`knowledge-card-error-alert glass-effect ${isFileUploadErrorAlertVisible && "show-card-alert"}`}> | ||
{fileUploadErrorMessage} | ||
</span> | ||
|
||
<span className={`knowledge-card-success-alert glass-effect ${isFileUploadSuccessAlertVisible && "show-card-alert"}`}> | ||
{fileUploadSuccessMessage} | ||
</span> | ||
|
||
{/*<div className={`tester-knowledge-card-error-alert glass-effect ${isTesterAlertVisible && "tester-show-card-alert"}`}>*/} | ||
{/* <span className={`tester-card-title`}><b>AVISO PARA TESTER</b></span>*/} | ||
{/* <span className={`tester-card-email`}><b>Email</b>: tester</span>*/} | ||
{/* <span className={`tester-card-password`}><b>Senha</b>: tester</span>*/} | ||
{/*</div>*/} | ||
</section> | ||
); | ||
} | ||
|
||
export default KnowledgeAlerts; |
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,5 @@ | ||
import { createContext } from "react"; | ||
|
||
const KnowledgeContext = createContext(null); | ||
|
||
export default KnowledgeContext; |
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,29 @@ | ||
import KnowledgeContext from "./KnowledgeContext.jsx"; | ||
import PropTypes from "prop-types"; | ||
import {useState} from "react"; | ||
|
||
KnowledgeProvider.propTypes = { | ||
children: PropTypes.node.isRequired, | ||
}; | ||
|
||
function KnowledgeProvider({ children }) { | ||
const [fileName, setFileName] = useState(""); | ||
const [isFileUploadErrorAlertVisible, setIsFileUploadErrorAlertVisible] = useState(false); | ||
const [fileUploadErrorMessage, setFileUploadErrorMessage] = useState(""); | ||
const [isFileUploadSuccessAlertVisible, setIsFileUploadSuccessAlertVisible] = useState(false); | ||
const [fileUploadSuccessMessage, setFileUploadSuccessMessage] = useState(""); | ||
|
||
return ( | ||
<KnowledgeContext.Provider value={{ | ||
fileName, setFileName, | ||
isFileUploadErrorAlertVisible, setIsFileUploadErrorAlertVisible, | ||
fileUploadErrorMessage, setFileUploadErrorMessage, | ||
isFileUploadSuccessAlertVisible, setIsFileUploadSuccessAlertVisible, | ||
fileUploadSuccessMessage, setFileUploadSuccessMessage | ||
}}> | ||
{children} | ||
</KnowledgeContext.Provider> | ||
); | ||
} | ||
|
||
export default KnowledgeProvider; |
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,12 @@ | ||
import { useContext } from 'react'; | ||
import KnowledgeContext from '../../context/Knowledge/KnowledgeContext.jsx'; | ||
|
||
const useKnowledgeContext = () => { | ||
const context = useContext(KnowledgeContext); | ||
if (context === undefined) { | ||
throw new Error('useKnowledgeContext must be used within an KnowledgeProvider'); | ||
} | ||
return context; | ||
}; | ||
|
||
export default useKnowledgeContext; |
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
73 changes: 73 additions & 0 deletions
73
src/style/alertMessages/KnowledgeAlerts/KnowledgeAlerts.css
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,73 @@ | ||
.knowledge-card-alerts { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
height: 100vh; | ||
width: 100vw; | ||
position: fixed; | ||
color: var(--light-gray); | ||
z-index: 901; | ||
pointer-events: none; | ||
} | ||
|
||
/*-----===| ALERTS |===-----*/ | ||
.knowledge-card-error-alert { | ||
border: solid 1px var(--medium-red); | ||
background-color: rgba(var(--medium-red-rgb), 0.1); | ||
} | ||
|
||
.knowledge-card-success-alert, | ||
.account-card-success-alert { | ||
border: solid 1px var(--medium-green); | ||
background-color: rgba(var(--medium-green-rgb), 0.1); | ||
} | ||
|
||
.knowledge-card-error-alert , | ||
.knowledge-card-success-alert, | ||
.account-card-success-alert { | ||
border-radius: 5px; | ||
padding: 3px 6px; | ||
opacity: 0; | ||
transform: translateY(-100%); | ||
align-self: flex-start; | ||
transition: var(--all-500ms-custom); | ||
position: absolute; | ||
pointer-events: none; | ||
} | ||
.show-card-alert { | ||
opacity: 1; | ||
transform: translateY(calc(8vh + 30px + 100%)); /* Header + ele 1 dele mesmo*/ | ||
} | ||
|
||
|
||
/*-----===| Tester Alert Card |===-----*/ | ||
.tester-knowledge-card-error-alert { | ||
border-radius: 5px; | ||
max-width: 300px; | ||
width: 25%; | ||
min-width: 200px; | ||
padding: 3px 6px; | ||
opacity: 0; | ||
transform: translateY(calc(100vh + 100%)); | ||
align-self: flex-start; | ||
transition: var(--all-500ms-custom); | ||
position: absolute; | ||
pointer-events: none; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: flex-start; | ||
justify-content: center; | ||
|
||
& :first-child { | ||
align-self: center; | ||
padding: 5px 0; | ||
} | ||
} | ||
.tester-knowledge-card-error-alert { | ||
border: solid 1px var(--medium-red); | ||
background-color: rgba(var(--medium-red-rgb), 0.1); | ||
} | ||
.tester-show-card-alert { | ||
opacity: 1; | ||
transform: translateY(calc(100vh - 150%)); | ||
} |