chore(frontend): use Orval types directly; drop normalize hacks
This commit is contained in:
@@ -5,7 +5,7 @@ import { useState } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { normalizeDepartments, normalizeEmployees } from "@/lib/normalize";
|
||||
|
||||
import { Select } from "@/components/ui/select";
|
||||
|
||||
import {
|
||||
@@ -20,10 +20,10 @@ export default function DepartmentsPage() {
|
||||
const [headId, setHeadId] = useState<string>("");
|
||||
|
||||
const departments = useListDepartmentsDepartmentsGet();
|
||||
const departmentList = normalizeDepartments(departments.data);
|
||||
const departmentList = departments.data ?? [];
|
||||
const employees = useListEmployeesEmployeesGet();
|
||||
|
||||
const employeeList = normalizeEmployees(employees.data);
|
||||
const employeeList = employees.data ?? [];
|
||||
|
||||
const createDepartment = useCreateDepartmentDepartmentsPost({
|
||||
mutation: {
|
||||
|
||||
@@ -5,7 +5,7 @@ import { useState } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { normalizeAgentOnboardings, normalizeDepartments, normalizeEmployees, normalizeEmploymentActions, normalizeHeadcountRequests } from "@/lib/normalize";
|
||||
|
||||
import { Select } from "@/components/ui/select";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
|
||||
@@ -22,16 +22,16 @@ import { useListDepartmentsDepartmentsGet, useListEmployeesEmployeesGet } from "
|
||||
|
||||
export default function HRPage() {
|
||||
const departments = useListDepartmentsDepartmentsGet();
|
||||
const departmentList = normalizeDepartments(departments.data);
|
||||
const departmentList = departments.data ?? [];
|
||||
const employees = useListEmployeesEmployeesGet();
|
||||
const employeeList = normalizeEmployees(employees.data);
|
||||
const employeeList = employees.data ?? [];
|
||||
|
||||
const headcount = useListHeadcountRequestsHrHeadcountGet();
|
||||
const actions = useListEmploymentActionsHrActionsGet();
|
||||
const onboarding = useListAgentOnboardingHrOnboardingGet();
|
||||
const headcountList = normalizeHeadcountRequests(headcount.data);
|
||||
const actionList = normalizeEmploymentActions(actions.data);
|
||||
const onboardingList = normalizeAgentOnboardings(onboarding.data);
|
||||
const headcountList = headcount.data ?? [];
|
||||
const actionList = actions.data ?? [];
|
||||
const onboardingList = onboarding.data ?? [];
|
||||
|
||||
const [hcDeptId, setHcDeptId] = useState<string>("");
|
||||
const [hcManagerId, setHcManagerId] = useState<string>("");
|
||||
|
||||
@@ -6,7 +6,7 @@ import styles from "@/app/_components/Shell.module.css";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { normalizeActivities, normalizeDepartments, normalizeEmployees, normalizeProjects } from "@/lib/normalize";
|
||||
import { normalizeActivities } from "@/lib/normalize";
|
||||
import { Select } from "@/components/ui/select";
|
||||
|
||||
import { useCreateProjectProjectsPost, useListProjectsProjectsGet } from "@/api/generated/projects/projects";
|
||||
@@ -16,12 +16,12 @@ import { useListActivitiesActivitiesGet } from "@/api/generated/activities/activ
|
||||
|
||||
export default function Home() {
|
||||
const projects = useListProjectsProjectsGet();
|
||||
const projectList = normalizeProjects(projects.data);
|
||||
const projectList = projects.data ?? [];
|
||||
const departments = useListDepartmentsDepartmentsGet();
|
||||
const departmentList = normalizeDepartments(departments.data);
|
||||
const departmentList = departments.data ?? [];
|
||||
const employees = useListEmployeesEmployeesGet();
|
||||
const activities = useListActivitiesActivitiesGet({ limit: 20 });
|
||||
const employeeList = normalizeEmployees(employees.data);
|
||||
const employeeList = employees.data ?? [];
|
||||
const activityList = normalizeActivities(activities.data);
|
||||
|
||||
const [projectName, setProjectName] = useState("");
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Button } from "@/components/ui/button";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { normalizeDepartments, normalizeEmployees } from "@/lib/normalize";
|
||||
|
||||
import { Select } from "@/components/ui/select";
|
||||
|
||||
import {
|
||||
@@ -24,8 +24,8 @@ export default function PeoplePage() {
|
||||
|
||||
const employees = useListEmployeesEmployeesGet();
|
||||
const departments = useListDepartmentsDepartmentsGet();
|
||||
const departmentList = normalizeDepartments(departments.data);
|
||||
const employeeList = normalizeEmployees(employees.data);
|
||||
const departmentList = departments.data ?? [];
|
||||
const employeeList = employees.data ?? [];
|
||||
|
||||
const createEmployee = useCreateEmployeeEmployeesPost({
|
||||
mutation: {
|
||||
|
||||
@@ -6,7 +6,7 @@ import { useParams } from "next/navigation";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { normalizeEmployees, normalizeProjectMembers, normalizeProjects, normalizeTaskComments, normalizeTasks } from "@/lib/normalize";
|
||||
|
||||
import { Select } from "@/components/ui/select";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
|
||||
@@ -34,14 +34,14 @@ export default function ProjectDetailPage() {
|
||||
const projectId = Number(params?.id);
|
||||
|
||||
const projects = useListProjectsProjectsGet();
|
||||
const projectList = normalizeProjects(projects.data);
|
||||
const projectList = projects.data ?? [];
|
||||
const project = projectList.find((p) => p.id === projectId);
|
||||
|
||||
const employees = useListEmployeesEmployeesGet();
|
||||
const employeeList = normalizeEmployees(employees.data);
|
||||
const employeeList = employees.data ?? [];
|
||||
|
||||
const members = useListProjectMembersProjectsProjectIdMembersGet(projectId);
|
||||
const memberList = normalizeProjectMembers(members.data);
|
||||
const memberList = members.data ?? [];
|
||||
const addMember = useAddProjectMemberProjectsProjectIdMembersPost({
|
||||
mutation: { onSuccess: () => members.refetch() },
|
||||
});
|
||||
@@ -53,7 +53,7 @@ export default function ProjectDetailPage() {
|
||||
});
|
||||
|
||||
const tasks = useListTasksTasksGet({ project_id: projectId });
|
||||
const taskList = normalizeTasks(tasks.data);
|
||||
const taskList = tasks.data ?? [];
|
||||
const createTask = useCreateTaskTasksPost({
|
||||
mutation: { onSuccess: () => tasks.refetch() },
|
||||
});
|
||||
@@ -76,7 +76,7 @@ export default function ProjectDetailPage() {
|
||||
{ task_id: commentTaskId ?? 0 },
|
||||
{ query: { enabled: Boolean(commentTaskId) } },
|
||||
);
|
||||
const commentList = normalizeTaskComments(comments.data);
|
||||
const commentList = comments.data ?? [];
|
||||
const addComment = useCreateTaskCommentTaskCommentsPost({
|
||||
mutation: {
|
||||
onSuccess: () => {
|
||||
|
||||
@@ -7,7 +7,6 @@ import styles from "@/app/_components/Shell.module.css";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { normalizeProjects } from "@/lib/normalize";
|
||||
|
||||
import {
|
||||
useCreateProjectProjectsPost,
|
||||
@@ -18,7 +17,7 @@ export default function ProjectsPage() {
|
||||
const [name, setName] = useState("");
|
||||
|
||||
const projects = useListProjectsProjectsGet();
|
||||
const projectList = normalizeProjects(projects.data);
|
||||
const projectList = projects.data ?? [];
|
||||
const createProject = useCreateProjectProjectsPost({
|
||||
mutation: {
|
||||
onSuccess: () => {
|
||||
|
||||
Reference in New Issue
Block a user