Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…course-assessment-g11 into matching-ui
  • Loading branch information
ckcherry23 committed Oct 8, 2023
2 parents 903ab12 + c5cde5f commit 3c9de8d
Show file tree
Hide file tree
Showing 23 changed files with 2,507 additions and 1,604 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
java-version: ${{ env.JAVA_VER }}

- name: Install dependencies with immutable lockfile
run: yarn install --immutable
run: yarn install --frozen-lockfile

- name: Run linting
run: |
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ WORKDIR /app
COPY package.json yarn.lock ./

# Install dependencies using Yarn
RUN yarn install
RUN yarn install --frozen-lockfile
RUN yarn prisma generate
2 changes: 1 addition & 1 deletion deployment/dockerfiles/Dockerfile.admin-service
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ COPY prisma ./prisma/
RUN yarn prisma generate

# Install dependencies using Yarn Workspaces
RUN yarn install --cwd /app
RUN yarn install --frozen-lockfile --cwd /app

# Run service
CMD [ "yarn", "workspace", "admin-service", "dev" ]
2 changes: 1 addition & 1 deletion deployment/dockerfiles/Dockerfile.collaboration-service
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ COPY prisma ./prisma/
RUN yarn prisma generate

# Install dependencies using Yarn Workspaces
RUN yarn install --cwd /app
RUN yarn install --frozen-lockfile --cwd /app

# Run service
CMD [ "yarn", "workspace", "collaboration-service", "dev" ]
2 changes: 1 addition & 1 deletion deployment/dockerfiles/Dockerfile.frontend
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ WORKDIR /app/frontend
COPY frontend .

# Install dependencies using Yarn Workspaces
RUN yarn install --cwd /app
RUN yarn install --frozen-lockfile --cwd /app

# Start command for the frontend
CMD [ "yarn", "workspace", "frontend", "dev" ]
Expand Down
2 changes: 1 addition & 1 deletion deployment/dockerfiles/Dockerfile.gateway
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ COPY prisma ./prisma/
RUN yarn prisma generate

# Install dependencies using Yarn Workspaces
RUN yarn install --cwd /app
RUN yarn install --frozen-lockfile --cwd /app

# Run service
CMD [ "yarn", "workspace", "gateway", "dev" ]
2 changes: 1 addition & 1 deletion deployment/dockerfiles/Dockerfile.matching-service
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ COPY prisma ./prisma/
RUN yarn prisma generate

# Install dependencies using Yarn Workspaces
RUN yarn install --cwd /app
RUN yarn install --frozen-lockfile --cwd /app

# Run service
CMD [ "yarn", "workspace", "matching-service", "dev" ]
2 changes: 1 addition & 1 deletion deployment/dockerfiles/Dockerfile.question-service
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ COPY prisma ./prisma/
RUN yarn prisma generate

# Install dependencies using Yarn Workspaces
RUN yarn install --cwd /app
RUN yarn install --frozen-lockfile --cwd /app

# Run service
CMD [ "yarn", "workspace", "question-service", "dev" ]
2 changes: 1 addition & 1 deletion deployment/dockerfiles/Dockerfile.user-service
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ COPY prisma ./prisma/
RUN yarn prisma generate

# Install dependencies using Yarn Workspaces
RUN yarn install --cwd /app
RUN yarn install --frozen-lockfile --cwd /app

# Run service
CMD [ "yarn", "workspace", "user-service", "dev" ]
5 changes: 4 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@
"@hookform/resolvers": "^3.3.1",
"@monaco-editor/react": "^4.5.2",
"@radix-ui/react-avatar": "^1.0.4",
"@radix-ui/react-dialog": "1.0.4",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-popover": "^1.0.7",
"@radix-ui/react-select": "^2.0.0",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-switch": "^1.0.3",
"@radix-ui/react-tabs": "^1.0.4",
"@tanstack/react-table": "^8.10.4",
"@types/node": "20.6.0",
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/components/questions/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { TypographySmall } from "../ui/typography";
import { Badge } from "../ui/badge";
import { Button } from "../ui/button";
import { EditIcon, PlayIcon, ArrowUpDown } from "lucide-react";
import Link from "next/link";

