Intergate chức năng staff evaluation

This commit is contained in:
Truong Vo 2024-09-20 17:54:46 +07:00
parent 8ebe9eb57f
commit 0fe9228241
3 changed files with 39 additions and 15 deletions

View File

@ -89,23 +89,33 @@ class TechnicalController extends Controller
->orderBy('point', 'desc')
->get();
if ($technicals->isEmpty()) {
return AbstractController::ResultError("No technicals found for this user.");
// Lấy tất cả các technical
$allTechnicals = Technical::all();
if ($technicals->isEmpty() && $allTechnicals->isEmpty()) {
return AbstractController::ResultError("No technicals found.");
}
// Chuẩn bị dữ liệu để trả về
$technicalData = $technicals->map(function ($technicalUser) {
$technicalData = $allTechnicals->map(function ($technical) use ($technicals) {
// Tìm kiếm kỹ thuật từ bảng technical_users
$technicalUser = $technicals->firstWhere('technical_id', $technical->id);
return [
'id' => $technicalUser->technical->id,
'name' => $technicalUser->technical->name,
'level' => $technicalUser->technical->level,
'point' => $technicalUser->point,
'updated_at' => $technicalUser->updated_at
'id' => $technical->id,
'name' => $technical->name,
'level' => $technical->level,
'point' => $technicalUser ? $technicalUser->point : 0, // Nếu không tồn tại, điểm mặc định là 0
'updated_at' => $technicalUser ? $technicalUser->updated_at : null // Nếu không tồn tại, updated_at là null
];
});
return AbstractController::ResultSuccess($technicalData);
$sortedTechnicalData = $technicalData->sortByDesc('point')->values(); // values() để giữ lại chỉ số
return AbstractController::ResultSuccess($sortedTechnicalData);
}
public function getTechnicalsOfUser()
{
$userInfo = auth('admins')->user();

View File

@ -81,3 +81,4 @@ export const getAllTechByUserId =
API_URL + 'v1/admin/technical/get-tech-by-user-id'
export const evaluation = API_URL + 'v1/admin/evaluation/report'
export const sprintReview = API_URL + 'v1/admin/evaluation/sprint-review'

View File

@ -1,8 +1,8 @@
import {
evaluation,
getAllTechByUserId,
getAllUser,
getProfilesData,
evaluation,
sprintReview
} from '@/api/Admin'
import DataTableAll from '@/components/DataTable/DataTable'
import ProjectInvolvement from '@/components/ProjectInvolvement/ProjectInvolvement'
@ -10,10 +10,10 @@ import { get } from '@/rtk/helpers/apiService'
import { Box, Button, Loader, Select, Text, Title } from '@mantine/core'
import { DateInput } from '@mantine/dates'
import { notifications } from '@mantine/notifications'
import axios from 'axios'
import moment from 'moment'
import { useEffect, useState } from 'react'
import classes from './StaffEvaluation.module.css'
import axios from 'axios'
interface User {
id: number
@ -122,7 +122,7 @@ const StaffEvaluation = () => {
? moment(filterSearch.toDate).format('YYYY-MM-DD')
: null,
}
const res = await get(getProfilesData, params)
const res = await get(sprintReview, params)
if (res.status) {
return res.data
}
@ -175,7 +175,7 @@ const StaffEvaluation = () => {
}
fetchData()
}
}, [filter])
}, [filter?.userID])
const columns = [
{
@ -370,7 +370,20 @@ const StaffEvaluation = () => {
Loading . . .
</Text>
</Box>
{loading ? null : (
{!loading && dataProfile.length == 0 && (
<Box
style={{
marginTop: '10%',
textAlign: 'center',
display: 'block',
}}
>
<Text fw={600} c={'gray'}>
No Data Sprint
</Text>
</Box>
)}
{!loading && (
<ProjectInvolvement dataProfile={dataProfile} page="admin" />
)}
</Box>