Skip to content

Commit c2b867c

Browse files
authored
Merge pull request #20 from CS3219-AY2425S1/chore/tidy-questions-layout-code
chore(tidy-code/UI): Add breadcrumbs-wrapper
2 parents f0184bf + 76f5136 commit c2b867c

File tree

8 files changed

+22
-26
lines changed

8 files changed

+22
-26
lines changed

frontend/src/assets/questions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export const questions = [
170170
id: 20,
171171
title: 'Trips and Users',
172172
description:
173-
"Given table `Trips` with columns `id`, `client_id`, `driver_id`, `city_id`, `status`, and `request_at`, where `id` is the primary key. The table holds all taxi trips. Each trip has a unique `id`, while `client_id` and `driver_id` are foreign keys to the `users_id` in the `Users` table.\n\nStatus is an ENUM (category) type of ('completed', 'cancelled_by_driver', 'cancelled_by_client').\n\nGiven table `Users` with columns `users_id`, `banned`, and `role`, users_id is the primary key (column with unique values) for htis table. The table holds all users. Each user has a unique `users_id` and `role` is an ENUM type of ('client', 'driver', 'partner'). `banned` is an ENUM category of type ('Yes', 'No'). The cancellation rate is computed by dividing the number of canceled (by client or driver) requests with unbanned users by the total number of requests with unbanned users on that day.\n\nWrite a solution to find the cancellation rate of requests with unbanned users (both client and driver must not be banned) each day between \"2013-10-01\" and \"2013-10-03\". Round the cancellation rate to two decimal points.",
173+
"Given table `Trips` with columns `id`, `client_id`, `driver_id`, `city_id`, `status`, and `request_at`, where `id` is the primary key. The table holds all taxi trips. Each trip has a unique `id`, while `client_id` and `driver_id` are foreign keys to the `users_id` in the `Users` table.\n\nStatus is an `ENUM` (category) type of (`'completed'`, `'cancelled_by_driver'`, `'cancelled_by_client'`).\n\nGiven table `Users` with columns `users_id`, `banned`, and `role`, `users_id` is the primary key (column with unique values) for this table. The table holds all users. Each user has a unique `users_id` and `role` is an `ENUM` type of (`'client'`, `'driver'`, `'partner'`). `banned` is an `ENUM` category of type (`'Yes'`, `'No'`). The cancellation rate is computed by dividing the number of canceled (by client or driver) requests with unbanned users by the total number of requests with unbanned users on that day.\n\nWrite a solution to find the cancellation rate of requests with unbanned users (both client and driver must not be banned) each day between `\"2013-10-01\"` and `\"2013-10-03\"`. Round the cancellation rate to two decimal points.",
174174
topics: ['Databases'],
175175
difficulty: 'Hard',
176176
leetcode: 'https://leetcode.com/problems/trips-and-users/',

frontend/src/components/blocks/authed/with-nav-banner.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { Fragment, type FC, type PropsWithChildren } from 'react';
2+
import { Link } from 'react-router-dom';
3+
14
import {
25
Breadcrumb,
36
BreadcrumbItem,
@@ -6,9 +9,7 @@ import {
69
BreadcrumbSeparator,
710
} from '@/components/ui/breadcrumb';
811
import { cn } from '@/lib/utils';
9-
import { BreadCrumb } from '@/stores/breadcrumb-store';
10-
import { FC, Fragment, PropsWithChildren } from 'react';
11-
import { Link } from 'react-router-dom';
12+
import type { BreadCrumb } from '@/lib/routes';
1213

1314
type IBreadCrumbBannerProps = {
1415
crumbs: Array<BreadCrumb>;

frontend/src/components/ui/badge.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ const badgeVariants = cva(
1414
destructive:
1515
'bg-destructive text-destructive-foreground hover:bg-destructive/80 border-transparent shadow',
1616
outline: 'text-foreground',
17+
hard: 'border-transparent bg-rose-200/70 text-rose-800 dark:bg-rose-900 dark:text-rose-200',
18+
medium:
19+
'border-transparent bg-amber-200/70 text-amber-800 dark:bg-amber-900 dark:text-amber-200',
20+
easy: 'border-transparent bg-emerald-200/70 text-emerald-800 dark:bg-emerald-900 dark:text-emerald-200',
1721
},
1822
},
1923
defaultVariants: {

frontend/src/lib/hooks/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
export * from './use-router-location';
2+
export * from './use-page-title';
3+
export * from './use-crumbs';

frontend/src/lib/hooks/use-crumbs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { BreadCrumb } from '@/stores/breadcrumb-store';
2-
import { getBreadCrumbs } from '../routes';
1+
import { type BreadCrumb, getBreadCrumbs } from '@/lib/routes';
2+
33
import { useRouterLocation } from './use-router-location';
44

55
export const useCrumbs = (...extraCrumbs: Array<BreadCrumb>) => {

frontend/src/lib/routes.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import type { BreadCrumb } from '@/stores/breadcrumb-store';
2-
31
export const ROUTES = {
42
LOGIN: '/login',
53
SIGNUP: '/signup',
@@ -19,6 +17,11 @@ const TOP_LEVEL_AUTHED_ROUTES = {
1917
],
2018
};
2119

20+
export type BreadCrumb = {
21+
path: string;
22+
title: string;
23+
};
24+
2225
export const getBreadCrumbs = (path: string): Array<BreadCrumb> => {
2326
for (const key of Object.keys(TOP_LEVEL_AUTHED_ROUTES)) {
2427
if (path.startsWith(key)) {

frontend/src/routes/questions/details.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ export const QuestionDetails = () => {
4848
</CardTitle>
4949
</div>
5050
<div className='flex flex-wrap items-center gap-1'>
51-
<Badge variant='secondary' className='flex w-min grow-0'>
51+
<Badge
52+
variant={details.difficulty.toLowerCase() as 'easy' | 'medium' | 'hard'}
53+
className='flex w-min grow-0'
54+
>
5255
{details.difficulty}
5356
</Badge>
5457
<Separator orientation='vertical' className='mx-2 h-4' />

frontend/src/stores/breadcrumb-store.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)