fix null tooltips
This commit is contained in:
parent
26a10d8550
commit
25bade6a02
8 changed files with 40 additions and 49 deletions
|
|
@ -2,31 +2,30 @@ import { Button, Card, CardContent, Tooltip } from "@mui/material"
|
|||
import { AnswerForm } from "controllers/FormControllers"
|
||||
import { useState } from "react"
|
||||
import MdPreview from "./MdPreview"
|
||||
export default function CreateAnswer({canAnswer, question_id}){
|
||||
export default function CreateAnswer({ canAnswer, question_id }) {
|
||||
const [show, setShow] = useState(false)
|
||||
|
||||
|
||||
function toggleShow(){
|
||||
|
||||
function toggleShow() {
|
||||
setShow(!show)
|
||||
}
|
||||
return(
|
||||
return (
|
||||
<div>
|
||||
<Tooltip title = {canAnswer ? null : "you need to be authenticated to answer or level 5 if the question is protected"}>
|
||||
<span>
|
||||
<Button disabled = {!canAnswer} variant = "contained" onClick = {toggleShow}>Add Answer</Button>
|
||||
</span>
|
||||
</Tooltip>
|
||||
{show ?
|
||||
<Card>
|
||||
<CardContent>
|
||||
<AnswerForm {...{question_id}} />
|
||||
<MdPreview/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
: null}
|
||||
|
||||
|
||||
<Tooltip title={canAnswer && 'You need to be authenticated to answer or level 5 if the question is protected'}>
|
||||
<span>
|
||||
<Button disabled={!canAnswer} variant="contained" onClick={toggleShow}>Add Answer</Button>
|
||||
</span>
|
||||
</Tooltip>
|
||||
{show && (
|
||||
<Card>
|
||||
<CardContent>
|
||||
<AnswerForm {...{ question_id }} />
|
||||
<MdPreview />
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,9 +42,9 @@ export default function Answer({
|
|||
</ListItemText>
|
||||
</ListItem>
|
||||
<ListItem sx={{ pl: 8 }}>
|
||||
<AnswerProvider>
|
||||
<AnswerCommentsList {...{ answer_id, comments }} />
|
||||
</AnswerProvider>
|
||||
{/* <AnswerProvider> */}
|
||||
<AnswerCommentsList {...{ answer_id, comments }} />
|
||||
{/* </AnswerProvider> */}
|
||||
</ListItem>
|
||||
</span>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
import { useEffect } from 'react';
|
||||
import { Divider, ListItem, ListItemText } from '@mui/material';
|
||||
import { useAnswer } from 'contexts';
|
||||
import { CreationInfoTag } from 'controllers';
|
||||
import { VoteControl } from 'controllers/QAControllers';
|
||||
import { getAnswerCommentVote, updateAnswerCommentVote } from 'services/questionsServices';
|
||||
|
|
@ -15,15 +13,9 @@ export default function AnswerComment({
|
|||
question_id,
|
||||
upvotes
|
||||
}) {
|
||||
const { answerData, setAnswerData } = useAnswer();
|
||||
|
||||
const getVote = () => getAnswerCommentVote(question_id, answer_id, comment_id);
|
||||
const updateVote = (data) => updateAnswerCommentVote(question_id, answer_id, comment_id, data);
|
||||
|
||||
useEffect(() => {
|
||||
setAnswerData(answerData + answer_id);
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<span key={comment_id}>
|
||||
<ListItem disablePadding>
|
||||
|
|
|
|||
|
|
@ -14,10 +14,10 @@ export default function CommentControl({
|
|||
return (
|
||||
<span>
|
||||
<ButtonGroup style={{ alignItems: 'center' }}>
|
||||
<Tooltip title = {!canComment ? "You must be level 3 to comment or level 5 if this question is protected" : null}>
|
||||
<Tooltip title={!canComment && "You must be level 3 to comment or level 5 if this question is protected"}>
|
||||
<span>
|
||||
<Button
|
||||
disabled = { !canComment}
|
||||
disabled={!canComment}
|
||||
color='inherit'
|
||||
disableRipple
|
||||
onClick={toggleShow}
|
||||
|
|
|
|||
|
|
@ -88,13 +88,13 @@ export default function Question({
|
|||
/>
|
||||
<Button component={Link} to='../ask' style={{'marginLeft': '10px'}}display = 'inline' m = {1} variant = "contained">Ask question</Button>
|
||||
|
||||
<Tooltip title = {!close ? "You must be level 7" : null}>
|
||||
<Tooltip title = {!close && "You must be level 7"}>
|
||||
<span>
|
||||
<Button disabled = {!close} style={{'marginLeft': '10px'}}display = 'inline' m = {1} variant = "contained" onClick = {changeProtect}>Close/Open</Button>
|
||||
</span>
|
||||
</Tooltip>
|
||||
|
||||
<Tooltip title = {!protect ? "You must be level 6 and this question must be open" : null}>
|
||||
<Tooltip title = {!protect && "You must be level 6 and this question must be open" }>
|
||||
<span>
|
||||
<Button disabled = {!protect} style={{'marginLeft': '10px'}}display = 'inline' m = {1} variant = "contained" onClick = {changeClose}>Protect</Button>
|
||||
</span>
|
||||
|
|
|
|||
|
|
@ -13,28 +13,28 @@ export default function VoteControl({
|
|||
}) {
|
||||
|
||||
return (
|
||||
<Tooltip title = {!canVote ? "This question must be open and you must be level 2 to vote" : null}>
|
||||
<span style={{ marginRight: 8 }}>
|
||||
<ButtonGroup {...{ orientation, style: { alignItems: 'center' } }}>
|
||||
<Tooltip title={!canVote && "This question must be open and you must be level 2 to vote"}>
|
||||
<span style={{ marginRight: 8 }}>
|
||||
<ButtonGroup {...{ orientation, style: { alignItems: 'center' } }}>
|
||||
<IconButton
|
||||
disabled={!canVote}
|
||||
onClick={handleUpvote}
|
||||
>
|
||||
<ThumbUpOutlinedIcon color={vote === 'upvoted' ? 'warning' : 'standard'} />
|
||||
</IconButton>
|
||||
<Tooltip title={`${upvotes} / ${downvotes}`} placement='right'>
|
||||
<Typography style={{ margin: 4, textAlign: 'center' }}>
|
||||
{upvotes - downvotes}
|
||||
</Typography>
|
||||
</Tooltip>
|
||||
<Tooltip title={`${upvotes} / ${downvotes}`} placement='right'>
|
||||
<Typography style={{ margin: 4, textAlign: 'center' }}>
|
||||
{upvotes - downvotes}
|
||||
</Typography>
|
||||
</Tooltip>
|
||||
<IconButton
|
||||
disabled={!canVote}
|
||||
onClick={handleDownvote}
|
||||
>
|
||||
<ThumbDownOutlinedIcon color={vote === 'downvoted' ? 'warning' : 'standard'} />
|
||||
</IconButton>
|
||||
</ButtonGroup>
|
||||
</span >
|
||||
</Tooltip>
|
||||
</ButtonGroup>
|
||||
</span >
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
|
|
@ -34,9 +34,9 @@ export default function Login() {
|
|||
</Typography>
|
||||
</CardContent>
|
||||
</Card>
|
||||
{returnMsg() ? (
|
||||
{returnMsg() && (
|
||||
<Alert severity='warning'> {returnMsg()} </Alert>
|
||||
) : null}
|
||||
)}
|
||||
</Grid>
|
||||
<Grid item xs={3.5} />
|
||||
</Grid>
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ export default function PaginatedListController({ count, Component, getData, noD
|
|||
// loadQuestions(sort);
|
||||
// }, 60000);
|
||||
|
||||
return data && (
|
||||
return (
|
||||
<PaginatedList {...{
|
||||
count: Math.ceil((count ?? data.length) / rowsPerPage),
|
||||
data: data.filter(d => d).slice((page - 1) * rowsPerPage, page * rowsPerPage),
|
||||
|
|
|
|||
Reference in a new issue