import {getCurrentInstance} from "@tarojs/runtime";
import {curriculum, RecordData} from "@/api";
import {useEffect, useState} from "react";
import {View, Progress, CustomWrapper} from "@tarojs/components";
import './student.scss'
import Taro from "@tarojs/taro";

const Student = () => {
  const {id, name} = getCurrentInstance()?.router?.params as any
  const [data, setData] = useState<RecordData[]>([])

  const getData = () => {
    curriculum.record(id!).then(res => {
      setData(res)
    })
  }

  useEffect(() => {
    Taro.setNavigationBarTitle({title:name})
    getData()
  }, [])

  return (
    <CustomWrapper>
      {
        data.map(d => {
          return (
            <View className='college'>
              <View>{d.key}</View>
              <Progress percent={d.value} activeColor='red' active showInfo/>
            </View>
          )
        })
      }
      <View className='text-center py-1'>暂无更多数据</View>
    </CustomWrapper>
  )
}
export default Student
