Update API names now that I can update iOS App

This commit is contained in:
Gabriel Brown 2024-07-25 21:49:38 -05:00
parent f6af2ff738
commit a849b065a1
4 changed files with 2 additions and 13 deletions

View File

@ -3,12 +3,6 @@ import { NextResponse } from 'next/server';
import { getEmployees } from '~/server/functions';
import { auth } from '~/auth';
type Technician = {
name: string;
status: string;
updatedAt: Date;
};
export const GET = async (request: Request) => {
try {
const session = await auth();
@ -22,12 +16,7 @@ export const GET = async (request: Request) => {
);
else {
const employees = await getEmployees();
const formattedEmployees = employees.map((employee: Technician) => ({
name: employee.name,
status: employee.status,
time: employee.updatedAt
}));
return NextResponse.json(formattedEmployees, { status: 200 });
return NextResponse.json(employees, { status: 200 });
}
} else {
const employees = await getEmployees();

View File

@ -22,7 +22,7 @@ export default function Tech_Table({ employees }: { employees: Employee[] }) {
const [employeeData, setEmployeeData] = useState(employees);
const fetch_employees = useCallback(async (): Promise<Employee[]> => {
const res = await fetch('/api/technicians', {
const res = await fetch('/api/get_technicians', {
method: 'GET',
headers: {
'Authorization': `Bearer ${process.env.API_KEY}`