import { useState, useEffect } from 'react'
import { siteConfig } from 'site/site.config.mjs'
import { Spinner } from 'shared/components/spinner.mjs'
import { ChartWrapper } from 'shared/components/wrappers/chart.mjs'
import orderBy from 'lodash.orderby'
/*
* This method load the translation status from the Crowdin API
*/
const loadTranslationStatus = async (setter) => {
let response
try {
response = await fetch(
`https://api.crowdin.com/api/v2/projects/${siteConfig.crowdin.projectId}/languages/progress`,
{ headers: { Authorization: `Bearer ${siteConfig.crowdin.token}` } }
)
} catch (err) {
console.log(err)
setter(err)
}
if (response) {
const data = await response.json()
setter(data)
}
}
const Status = ({ done, approved }) => {
const option = {
series: [
{
name: 'Translation Status',
type: 'pie',
radius: ['40%', '70%'],
label: {
show: false,
},
emphasis: {
disabled: true,
},
data: [
{
value: approved,
name: 'Translated & Approved',
itemStyle: {
color: 'currentColor',
opacity: 1,
},
},
{
value: done,
name: 'Translated & Approved',
itemStyle: {
color: 'currentColor',
opacity: 0.7,
},
},
{
value: 100 - (done + approved),
name: 'Untranslated',
itemStyle: {
color: 'currentColor',
opacity: 0.3,
},
},
],
},
],
}
return