Skip to content

Commit

Permalink
chore: format (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinmichaelchen authored Jan 5, 2024
1 parent afe11b7 commit 2c1e40f
Show file tree
Hide file tree
Showing 10 changed files with 190 additions and 190 deletions.
28 changes: 14 additions & 14 deletions ui/src/app/dashboard/actions.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
"use server";
'use server'

import { Timestamp } from "@bufbuild/protobuf";
import { createPromiseClient } from "@connectrpc/connect";
import { TemporalService } from "@buf/kevinmichaelchen_temporalapis.connectrpc_es/temporal/v1beta1/api_connect";
import { createConnectTransport } from "@connectrpc/connect-web";
import { Timestamp } from '@bufbuild/protobuf'
import { createPromiseClient } from '@connectrpc/connect'
import { TemporalService } from '@buf/kevinmichaelchen_temporalapis.connectrpc_es/temporal/v1beta1/api_connect'
import { createConnectTransport } from '@connectrpc/connect-web'

const temporalClient = createPromiseClient(
TemporalService,
createConnectTransport({
baseUrl: "http://localhost:8081",
baseUrl: 'http://localhost:8081',
}),
);
)

export async function createOnboardingWorkflow({
orgName,
profileName,
start,
end,
}: {
orgName: string;
profileName: string;
start: Date;
end: Date;
orgName: string
profileName: string
start: Date
end: Date
}) {
"use server";
'use server'
const response = await temporalClient.createOnboardingWorkflow({
org: {
name: orgName,
Expand All @@ -35,6 +35,6 @@ export async function createOnboardingWorkflow({
profile: {
name: profileName,
},
});
return response;
})
return response
}
108 changes: 54 additions & 54 deletions ui/src/app/dashboard/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"use client";
'use client'

import * as React from "react";
import { Button } from "@/components/ui/button";
import Link from "next/link";
import { toast } from "sonner";
import * as React from 'react'
import { Button } from '@/components/ui/button'
import Link from 'next/link'
import { toast } from 'sonner'
import {
Dialog,
DialogContent,
Expand All @@ -12,7 +12,7 @@ import {
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog";
} from '@/components/ui/dialog'
import {
Form,
FormControl,
Expand All @@ -21,22 +21,22 @@ import {
FormItem,
FormLabel,
FormMessage,
} from "@/components/ui/form";
import { Input } from "@/components/ui/input";
import { DateFormatter } from "react-day-picker";
import { CalendarIcon } from "@radix-ui/react-icons";
import { cn } from "@/lib/utils";
import { format } from "date-fns";
import { Calendar } from "@/components/ui/calendar";
} from '@/components/ui/form'
import { Input } from '@/components/ui/input'
import { DateFormatter } from 'react-day-picker'
import { CalendarIcon } from '@radix-ui/react-icons'
import { cn } from '@/lib/utils'
import { format } from 'date-fns'
import { Calendar } from '@/components/ui/calendar'
import {
Popover,
PopoverContent,
PopoverTrigger,
} from "@/components/ui/popover";
import { useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import * as z from "zod";
import { createOnboardingWorkflow } from "@/app/dashboard/actions";
} from '@/components/ui/popover'
import { useForm } from 'react-hook-form'
import { zodResolver } from '@hookform/resolvers/zod'
import * as z from 'zod'
import { createOnboardingWorkflow } from '@/app/dashboard/actions'

// `app/dashboard/page.tsx` is the UI for the `/dashboard` URL
export default function Page() {
Expand All @@ -50,70 +50,70 @@ export default function Page() {
</Link>
</div>
</div>
);
)
}

const seasonEmoji: Record<string, string> = {
winter: "⛄️",
spring: "🌸",
summer: "🌻",
autumn: "🍂",
};
winter: '⛄️',
spring: '🌸',
summer: '🌻',
autumn: '🍂',
}

const getSeason = (month: Date): string => {
const monthNumber = month.getMonth();
if (monthNumber >= 0 && monthNumber < 3) return "winter";
if (monthNumber >= 3 && monthNumber < 6) return "spring";
if (monthNumber >= 6 && monthNumber < 9) return "summer";
else return "autumn";
};
const monthNumber = month.getMonth()
if (monthNumber >= 0 && monthNumber < 3) return 'winter'
if (monthNumber >= 3 && monthNumber < 6) return 'spring'
if (monthNumber >= 6 && monthNumber < 9) return 'summer'
else return 'autumn'
}

