-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Urgent component #104
Open
leowang801
wants to merge
10
commits into
main
Choose a base branch
from
urgent-component
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Urgent component #104
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6f43e57
add a new question to formBuilder js that asks if a request is urgent…
19dd2de
Add urgent question editor files
dc75212
Add urgent question to the drag and drop component
70dbbeb
fixed rendering issue with urgent question
4d08234
render urgent question when previewed and added default answers of ye…
57bad89
Question title rendered onChange, still want the default and question…
32c79f5
completed the frontend question
3a63dff
correctly multiplies cost by multiplier when urgent request is submitted
15c29bc
small correction in text for question box
17ce381
link to cost estimate tab
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,49 @@ | ||
.question-cancel-button{ | ||
font-size: 18px; | ||
/* text-align: center; */ | ||
background: transparent; | ||
border: none; | ||
align-self: right; | ||
} | ||
|
||
.single-select-option{ | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
width: 100%; | ||
} | ||
.single-select-option-delete{ | ||
height: 50%; | ||
} | ||
|
||
.single-select-options-container{ | ||
display: flex; | ||
margin-top: 2%; | ||
margin-bottom: 2%; | ||
width: 100%; | ||
padding-left: 5px; | ||
padding-right: 5px; | ||
} | ||
|
||
.new-question-input-container { | ||
display: flex; | ||
margin:none; | ||
padding:none; | ||
justify-content: left; | ||
align-items: center; | ||
width: 100%; | ||
} | ||
|
||
.new-question-input { | ||
display: flex; | ||
border: none; | ||
width: 100%; | ||
} | ||
|
||
.new-question-input:focus{ | ||
outline: none; | ||
} | ||
|
||
.new-question-checkbox{ | ||
width: 30px; | ||
} |
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,176 @@ | ||
import "./index.css"; | ||
import "../../index.css"; | ||
import { useEffect, useState } from "react"; | ||
import Radio from "@mui/material/Radio"; | ||
import RadioGroup from "@mui/material/RadioGroup"; | ||
import FormControlLabel from "@mui/material/FormControlLabel"; | ||
import FormControl from "@mui/material/FormControl"; | ||
import X from "../../../assets/X.png"; | ||
import DragDots from "../../../assets/DragDots.png"; | ||
import { useDispatch, useSelector } from "react-redux"; | ||
import uuid from "react-uuid"; | ||
import { | ||
DELETE_ANSWER, | ||
DELETE_QUESTION, | ||
LOAD_QUESTION, | ||
SAVE_ANSWER, | ||
SAVE_QUESTION, | ||
} from "../../../redux/actions/questionActions"; | ||
import { SET_LOGIC_QUESTION } from "../../../redux/actions/logicActions"; | ||
import EditComponentFooter from "../../EditComponentFooter"; | ||
|
||
function UrgentEditor({ question }) { | ||
const dispatch = useDispatch(); | ||
const questionList = useSelector( | ||
(state) => state.questionReducer.questionList | ||
); | ||
|
||
const [options, setOptions] = useState([]); | ||
const answerList = useSelector((state) => state.questionReducer.answerList); | ||
|
||
const [questionNum, setQuestionNum] = useState(""); | ||
const [title, setTitle] = useState(""); | ||
|
||
useEffect(() => { | ||
setQuestionNum(`Q${question.position_index}`); | ||
setTitle("Is this request urgent?"); | ||
}, [question]); | ||
|
||
useEffect(() => { | ||
var optionList = answerList[question.question_id ?? ""] ?? []; | ||
optionList = optionList.sort((a, b) => { | ||
let fa = a.answer; | ||
let fb = b.answer; | ||
|
||
if (fa < fb) { | ||
return -1; | ||
} | ||
if (fa > fb) { | ||
return 1; | ||
} | ||
return 0; | ||
}); | ||
optionList = optionList.filter((option) => option !== ""); | ||
optionList.push(""); | ||
optionList.unshift({answer_id: uuid(), answer: "No"}); | ||
optionList.unshift({answer_id: uuid(), answer: "Yes"}); | ||
setOptions(optionList); | ||
}, [answerList, question]); | ||
|
||
return ( | ||
<div className="GlobalEditorComponent"> | ||
<div className="GlobalEditorComponentHeader"> | ||
<div | ||
className="GlobalEditorQuestionNumber" | ||
onClick={() => { | ||
dispatch({ | ||
type: SET_LOGIC_QUESTION, | ||
payload: question, | ||
}); | ||
}} | ||
> | ||
{questionNum} | ||
</div> | ||
<input | ||
className="GlobalEditorQuestionTitleInput" | ||
defaultValue={title} | ||
placeholder="Type your form name here..." | ||
onChange={(event) => setTitle(event.target.value)} | ||
onBlur={() => { | ||
dispatch({ | ||
type: SAVE_QUESTION, | ||
payload: { | ||
...question, | ||
form_id: question.fk_form_id, | ||
question_title: title, //text.target.value, | ||
question_index: question.position_index, | ||
}, | ||
}); | ||
dispatch({ type: LOAD_QUESTION, payload: question.fk_form_id }); | ||
}} | ||
/> | ||
<img | ||
className="GlobalEditorDelete" | ||
src={X} | ||
alt="Delete" | ||
onClick={() => { | ||
questionList.forEach((questionObj) => { | ||
if (questionObj.position_index >= question.position_index) { | ||
questionObj.question_index = questionObj.position_index - 1; | ||
questionObj.question_title = questionObj.question; | ||
questionObj.form_id = questionObj.fk_form_id; | ||
dispatch({ type: SAVE_QUESTION, payload: questionObj }); | ||
} | ||
}); | ||
dispatch({ | ||
type: DELETE_QUESTION, | ||
payload: { | ||
question_id: question.question_id, | ||
}, | ||
}); | ||
dispatch({ type: LOAD_QUESTION, payload: question.fk_form_id }); | ||
}} | ||
/> | ||
</div> | ||
{/* Copy Everything Except Content Below For Reusability */} | ||
<div className="single-select-options-container"> | ||
<img className="GlobalDragDot" src={DragDots} alt="DragDots" /> | ||
<FormControl style={{ width: "100%" }}> | ||
<RadioGroup | ||
aria-labelledby="demo-radio-buttons-group-label" | ||
defaultValue="female" | ||
name="radio-buttons-group" | ||
> | ||
{options.map((option, index) => { | ||
return ( | ||
<div className="single-select-option" key={index}> | ||
<FormControlLabel control={<Radio />} /> | ||
<input | ||
type="text" | ||
className="new-question-input" | ||
defaultValue={option.answer} | ||
placeholder="Click to add new option" | ||
onBlur={(e) => { | ||
const answerVal = e.target.value; | ||
if (answerVal.trim() !== "") { | ||
dispatch({ | ||
type: SAVE_ANSWER, | ||
payload: { | ||
answer_id: option.answer_id ?? uuid(), | ||
fk_question_id: question.question_id, | ||
question_type: question.question_type, | ||
answer: answerVal, | ||
form_id: question.fk_form_id, | ||
}, | ||
}); | ||
} else { | ||
dispatch({ | ||
type: DELETE_ANSWER, | ||
payload: { | ||
answer_id: option.answer_id, | ||
form_id: question.fk_form_id, | ||
}, | ||
}); | ||
} | ||
setOptions([]); | ||
}} | ||
// If we want to have key down functionality as well: | ||
onKeyDown={(e) => { | ||
if (e.key === "Enter") { | ||
e.target.blur(); | ||
} | ||
}} | ||
/> | ||
</div> | ||
); | ||
})} | ||
</RadioGroup> | ||
</FormControl> | ||
</div> | ||
{/* Copy Everything Except Content Above For Reusability */} | ||
<EditComponentFooter question={question} /> | ||
</div> | ||
); | ||
} | ||
|
||
export default UrgentEditor; |
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,49 @@ | ||
.question-cancel-button{ | ||
font-size: 18px; | ||
/* text-align: center; */ | ||
background: transparent; | ||
border: none; | ||
align-self: right; | ||
} | ||
|
||
.single-select-option{ | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
width: 100%; | ||
} | ||
.single-select-option-delete{ | ||
height: 50%; | ||
} | ||
|
||
.single-select-options-container{ | ||
display: flex; | ||
margin-top: 2%; | ||
margin-bottom: 2%; | ||
width: 100%; | ||
padding-left: 5px; | ||
padding-right: 5px; | ||
} | ||
|
||
.new-question-input-container { | ||
display: flex; | ||
margin:none; | ||
padding:none; | ||
justify-content: left; | ||
align-items: center; | ||
width: 100%; | ||
} | ||
|
||
.new-question-input { | ||
display: flex; | ||
border: none; | ||
width: 100%; | ||
} | ||
|
||
.new-question-input:focus{ | ||
outline: none; | ||
} | ||
|
||
.new-question-checkbox{ | ||
width: 30px; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this console log