Skip to content

Commit

Permalink
fix: rounding & icon for missing ai
Browse files Browse the repository at this point in the history
  • Loading branch information
TurtIeSocks committed Mar 16, 2024
1 parent 77eafa9 commit 4ed05ff
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
10 changes: 5 additions & 5 deletions packages/locales/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@ function getStatus() {
),
)
const mergedSize = Object.keys({ ...aiJson, ...humanJson }).length
const human = +(humanHas / total).toFixed(2) * 100
const localeTotal = Math.min(1, +(mergedSize / total).toFixed(2)) * 100
const human = (humanHas / total) * 100
const localeTotal = (mergedSize / total) * 100
return [
locale.replace('.json', ''),
{
human,
ai: localeTotal - human,
total: localeTotal,
human: +human.toFixed(2),
ai: +(localeTotal - human).toFixed(2),
total: +localeTotal.toFixed(2),
},
]
}),
Expand Down
7 changes: 4 additions & 3 deletions server/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,13 @@ startApollo(httpServer).then((server) => {
const definition = parse(req.body.query).definitions.find(
(d) => d.kind === 'OperationDefinition',
)
const endpoint = definition?.name?.value || ''
const errorCtx = {
id,
user,
clientV,
serverV,
endpoint: definition.name?.value || '',
endpoint,
}

if (clientV && serverV && clientV !== serverV) {
Expand All @@ -262,7 +263,7 @@ startApollo(httpServer).then((server) => {
})
}

if (!perms) {
if (!perms && endpoint !== 'Locales') {
throw new GraphQLError('session_expired', {
extensions: {
...errorCtx,
Expand All @@ -275,7 +276,7 @@ startApollo(httpServer).then((server) => {
if (
definition?.operation === 'mutation' &&
!id &&
definition?.name?.value !== 'SetTutorial'
endpoint !== 'SetTutorial'
) {
throw new GraphQLError('unauthenticated', {
extensions: {
Expand Down
7 changes: 5 additions & 2 deletions src/pages/locales/components/LocalesTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ import { useQuery } from '@apollo/client'
import TableCell from '@mui/material/TableCell'
import TableRow from '@mui/material/TableRow'
import Box from '@mui/material/Box'
import ClearIcon from '@mui/icons-material/Clear'

import { LOCALES_STATUS } from '@services/queries/config'
import { VirtualTable } from '@components/virtual/Table'

import { setScrolling, useLocalesStore } from '../hooks/store'
import { EditLocale } from './EditLocale'

const clear = <ClearIcon color="error" fontSize="small" />

/** @type {import('react-virtuoso').TableVirtuosoProps['fixedHeaderContent']} */
function fixedHeaderContent() {
const { t } = useTranslation()
Expand All @@ -30,8 +33,8 @@ function itemContent(_index, row) {
return (
<>
<TableCell>{row.name}</TableCell>
<TableCell>{row.english}</TableCell>
<TableCell>{row.ai}</TableCell>
<TableCell>{row.english || clear}</TableCell>
<TableCell>{row.ai || clear}</TableCell>
<TableCell width="40%">
<EditLocale
name={row.name}
Expand Down

0 comments on commit 4ed05ff

Please sign in to comment.