Skip to content

Commit

Permalink
cleanup itineraries
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksors committed Jan 28, 2024
1 parent 64279c7 commit c2897b7
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pages/itineraries/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {Airport, Flight, Route, User} from "@prisma/client";
import {useUser} from "@auth0/nextjs-auth0/client";
import {FlightAdd} from "@/components/itinerary/flightadd";
import {Button} from "@/components/ui/button";
import {useRouter} from "next/router";

const Create = () => {
const [routes, setRoutes] = useState<{ originCode: string, destinationCode: string }[]>([]);
Expand All @@ -15,6 +16,8 @@ const Create = () => {
const { user, isLoading } = useUser();
const [wingmanUser, setWingmanUser] = useState<User | null>(null);

const router = useRouter();

useEffect(() => {
if (!isLoading && user) {
fetch(`/api/users/${user?.sub}`).then(res => res.json()).then(data => {
Expand Down Expand Up @@ -66,7 +69,9 @@ const Create = () => {
}

// If there's no starting point, the route is circular and not contiguous
if (start === null) return false;
if (start === null) {
return false;
}

// Step 4: Follow the route
let count = 0;
Expand Down Expand Up @@ -101,6 +106,10 @@ const Create = () => {
}).then(res => res.json()).then(data => {
console.log(data);
})
router.push('/itineraries');
} else {
console.log('Invalid route');
alert('There is an issue in your route! Please make sure that your route is contiguous and your return flights are in a separate itinerary.')
}
};

Expand Down

0 comments on commit c2897b7

Please sign in to comment.