type Difficulty = 'easy' | 'medium' | 'hard' | 'any';

Expand Down Expand Up @@ -62,11 +63,14 @@ export const columns: ColumnDef<Question>[] = [
id: "actions",
header: "Actions",
cell: ({ row }) => {
const id = row.id as string;
return (
<div className="flex gap-2 justify-between">
<Link href={`/questions/${id}/edit`}>
<Button variant="secondary" size="icon" className="h-8 w-8">
<EditIcon size={20} />
</Button>
</Link>
<Button variant="outline" size="sm" className="h-8 gap-2">
Practice
<PlayIcon size={20} />
Expand Down
176 changes: 176 additions & 0 deletions frontend/src/components/ui/form.tsx
Original file line number Diff line number Diff line change
@@ -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<TFieldValues> = FieldPath<TFieldValues>
> = {
name: TName
}

const FormFieldContext = React.createContext<FormFieldContextValue>(
{} as FormFieldContextValue
)

const FormField = <
TFieldValues extends FieldValues = FieldValues,
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
>({
...props
}: ControllerProps<TFieldValues, TName>) => {
return (
<FormFieldContext.Provider value={{ name: props.name }}>
<Controller {...props} />
</FormFieldContext.Provider>
)
}

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 <FormField>")
}

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<FormItemContextValue>(
{} as FormItemContextValue
)

const FormItem = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => {
const id = React.useId()

return (
<FormItemContext.Provider value={{ id }}>
<div ref={ref} className={cn("space-y-2", className)} {...props} />
</FormItemContext.Provider>
)
})
FormItem.displayName = "FormItem"

const FormLabel = React.forwardRef<
React.ElementRef<typeof LabelPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
>(({ className, ...props }, ref) => {
const { error, formItemId } = useFormField()

return (
<Label
ref={ref}
className={cn(error && "text-destructive", className)}
htmlFor={formItemId}
{...props}
/>
)
})
FormLabel.displayName = "FormLabel"

const FormControl = React.forwardRef<
React.ElementRef<typeof Slot>,
React.ComponentPropsWithoutRef<typeof Slot>
>(({ ...props }, ref) => {
const { error, formItemId, formDescriptionId, formMessageId } = useFormField()

return (
<Slot
ref={ref}
id={formItemId}
aria-describedby={
!error
? `${formDescriptionId}`
: `${formDescriptionId} ${formMessageId}`
}
aria-invalid={!!error}
{...props}
/>
)
})
FormControl.displayName = "FormControl"

const FormDescription = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLParagraphElement>
>(({ className, ...props }, ref) => {
const { formDescriptionId } = useFormField()

return (
<p
ref={ref}
id={formDescriptionId}
className={cn("text-sm text-muted-foreground", className)}
{...props}
/>
)
})
FormDescription.displayName = "FormDescription"

const FormMessage = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLParagraphElement>
>(({ className, children, ...props }, ref) => {
const { error, formMessageId } = useFormField()
const body = error ? String(error?.message) : children

if (!body) {
return null
}

return (
<p
ref={ref}
id={formMessageId}
className={cn("text-sm font-medium text-destructive", className)}
{...props}
>
{body}
</p>
)
})
FormMessage.displayName = "FormMessage"

export {
useFormField,
Form,
FormItem,
FormLabel,
FormControl,
FormDescription,
FormMessage,
FormField,
}
24 changes: 24 additions & 0 deletions frontend/src/components/ui/label.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import * as React from "react"
import * as LabelPrimitive from "@radix-ui/react-label"
import { cva, type VariantProps } from "class-variance-authority"

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

const labelVariants = cva(
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
)

const Label = React.forwardRef<
React.ElementRef<typeof LabelPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
VariantProps<typeof labelVariants>
>(({ className, ...props }, ref) => (
<LabelPrimitive.Root
ref={ref}
className={cn(labelVariants(), className)}
{...props}
/>
))
Label.displayName = LabelPrimitive.Root.displayName

export { Label }
Loading

0 comments on commit 3c9de8d

Please sign in to comment.