-
Notifications
You must be signed in to change notification settings - Fork 317
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'HITK-TECH-Community:main' into main
- Loading branch information
Showing
8 changed files
with
268 additions
and
38 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
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,92 @@ | ||
import React, { useState } from "react"; | ||
import { Modal, Backdrop, Fade } from '@material-ui/core'; | ||
import { SimpleToast } from '../../../components/util/Toast' | ||
import {postAnswer} from '../../../service/Faq' | ||
import style from './AnswerModel.scss' | ||
|
||
export function AnswerModel(props) { | ||
const [answer, setAnswer] = useState("") | ||
const [toast, setToast] = useState({ | ||
toastStatus: false, | ||
toastType: "", | ||
toastMessage: "", | ||
}); | ||
const Tags = [ | ||
{ value: "ml" }, | ||
{ value: "open-source" }, | ||
{ value: "deap-learning" }, | ||
{ value: "cp" }, | ||
{ value: "block-chain" }, | ||
{ value: "mern" }, | ||
{ value: "android" }, | ||
{ value: "mean" }, | ||
{ value: "javascript" }, | ||
{ value: "java" }, | ||
{ value: "c++" }, | ||
{ value: "python" }, | ||
]; | ||
function handleSubmit(e) { | ||
e.preventDefault() | ||
if(answer!=""){ | ||
let data={question_id:props.data._id,answer,created_on:new Date(),created_by:"Anonymous"} | ||
postAnswer(data,setToast) | ||
setAnswer("") | ||
props.handleClose(false) | ||
}else{ | ||
setToast({toastStatus:true,toastMessage:"Please enter your answer",toastType:"error"}) | ||
} | ||
} | ||
return ( | ||
<div> | ||
{toast.toastStatus && ( | ||
<SimpleToast | ||
open={toast.toastStatus} | ||
message={toast.toastMessage} | ||
handleCloseToast={()=>{setToast({toastMessage:"",toastStatus:false,toastType:""})}} | ||
severity={toast.toastType} | ||
/> | ||
)} | ||
<Modal | ||
aria-labelledby="transition-modal-title" | ||
aria-describedby="transition-modal-description" | ||
className="modal" | ||
open={props.open} | ||
onClose={props.handleClose} | ||
closeAfterTransition | ||
BackdropComponent={Backdrop} | ||
BackdropProps={{ | ||
timeout: 500, | ||
}} | ||
> | ||
<Fade in={props.open}> | ||
<div className={"modal-container"}> | ||
<div className="close-icon-container"> | ||
<span onClick={() => { | ||
setAnswer("") | ||
props.handleClose(false) | ||
}}> | ||
<i class="fas fa-times close-icon"></i> | ||
</span> | ||
</div> | ||
<h2 className="ques-title">{props.data?.title}</h2> | ||
<p className="ques-description">{props.data?.description}</p> | ||
<div className="tag-container"> | ||
{ | ||
props && props.data?.tags?.map((tag, index) => { | ||
if (tag) | ||
return ( | ||
<p key={index}>#{Tags[index].value}</p> | ||
) | ||
}) | ||
} | ||
</div> | ||
<form className="answer-form" onSubmit={handleSubmit}> | ||
<input className="answer-field" onChange={(e) => { setAnswer(e.target.value) }} value={answer} type="text" placeholder="Post your answer" /> | ||
<button className="post-answer-btn">Post</button> | ||
</form> | ||
</div> | ||
</Fade> | ||
</Modal> | ||
</div> | ||
) | ||
} |
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,84 @@ | ||
:root{ | ||
font-family: "Futura LT Book"; | ||
} | ||
.modal-container { | ||
width: 70%; | ||
height: auto; | ||
background-color: white; | ||
outline: none !important; | ||
padding: 20px 20px; | ||
border-radius: 12px; | ||
h2{ | ||
margin: 0; | ||
} | ||
} | ||
|
||
.modal { | ||
display: flex; | ||
position: fixed; | ||
align-items: center; | ||
justify-content: center; | ||
align-items: center; | ||
overflow-y: scroll; | ||
outline: none !important; | ||
} | ||
.close-icon-container{ | ||
display: flex; | ||
justify-content: end; | ||
} | ||
.close-icon{ | ||
font-size: 24px; | ||
padding-right: 20px; | ||
cursor: pointer; | ||
color:#243e74; | ||
} | ||
.ques-title{ | ||
color:#243e74; | ||
} | ||
.ques-description{ | ||
font-size: 16px; | ||
margin: 10px auto; | ||
} | ||
.tag-container{ | ||
width: 100%; | ||
display: flex; | ||
gap: 8px; | ||
flex-wrap: wrap; | ||
} | ||
.answer-form{ | ||
width: 100%; | ||
margin: 14px auto; | ||
display: flex; | ||
justify-content: space-between; | ||
gap: 8px; | ||
} | ||
.answer-field{ | ||
width: 85%; | ||
padding: 10px 20px; | ||
outline: none; | ||
border: 1px solid #ccc; | ||
border-radius: 8px; | ||
} | ||
.post-answer-btn{ | ||
width: 15%; | ||
padding: 10px 20px; | ||
background-color: #243e74; | ||
border: none; | ||
color: #fff; | ||
border-radius: 8px; | ||
outline: none; | ||
} | ||
@media screen and (max-width:768px) { | ||
.modal-container{ | ||
width: 90%; | ||
} | ||
.close-icon{ | ||
padding-right: 5px; | ||
} | ||
.answer-field{ | ||
width: 70%; | ||
} | ||
.post-answer-btn{ | ||
width: 25%; | ||
} | ||
} |
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 @@ | ||
export * from './AnswerModel' |
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
Oops, something went wrong.