diff --git a/app/api/airports/route.ts b/app/api/airports/route.ts index e65961e..c912071 100644 --- a/app/api/airports/route.ts +++ b/app/api/airports/route.ts @@ -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) { @@ -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() @@ -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' }) - } } } diff --git a/app/layout.tsx b/app/layout.tsx index d835fa5..38b9d39 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -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"] }); @@ -15,6 +17,7 @@ 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({ @@ -22,6 +25,7 @@ export default function RootLayout({ }: Readonly<{ children: React.ReactNode; }>) { + return ( diff --git a/components/ldprovider.tsx b/components/ldprovider.tsx index 8fa8034..7bb9c78 100644 --- a/components/ldprovider.tsx +++ b/components/ldprovider.tsx @@ -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: { diff --git a/components/ui/airwayscomponents/airlineHero.tsx b/components/ui/airwayscomponents/airlineHero.tsx index 1daed5b..548752c 100644 --- a/components/ui/airwayscomponents/airlineHero.tsx +++ b/components/ui/airwayscomponents/airlineHero.tsx @@ -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, @@ -13,6 +14,8 @@ const AirlineHero = ({ }) => { const { isLoggedIn, enrolledInLaunchClub } = useContext(LoginContext); + const { launchClubText} = useFlags(); + return (
@@ -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" >
-

Are you ready to Launch?!

-

- Join Launch Club for exclusive access to flights, rewards, and much more. See - details within! + {/*

Are you ready to Launch?!

*/} +

+ {launchClubText}

-
+
diff --git a/components/ui/airwayscomponents/commandMenu.tsx b/components/ui/airwayscomponents/commandMenu.tsx new file mode 100644 index 0000000..f446744 --- /dev/null +++ b/components/ui/airwayscomponents/commandMenu.tsx @@ -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 ( + <> + + + + No results found. + + + {console.log("test")}} className="mr-2 h-4 w-4" /> + Create Chaos + + + + + + ) +} diff --git a/components/ui/airwayscomponents/launchSignup.tsx b/components/ui/airwayscomponents/launchSignup.tsx index 5074524..60b39da 100644 --- a/components/ui/airwayscomponents/launchSignup.tsx +++ b/components/ui/airwayscomponents/launchSignup.tsx @@ -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 = [ @@ -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!
+
+

hi aaron

+
{perks.map((perks, index) => ( , + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + + + + + +)) +Checkbox.displayName = CheckboxPrimitive.Root.displayName + +export { Checkbox } diff --git a/components/ui/form.tsx b/components/ui/form.tsx new file mode 100644 index 0000000..4603f8b --- /dev/null +++ b/components/ui/form.tsx @@ -0,0 +1,176 @@ +import * as React from "react" +import * as LabelPrimitive from "@radix-ui/react-label" +import { Slot } from "@radix-ui/react-slot" +import { + Controller, + ControllerProps, + FieldPath, + FieldValues, + FormProvider, + useFormContext, +} from "react-hook-form" + +import { cn } from "@/lib/utils" +import { Label } from "@/components/ui/label" + +const Form = FormProvider + +type FormFieldContextValue< + TFieldValues extends FieldValues = FieldValues, + TName extends FieldPath = FieldPath +> = { + name: TName +} + +const FormFieldContext = React.createContext( + {} as FormFieldContextValue +) + +const FormField = < + TFieldValues extends FieldValues = FieldValues, + TName extends FieldPath = FieldPath +>({ + ...props +}: ControllerProps) => { + return ( + + + + ) +} + +const useFormField = () => { + const fieldContext = React.useContext(FormFieldContext) + const itemContext = React.useContext(FormItemContext) + const { getFieldState, formState } = useFormContext() + + const fieldState = getFieldState(fieldContext.name, formState) + + if (!fieldContext) { + throw new Error("useFormField should be used within ") + } + + const { id } = itemContext + + return { + id, + name: fieldContext.name, + formItemId: `${id}-form-item`, + formDescriptionId: `${id}-form-item-description`, + formMessageId: `${id}-form-item-message`, + ...fieldState, + } +} + +type FormItemContextValue = { + id: string +} + +const FormItemContext = React.createContext( + {} as FormItemContextValue +) + +const FormItem = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => { + const id = React.useId() + + return ( + +
+ + ) +}) +FormItem.displayName = "FormItem" + +const FormLabel = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => { + const { error, formItemId } = useFormField() + + return ( +