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";
import PageScript from "@/components/pageScript/pageScript";

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>
          )
        })
      }
      <PageScript/>
    </CustomWrapper>
  )
}
export default Student