const formatCaption: DateFormatter = (month, options) => {
const season = getSeason(month);
const season = getSeason(month)
return (
<>
<span role="img" aria-label={season}>
{seasonEmoji[season]}
</span>{" "}
{format(month, "LLLL", { locale: options?.locale })}
</span>{' '}
{format(month, 'LLLL', { locale: options?.locale })}
</>
);
};
)
}

const formSchema = z.object({
orgName: z.string().min(2, {
message: "Organization name must be at least 2 characters.",
message: 'Organization name must be at least 2 characters.',
}),
profileName: z.string().min(2, {
message: "User display name must be at least 2 characters.",
message: 'User display name must be at least 2 characters.',
}),
startDate: z.date({
required_error: "Please select a date",
required_error: 'Please select a date',
invalid_type_error: "That's not a date!",
}),
endDate: z.date({
required_error: "Please select a date",
required_error: 'Please select a date',
invalid_type_error: "That's not a date!",
}),
});
})

export function CreateWorkflowDialog() {
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
});
})

async function onSubmit(values: z.infer<typeof formSchema>) {
// Do something with the form values.
// ✅ This will be type-safe and validated.
console.log(values);
toast("form submit" + JSON.stringify(values));
console.log(values)
toast('form submit' + JSON.stringify(values))
const response = await createOnboardingWorkflow({
orgName: values.orgName,
profileName: values.profileName,
start: values.startDate,
end: values.startDate,
});
toast(response.toJsonString());
})
toast(response.toJsonString())
}

return (
Expand Down Expand Up @@ -173,14 +173,14 @@ export function CreateWorkflowDialog() {
<Popover>
<PopoverTrigger asChild>
<Button
variant={"outline"}
variant={'outline'}
className={cn(
"pl-3 text-left font-normal",
!field.value && "text-muted-foreground",
'pl-3 text-left font-normal',
!field.value && 'text-muted-foreground',
)}
>
{field.value ? (
format(field.value, "yyyy-MM-dd")
format(field.value, 'yyyy-MM-dd')
) : (
<span className="pr-1">Pick a date</span>
)}
Expand Down Expand Up @@ -218,14 +218,14 @@ export function CreateWorkflowDialog() {
<Popover>
<PopoverTrigger asChild>
<Button
variant={"outline"}
variant={'outline'}
className={cn(
"pl-3 text-left font-normal",
!field.value && "text-muted-foreground",
'pl-3 text-left font-normal',
!field.value && 'text-muted-foreground',
)}
>
{field.value ? (
format(field.value, "yyyy-MM-dd")
format(field.value, 'yyyy-MM-dd')
) : (
<span className="pr-1">Pick a date</span>
)}
Expand Down Expand Up @@ -259,5 +259,5 @@ export function CreateWorkflowDialog() {
</Form>
</DialogContent>
</Dialog>
);
)
}
42 changes: 21 additions & 21 deletions ui/src/components/ui/button.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
import * as React from "react"
import { Slot } from "@radix-ui/react-slot"
import { cva, type VariantProps } from "class-variance-authority"
import * as React from 'react'
import { Slot } from '@radix-ui/react-slot'
import { cva, type VariantProps } from 'class-variance-authority'

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

const buttonVariants = cva(
"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",
'inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50',
{
variants: {
variant: {
default:
"bg-primary text-primary-foreground shadow hover:bg-primary/90",
'bg-primary text-primary-foreground shadow hover:bg-primary/90',
destructive:
"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
'bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90',
outline:
"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
'border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground',
secondary:
"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
ghost: "hover:bg-accent hover:text-accent-foreground",
link: "text-primary underline-offset-4 hover:underline",
'bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80',
ghost: 'hover:bg-accent hover:text-accent-foreground',
link: 'text-primary underline-offset-4 hover:underline',
},
size: {
default: "h-9 px-4 py-2",
sm: "h-8 rounded-md px-3 text-xs",
lg: "h-10 rounded-md px-8",
icon: "h-9 w-9",
default: 'h-9 px-4 py-2',
sm: 'h-8 rounded-md px-3 text-xs',
lg: 'h-10 rounded-md px-8',
icon: 'h-9 w-9',
},
},
defaultVariants: {
variant: "default",
size: "default",
variant: 'default',
size: 'default',
},
}
},
)

export interface ButtonProps
Expand All @@ -42,16 +42,16 @@ export interface ButtonProps

const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, size, asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : "button"
const Comp = asChild ? Slot : 'button'
return (
<Comp
className={cn(buttonVariants({ variant, size, className }))}
ref={ref}
{...props}
/>
)
}
},
)
Button.displayName = "Button"
Button.displayName = 'Button'

export { Button, buttonVariants }
Loading

0 comments on commit 2c1e40f

Please sign in to comment.