Update API names now that I can update iOS App
This commit is contained in:
parent
f6af2ff738
commit
a849b065a1
@ -3,12 +3,6 @@ import { NextResponse } from 'next/server';
|
|||||||
import { getEmployees } from '~/server/functions';
|
import { getEmployees } from '~/server/functions';
|
||||||
import { auth } from '~/auth';
|
import { auth } from '~/auth';
|
||||||
|
|
||||||
type Technician = {
|
|
||||||
name: string;
|
|
||||||
status: string;
|
|
||||||
updatedAt: Date;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const GET = async (request: Request) => {
|
export const GET = async (request: Request) => {
|
||||||
try {
|
try {
|
||||||
const session = await auth();
|
const session = await auth();
|
||||||
@ -22,12 +16,7 @@ export const GET = async (request: Request) => {
|
|||||||
);
|
);
|
||||||
else {
|
else {
|
||||||
const employees = await getEmployees();
|
const employees = await getEmployees();
|
||||||
const formattedEmployees = employees.map((employee: Technician) => ({
|
return NextResponse.json(employees, { status: 200 });
|
||||||
name: employee.name,
|
|
||||||
status: employee.status,
|
|
||||||
time: employee.updatedAt
|
|
||||||
}));
|
|
||||||
return NextResponse.json(formattedEmployees, { status: 200 });
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const employees = await getEmployees();
|
const employees = await getEmployees();
|
@ -22,7 +22,7 @@ export default function Tech_Table({ employees }: { employees: Employee[] }) {
|
|||||||
const [employeeData, setEmployeeData] = useState(employees);
|
const [employeeData, setEmployeeData] = useState(employees);
|
||||||
|
|
||||||
const fetch_employees = useCallback(async (): Promise<Employee[]> => {
|
const fetch_employees = useCallback(async (): Promise<Employee[]> => {
|
||||||
const res = await fetch('/api/technicians', {
|
const res = await fetch('/api/get_technicians', {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': `Bearer ${process.env.API_KEY}`
|
'Authorization': `Bearer ${process.env.API_KEY}`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user