Skip to content

Commit

Permalink
fixing app rev
Browse files Browse the repository at this point in the history
  • Loading branch information
codyde committed May 7, 2024
1 parent 74a420c commit 02e338a
Show file tree
Hide file tree
Showing 36 changed files with 457 additions and 40 deletions.
46 changes: 24 additions & 22 deletions app/api/airports/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,29 @@ export async function GET(request: NextApiRequest, response: NextApiResponse) {
let connectionString;
if (flightDb) {
const t1 = Date.now()
console.log('FlightDb is enabled');
console.log('FlightDb Feature is Enabled');
try {
const redis = new Redis(process.env.REDIS_URL || '');
const airportsRedisJson = await redis.get('allAirports');
const allAirports = JSON.parse(airportsRedisJson!);
const t2 = Date.now()
console.log("Redis speed is: " + (t2 - t1) + "ms")
const speed = (t2 - t1)

ldclient.track("Airport DB Latency", context, null, speed)

await ldclient.flush()
return Response.json({ allAirports })
} catch (error) {
ldclient.track("Airport DB Errors", context)
await ldclient.flush()
console.log("error")
return Response.json({ message: 'Pool went kaboom' })
}

} else {
const t1 = Date.now()
console.log('FlightDb is disabled');
connectionString = process.env.DATABASE_URL
try {
if (!connectionString) {
Expand All @@ -30,9 +52,8 @@ export async function GET(request: NextApiRequest, response: NextApiResponse) {
const client = postgres(connectionString)
const db = drizzle(client);
const allAirports = await db.select().from(airports)
console.log(allAirports)
const t2 = Date.now()
console.log("PostgreSQL speed is: " + (t2 - t1)+ "ms")
console.log("PostgreSQL speed is: " + (t2 - t1) + "ms")
const speed = (t2 - t1)
ldclient.track("Airport DB Latency", context, null, speed)
await ldclient.flush()
Expand All @@ -44,25 +65,6 @@ export async function GET(request: NextApiRequest, response: NextApiResponse) {
console.log("error")
return Response.json({ message: 'Pool went kaboom' })
}
} else {
const t1 = Date.now()
console.log('FlightDb is disabled');
try {
const redis = new Redis(process.env.REDIS_URL || '');
const airportsRedisJson = await redis.get('allAirports');
const allAirports = JSON.parse(airportsRedisJson!);
const t2 = Date.now()
console.log("Redis speed is: " + (t2 - t1)+ "ms")
const speed = (t2 - t1)
console.log(speed)
ldclient.track("Airport DB Latency", context, null, speed)
await ldclient.flush()
return Response.json({ allAirports })
} catch (error) {
ldclient.track("Airport DB Errors", context)
await ldclient.flush()
return Response.json({ message: 'Pool went kaboom' })
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import dynamic from "next/dynamic";
import { Suspense } from "react";
import { TripsProvider } from "@/utils/contexts/TripContext";
import LoginContext, { LoginProvider } from "@/utils/contexts/login";
import { v4 as uuidv4 } from "uuid";


const inter = Inter({ subsets: ["latin"] });

Expand All @@ -15,13 +17,15 @@ const AsyncLDProvider = dynamic(() => import("@/components/ldprovider"), {
export const metadata: Metadata = {
title: "LaunchAirways",
description: "LaunchAirways Sample App",
viewport: "width=device-width, initial-scale=1",
};

export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {

return (
<html lang="en">
<body className={inter.className}>
Expand Down
7 changes: 7 additions & 0 deletions components/ldprovider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,15 @@ export default function AsyncLDProvider({
asyncWithLDProvider({
clientSideID: process.env.NEXT_PUBLIC_LD_CLIENT_KEY || '',
reactOptions: {

useCamelCaseFlagKeys: false
},
options: {
application: {
id: "launch-airways",
version: "74a420c9dfe4981d221551e1305ba152a2342fec"
}
},
context: {
kind: "multi",
user: {
Expand Down
14 changes: 8 additions & 6 deletions components/ui/airwayscomponents/airlineHero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Button } from "@/components/ui/button";
import { motion } from "framer-motion";
import LaunchSignUp from "./launchSignup";
import LoginContext from "@/utils/contexts/login";
import { useFlags } from "launchdarkly-react-client-sdk";

const AirlineHero = ({
showSearch,
Expand All @@ -13,6 +14,8 @@ const AirlineHero = ({
}) => {
const { isLoggedIn, enrolledInLaunchClub } = useContext(LoginContext);

const { launchClubText} = useFlags();

return (
<section className={`airline-hero-image ${showSearch ? "blur-lg" : ""}`}>
<div className="flex flex-col">
Expand Down Expand Up @@ -43,17 +46,16 @@ const AirlineHero = ({
initial={{ x: 300 }}
animate={{ x: 0 }}
transition={{ type: "spring", stiffness: 50 }}
className="flex flex-col p-10 gap-y-8 z-30 w-full h-auto sm:h-[300px] sm:w-[500px]
className="flex flex-col p-10 gap-y-8 z-30 w-full sm:w-[500px]
bg-gradient-releases shadow-2xl mb-[5rem] lg:my-32 lg:absolute lg:right-10 rounded-lg text-white"
>
<div className="text-center">
<h3 className="text-4xl text-center mb-4">Are you ready to Launch?!</h3>
<p className="text-xl ">
Join Launch Club for exclusive access to flights, rewards, and much more. See
details within!
{/* <h3 className="text-4xl text-center mb-4">Are you ready to Launch?!</h3> */}
<p className="text-2xl">
{launchClubText}
</p>
</div>
<div className="h-full flex self-center">
<div className="max-h-[200px] bottom-0 flex">
<LaunchSignUp />
</div>
</motion.div>
Expand Down
55 changes: 55 additions & 0 deletions components/ui/airwayscomponents/commandMenu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"use client"

import * as React from "react"
import {
CalendarIcon,
EnvelopeClosedIcon,
FaceIcon,
GearIcon,
PersonIcon,
RocketIcon,
} from "@radix-ui/react-icons"

import {
CommandDialog,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
CommandSeparator,
CommandShortcut,
} from "@/components/ui/command"

export function CommandDialogDemo() {
const [open, setOpen] = React.useState(false)

React.useEffect(() => {
const down = (e: KeyboardEvent) => {
if (e.key === "j" && (e.metaKey || e.ctrlKey)) {
e.preventDefault()
setOpen((open) => !open)
}
}

document.addEventListener("keydown", down)
return () => document.removeEventListener("keydown", down)
}, [])

return (
<>
<CommandDialog open={open} onOpenChange={setOpen}>
<CommandInput placeholder="Type a command or search..." />
<CommandList>
<CommandEmpty>No results found.</CommandEmpty>
<CommandGroup heading="Suggestions">
<CommandItem >
<CalendarIcon onClick={() => {console.log("test")}} className="mr-2 h-4 w-4" />
<span className="text-black">Create Chaos</span>
</CommandItem>
</CommandGroup>
</CommandList>
</CommandDialog>
</>
)
}
5 changes: 5 additions & 0 deletions components/ui/airwayscomponents/launchSignup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export default function LaunchSignUp() {
const context = await client?.getContext();
context.user.launchclub = "standard";
client.identify(context);
client?.track("registration-completed", context)
client?.flush()
};

const perks = [
Expand Down Expand Up @@ -127,6 +129,9 @@ export default function LaunchSignUp() {
Introducing our the new Launch Airways loyalty program. Join now for exclusive
member perks that increase the more you fly!
</div>
<div>
<p>hi aaron</p>
</div>
<div className="flex flex-col sm:flex-row gap-4 place-content-between w-full my-10">
{perks.map((perks, index) => (
<Card
Expand Down
30 changes: 30 additions & 0 deletions components/ui/checkbox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"use client"

import * as React from "react"
import * as CheckboxPrimitive from "@radix-ui/react-checkbox"
import { Check } from "lucide-react"

import { cn } from "@/lib/utils"

const Checkbox = React.forwardRef<
React.ElementRef<typeof CheckboxPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
>(({ className, ...props }, ref) => (
<CheckboxPrimitive.Root
ref={ref}
className={cn(
"peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
className
)}
{...props}
>
<CheckboxPrimitive.Indicator
className={cn("flex items-center justify-center text-current")}
>
<Check className="h-4 w-4" />
</CheckboxPrimitive.Indicator>
</CheckboxPrimitive.Root>
))
Checkbox.displayName = CheckboxPrimitive.Root.displayName

export { Checkbox }
Loading

0 comments on commit 02e338a

Please sign in to comment.