Skip to content

Commit

Permalink
fix: language not synced for some text
Browse files Browse the repository at this point in the history
  • Loading branch information
linicam committed Nov 1, 2024
1 parent faa346b commit d857b3f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 21 deletions.
7 changes: 0 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 12 additions & 13 deletions packages/front-end/src/components/quartzTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
} from '@mui/material'
import { ALL_QUARTZ } from '@shared/constants/quartz'
import { ElementType } from '@shared/enums/elementType'
import { useContext, useEffect, useRef } from 'react'
import { useContext, useEffect, useState } from 'react'
import { globalContext } from '../contexts/globalContext'

import { ExpandMore } from '@mui/icons-material'
Expand Down Expand Up @@ -62,24 +62,15 @@ export const QuartzTable = (props: {
const [quartzTableExpanded, setQuartzTableExpanded] =
useSingletonLocalStorage('quartzTableExpanded', true)
const { t } = useTranslation()
const optionLabels = useRef(_loadOptionLabels())
const [optionLabels, setOptionLabels] = useState(_loadOptionLabels())
const theme = useTheme()
const textColor = theme.palette.text.primary
const customOrange = theme.palette.colors.customOrange

useEffect(() => {
optionLabels.current = _loadOptionLabels()
setOptionLabels(_loadOptionLabels())
}, [gc.language])

const getOptionLabel = (value: number) => {
if (value === -1) {
return optionLabels.current.disabled
} else if (value === 0) {
return optionLabels.current.enabled
}
return value
}

const updateQuartzState = (ev: SelectChangeEvent, id: number) => {
const copy = [...props.data]
copy[id] = parseInt(ev.target.value)
Expand Down Expand Up @@ -192,7 +183,15 @@ export const QuartzTable = (props: {
}}
>
<Typography>
{getOptionLabel(index - 1)}
{
optionLabels[
index < 1
? 'disabled'
: index > 1
? 'weighted'
: 'enabled'
]
}
</Typography>
{index === 0 && (
<ClearIcon
Expand Down
19 changes: 18 additions & 1 deletion packages/front-end/src/components/result.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,24 @@ export const Result = (props: {
}}
>
{quartzId === -1 ? (
<span></span>
<span
style={{
padding: '0 4px',
backgroundColor: limitedSlots[index]?.includes(
ind,
)
? colorMap[
getQuartzById(quartzId)
.elementType as keyof typeof colorMap
]
: 'unset',
color: limitedSlots[index]?.includes(ind)
? 'white'
: 'unset',
}}
>
</span>
) : (
<>
<span
Expand Down

0 comments on commit d857b3f

Please sign in to comment.