mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-03-26 10:31:10 -04:00
Fix index and total not refreshing
This commit is contained in:
@@ -2,7 +2,7 @@ import clsx from 'clsx'
|
||||
import {User} from 'common/user'
|
||||
import Link from 'next/link'
|
||||
import router from 'next/router'
|
||||
import {useMemo, useState} from 'react'
|
||||
import {useEffect, useMemo, useState} from 'react'
|
||||
import toast from 'react-hot-toast'
|
||||
import {Button} from 'web/components/buttons/button'
|
||||
import {compareBySort, CompatibilitySort} from 'web/components/compatibility/sort-widget'
|
||||
@@ -167,6 +167,11 @@ function AnswerCompatibilityQuestionModal(props: {
|
||||
const [showOnboarding, setShowOnboarding] = useState(fromSignup ?? false)
|
||||
const [sort, setSort] = useState<CompatibilitySort>('random')
|
||||
|
||||
useEffect(() => {
|
||||
refreshCompatibilityAll()
|
||||
setQuestionIndex(0)
|
||||
}, [sort])
|
||||
|
||||
const sortedQuestions = useMemo(() => {
|
||||
return [...otherQuestions].sort((a, b) => {
|
||||
return compareBySort(a, b, sort)
|
||||
|
||||
@@ -157,22 +157,6 @@ export function AnswerCompatibilityQuestionContent(props: {
|
||||
return (
|
||||
<Col className="min-h-0 w-full gap-4">
|
||||
<Col className="gap-1 shrink-0">
|
||||
{/*{compatibilityQuestion.importance_score > 0 && <Row className="text-blue-400 -mt-4 w-full justify-start text-sm">*/}
|
||||
{/* <span>*/}
|
||||
{/* Massive upgrade coming soon! More prompts, better predictive power, filtered by category, etc.*/}
|
||||
{/* </span>*/}
|
||||
{/*</Row>}*/}
|
||||
{index !== null &&
|
||||
index !== undefined &&
|
||||
total !== null &&
|
||||
total !== undefined &&
|
||||
total > 1 && (
|
||||
<Row className="text-ink-500 -mt-4 w-full justify-end text-sm">
|
||||
<span>
|
||||
<span className="text-ink-600 font-semibold">{index + 1}</span> / {total}
|
||||
</span>
|
||||
</Row>
|
||||
)}
|
||||
<Row>
|
||||
{shortenedPopularity && (
|
||||
<Tooltip
|
||||
@@ -188,6 +172,11 @@ export function AnswerCompatibilityQuestionContent(props: {
|
||||
</Row>
|
||||
</Tooltip>
|
||||
)}
|
||||
{isFinite(index!) && isFinite(total!) && (
|
||||
<span className={'ml-16 text-sm'}>
|
||||
<span className="text-ink-600 font-semibold">{index! + 1}</span> / {total}
|
||||
</span>
|
||||
)}
|
||||
{sort && setSort && (
|
||||
<CompatibilitySortWidget
|
||||
className="text-sm sm:flex ml-auto"
|
||||
|
||||
Reference in New Issue
Block a user