Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ src/
- [x] Create task — the + buttons open a Figma-matched modal (full-screen page on mobile, floating panel on desktop) with custom estimate/assignee/tag menus and per-breakpoint date pickers; createTask + cache invalidation + error handling
- [x] Update task — Edit via the card/list options menu, reusing the shared TaskForm with all six required editable fields (name, due date, position, status, tags, estimate) plus assignee; success/failure notifications
- [x] Delete task — 'Delete Task?' confirmation via the options menu, deleteTask by id, success/failure notifications
- [x] View toggle & My Task — grid/list layouts on both views (list = the mockup's grouped table with due-date row indicators); My Task filters to tasks assigned to the logged-in user via the profile query
- [x] View toggle & My Task — grid/list layouts on both views (list = the mockup's grouped table with due-date row indicators), switched by the toolbar icons on desktop and by the Dashboard/Task tabs on mobile; My Task filters to tasks assigned to the logged-in user via the profile query
- [x] Search & filter — the header search and five filter chips (status, estimate, tags, due date, owner) live in URL search params, combine freely, and show a dedicated empty-results state when nothing matches
- [ ] User settings page
- [x] User settings page — reached from a Settings sidebar item — rendered with the same NavLink anatomy as Dashboard and My Task; the design system documents its SidebarItem as an abstract component, which is what sanctions adding a third item — and by clicking the header avatar; /settings renders the profile query (full name, email, type chip, created/updated dates) in an invented card design built from the app's own tokens; the requirement's Position field does not exist on the API's User type (verified by introspection), so the row states that instead of fabricating a value

### Bonus points attempted

Expand All @@ -124,6 +124,7 @@ src/

- **Generated GraphQL code is committed on purpose.** `src/graphql/generated/` (output of `npm run codegen`) is checked into git so CI can typecheck and build without holding the API token. Regenerate after changing any query/mutation; never edit by hand.
- **Quality gates are CI-enforced, not hook-enforced.** There are deliberately no git hooks (husky/lint-staged): CI runs format check, lint, typecheck, tests, and build on every PR, and the same scripts run locally on demand. Hooks can be added later if commit-time enforcement proves necessary.
- **The settings Position row says "Not provided by the API."** The requirement lists Position among the user fields, but the User type has no such field (introspection: fullName, email, type, avatar, createdAt, updatedAt). The row is rendered so the requirement's shape is visible, with an honest value instead of an invented one.
- **Filter state lives in the URL.** Search and filters are `?q=…&status=…` search params, not component state: filtered views are shareable/bookmarkable, survive reloads, and search-params changes don't remount the page (the error boundary keys on pathname only). Three observed API behaviors are documented rather than papered over: name matching is a **case-sensitive** substring (verified: `icket` matches `Ticket5`, `ticket` does not); `dueDate` filters by **exact timestamp** equality (this app writes all due dates at noon UTC, so day-level filtering works for tasks it created); and `ownerId` is accepted but **ignored by the server** (a nonexistent id returns the full task list) — the param is still sent as required, and the owner filter additionally applies client-side against the task's `creator.id` so the control does what it says.
- **Tag labels derive from the API enum.** The mockups show sample tag texts that contradict each other across surfaces (the same tag renders "IOS APP" on cards but "IOS" in the tag menu, "ANDROID" on cards but "Android App" in the menu). Since the API's TaskTag enum is the real domain, labels derive from the enum values (IOS, ANDROID, REACT, NODE JS, RAILS) and are identical everywhere.
- **List group-header hover icons are omitted.** One mockup group header shows +/… icons; they have no behavior behind them (non-working UI, same principle as the bell).
Expand Down
36 changes: 22 additions & 14 deletions src/app/router.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
makeFixtureUsers,
tasksRequestMock,
} from '@/test/fixtures'
import { ProfileDocument, UsersDocument } from '@/features/tasks/queries'
import { UsersDocument } from '@/features/tasks/queries'
import { ProfileDocument } from '@/lib/profile'

vi.mock('@/lib/graphql-client', () => ({
graphqlClient: { request: vi.fn() },
Expand Down Expand Up @@ -73,20 +74,22 @@ describe('app routes', () => {
describe('sidebar navigation', () => {
it('marks only the active item with aria-current', () => {
renderAt('/')
expect(screen.getByRole('link', { name: /dashboard/i })).toHaveAttribute('aria-current', 'page')
expect(screen.getByRole('link', { name: /my task/i })).not.toHaveAttribute('aria-current')
const nav = within(screen.getByRole('navigation', { name: /main/i }))
expect(nav.getByRole('link', { name: /dashboard/i })).toHaveAttribute('aria-current', 'page')
expect(nav.getByRole('link', { name: /my task/i })).not.toHaveAttribute('aria-current')
})

it('moves aria-current when the route changes', () => {
renderAt('/my-task')
expect(screen.getByRole('link', { name: /my task/i })).toHaveAttribute('aria-current', 'page')
expect(screen.getByRole('link', { name: /dashboard/i })).not.toHaveAttribute('aria-current')
const nav = within(screen.getByRole('navigation', { name: /main/i }))
expect(nav.getByRole('link', { name: /my task/i })).toHaveAttribute('aria-current', 'page')
expect(nav.getByRole('link', { name: /dashboard/i })).not.toHaveAttribute('aria-current')
})

it('marks nothing active on unknown deep paths (renders not-found)', () => {
renderAt('/my-task/anything')
expect(screen.getByRole('heading', { level: 1, name: /not found/i })).toBeInTheDocument()
const nav = within(screen.getByRole('navigation'))
const nav = within(screen.getByRole('navigation', { name: /main/i }))
expect(nav.getByRole('link', { name: /my task/i })).not.toHaveAttribute('aria-current')
expect(nav.getByRole('link', { name: /dashboard/i })).not.toHaveAttribute('aria-current')
})
Expand Down Expand Up @@ -125,13 +128,18 @@ describe('dashboard main content', () => {
expect(screen.getAllByRole('button', { name: /add task/i }).length).toBeGreaterThan(0)
})

it('marks the correct mobile tab active per route', () => {
renderAt('/my-task')
const taskTab = screen.getByText('Task')
const tabs = taskTab.parentElement?.parentElement
if (!tabs) throw new Error('expected the mobile tabs container to exist')
expect(taskTab).toHaveClass('text-primary-4')
expect(within(tabs).getByText('Dashboard')).toHaveClass('text-neutral-2')
it('mobile tabs switch the layout and survive navigation', async () => {
const user = userEvent.setup()
renderAt('/')
expect(screen.getByRole('button', { name: 'Dashboard' })).toHaveAttribute(
'aria-pressed',
'true',
)
await user.click(screen.getByRole('button', { name: 'Task' }))
expect(screen.getByRole('button', { name: 'Task' })).toHaveAttribute('aria-pressed', 'true')
const nav = within(screen.getByRole('navigation', { name: /main/i }))
await user.click(nav.getByRole('link', { name: /my task/i }))
expect(screen.getByRole('button', { name: 'Task' })).toHaveAttribute('aria-pressed', 'true')
})
})

Expand Down Expand Up @@ -197,7 +205,7 @@ describe('mobile navigation drawer', () => {
const user = userEvent.setup()
renderAt('/')
await user.click(screen.getByRole('button', { name: /open navigation/i }))
const nav = within(screen.getByRole('navigation'))
const nav = within(screen.getByRole('navigation', { name: /main/i }))
await user.click(nav.getByRole('link', { name: /my task/i }))
expect(screen.getByRole('heading', { level: 1, name: /my task/i })).toBeInTheDocument()
expect(screen.getByRole('button', { name: /open navigation/i })).toHaveAttribute(
Expand Down
6 changes: 4 additions & 2 deletions src/components/layout/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useRef, useState } from 'react'
import { useSearchParams } from 'react-router'
import { Link, useSearchParams } from 'react-router'
import avatarUrl from '@/assets/avatar.png'
import { SearchIcon } from '@/components/ui/icons'
import { NotificationsBell } from '@/components/layout/NotificationsBell'
Expand Down Expand Up @@ -70,7 +70,9 @@ export function Header({ sidebarOpen, onOpenSidebar }: HeaderProps) {
</div>
<div className="hidden shrink-0 items-center gap-6 lg:flex">
<NotificationsBell />
<img className="size-10 rounded-full" src={avatarUrl} alt="Profile" />
<Link to="/settings" aria-label="Settings" className="rounded-full">
<img className="size-10 rounded-full" src={avatarUrl} alt="" />
</Link>
</div>
</header>
)
Expand Down
4 changes: 3 additions & 1 deletion src/components/layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import { Outlet, useLocation } from 'react-router'
import { ErrorBoundary } from '@/components/ui/ErrorBoundary'
import { Sidebar } from '@/components/layout/Sidebar'
import { Header } from '@/components/layout/Header'
import type { BoardLayout, ViewLayoutContext } from '@/components/layout/view-layout'

export function Layout() {
const location = useLocation()
const [sidebarOpen, setSidebarOpen] = useState(false)
const [layout, setLayout] = useState<BoardLayout>('grid')

useEffect(() => {
if (!sidebarOpen) return
Expand Down Expand Up @@ -38,7 +40,7 @@ export function Layout() {
/>
<main className="flex-1 overflow-y-auto p-4 lg:p-0 lg:pt-8">
<ErrorBoundary key={location.pathname}>
<Outlet />
<Outlet context={{ layout, setLayout } satisfies ViewLayoutContext} />
</ErrorBoundary>
</main>
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/components/layout/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { NavLink } from 'react-router'
import logoUrl from '@/assets/logos/ravn-logomark-white.svg'
import { GridIcon, ListIcon } from '@/components/ui/icons'
import { GridIcon, ListIcon, UserIcon } from '@/components/ui/icons'

const navItems = [
{ to: '/', label: 'Dashboard', Icon: GridIcon },
{ to: '/my-task', label: 'My Task', Icon: ListIcon },
{ to: '/settings', label: 'Settings', Icon: UserIcon },
]

interface SidebarProps {
Expand Down
16 changes: 16 additions & 0 deletions src/components/layout/view-layout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { useOutletContext } from 'react-router'

export type BoardLayout = 'grid' | 'list'

export interface ViewLayoutContext {
layout: BoardLayout
setLayout: (layout: BoardLayout) => void
}

export function useViewLayout(): ViewLayoutContext {
const context = useOutletContext<ViewLayoutContext | null>()
if (context === null) {
throw new Error('useViewLayout requires a route rendered inside Layout — check the router')
}
return context
}
12 changes: 12 additions & 0 deletions src/components/ui/icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,15 @@ export function BellIcon(props: IconProps) {
</svg>
)
}

export function UserIcon(props: IconProps) {
return (
<svg viewBox="0 0 24 24" fill="none" aria-hidden="true" {...props}>
<path
transform="translate(4 1)"
d="M16 21H0V19C0 17.6739 0.526784 16.4021 1.46447 15.4645C2.40215 14.5268 3.67392 14 5 14H11C12.3261 14 13.5979 14.5268 14.5355 15.4645C15.4732 16.4021 16 17.6739 16 19V21ZM8 12C7.21207 12 6.43185 11.8448 5.7039 11.5433C4.97595 11.2417 4.31451 10.7998 3.75736 10.2426C3.20021 9.68549 2.75825 9.02405 2.45672 8.2961C2.15519 7.56815 2 6.78793 2 6C2 5.21207 2.15519 4.43185 2.45672 3.7039C2.75825 2.97595 3.20021 2.31451 3.75736 1.75736C4.31451 1.20021 4.97595 0.758251 5.7039 0.456723C6.43185 0.155195 7.21207 0 8 0C9.5913 0 11.1174 0.632141 12.2426 1.75736C13.3679 2.88258 14 4.4087 14 6C14 7.5913 13.3679 9.11742 12.2426 10.2426C11.1174 11.3679 9.5913 12 8 12Z"
fill="currentColor"
/>
</svg>
)
}
97 changes: 96 additions & 1 deletion src/features/settings/Settings.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,98 @@
import avatarUrl from '@/assets/avatar.png'
import { avatarSrc } from '@/lib/avatar'
import { useProfile } from '@/lib/profile'
import { QueryErrorAlert } from '@/components/ui/QueryErrorAlert'
import type { ProfileQuery } from '@/graphql/generated/graphql'

const formatDate = (iso: string) =>
new Date(iso).toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' })

const titleCase = (value: string) =>
value.toLowerCase().replace(/\b\w/g, (letter) => letter.toUpperCase())

function ProfileSkeleton() {
return (
<>
<p role="status" className="sr-only">
Loading your profile…
</p>
<div aria-hidden="true" className="flex max-w-2xl flex-col gap-6 rounded-lg bg-neutral-4 p-6">
<div className="flex items-center gap-4">
<div className="size-16 animate-pulse rounded-full bg-neutral-3" />
<div className="flex flex-col gap-2">
<div className="h-6 w-48 animate-pulse rounded bg-neutral-3" />
<div className="h-4 w-64 animate-pulse rounded bg-neutral-3" />
</div>
</div>
<div className="h-32 animate-pulse rounded bg-neutral-3" />
</div>
</>
)
}

function ProfileCard({ user }: { user: ProfileQuery['profile'] }) {
return (
<section
aria-label="Profile"
className="flex max-w-2xl flex-col gap-6 rounded-lg bg-neutral-4 p-6"
>
<div className="flex items-center gap-4">
<img className="size-16 rounded-full" src={avatarSrc(user.avatar) ?? avatarUrl} alt="" />
<div className="min-w-0">
<h2 className="truncate text-body-xl font-semibold text-neutral-1">{user.fullName}</h2>
<p className="truncate text-body-m text-neutral-2">{user.email}</p>
</div>
</div>
<dl className="grid gap-x-8 gap-y-4 sm:grid-cols-2">
<div className="flex flex-col gap-1">
<dt className="text-body-s text-neutral-2">Full name</dt>
<dd className="text-body-m text-neutral-1">{user.fullName}</dd>
</div>
<div className="flex flex-col gap-1">
<dt className="text-body-s text-neutral-2">Email</dt>
<dd className="text-body-m text-neutral-1">{user.email}</dd>
</div>
<div className="flex flex-col gap-1">
<dt className="text-body-s text-neutral-2">Type</dt>
<dd>
<span className="rounded bg-neutral-2/10 px-4 py-1 text-body-m font-semibold text-neutral-1">
{titleCase(user.type)}
</span>
</dd>
</div>
<div className="flex flex-col gap-1">
<dt className="text-body-s text-neutral-2">Position</dt>
<dd className="text-body-m text-neutral-2">Not provided by the API</dd>
</div>
<div className="flex flex-col gap-1">
<dt className="text-body-s text-neutral-2">Created at</dt>
<dd className="text-body-m text-neutral-1">{formatDate(user.createdAt)}</dd>
</div>
<div className="flex flex-col gap-1">
<dt className="text-body-s text-neutral-2">Updated at</dt>
<dd className="text-body-m text-neutral-1">{formatDate(user.updatedAt)}</dd>
</div>
</dl>
</section>
)
}

export function Settings() {
return <h1>Settings</h1>
const profile = useProfile()

return (
<div className="flex flex-col gap-6">
<h1 className="text-body-xl font-semibold text-neutral-1">Settings</h1>
{profile.isPending && <ProfileSkeleton />}
{profile.isError && (
<QueryErrorAlert
message="Something went wrong while loading your profile."
onRetry={() => {
void profile.refetch()
}}
/>
)}
{profile.data !== undefined && <ProfileCard user={profile.data.profile} />}
</div>
)
}
5 changes: 2 additions & 3 deletions src/features/tasks/Dashboard.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { useState } from 'react'
import { useSearchParams } from 'react-router'
import { Toolbar } from '@/features/tasks/Toolbar'
import { FilterBar } from '@/features/tasks/FilterBar'
import { TasksView } from '@/features/tasks/TasksView'
import { filterInputFromParams, hasActiveFilters } from '@/features/tasks/filter-params'
import type { BoardLayout } from '@/features/tasks/types'
import { useViewLayout } from '@/components/layout/view-layout'

export function Dashboard() {
const [layout, setLayout] = useState<BoardLayout>('grid')
const { layout, setLayout } = useViewLayout()
const [searchParams] = useSearchParams()
return (
<div className="flex h-full flex-col gap-5 lg:gap-4">
Expand Down
3 changes: 2 additions & 1 deletion src/features/tasks/FilterBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import { useState } from 'react'
import { useSearchParams } from 'react-router'
import { useQuery } from '@tanstack/react-query'
import avatarUrl from '@/assets/avatar.png'
import { avatarSrc } from '@/lib/avatar'
import { graphqlClient } from '@/lib/graphql-client'
import { UsersDocument } from '@/features/tasks/queries'
import { MenuPanel } from '@/features/tasks/MenuPanel'
import { DatePicker, DatePickerDialog } from '@/features/tasks/DatePicker'
import { avatarSrc, POINTS, STATUS_COLUMNS, TAG_META } from '@/features/tasks/task-display'
import { POINTS, STATUS_COLUMNS, TAG_META } from '@/features/tasks/task-display'
import { FILTER_PARAM_KEYS, hasActiveFilters, parseDueParam } from '@/features/tasks/filter-params'
import type { PointEstimate, TaskTag } from '@/graphql/generated/graphql'

Expand Down
16 changes: 5 additions & 11 deletions src/features/tasks/MyTask.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
import { useState } from 'react'
import { useSearchParams } from 'react-router'
import { useQuery } from '@tanstack/react-query'
import { graphqlClient } from '@/lib/graphql-client'
import { ProfileDocument } from '@/features/tasks/queries'
import { QueryErrorAlert } from '@/features/tasks/QueryErrorAlert'
import { useProfile } from '@/lib/profile'
import { QueryErrorAlert } from '@/components/ui/QueryErrorAlert'
import { Toolbar } from '@/features/tasks/Toolbar'
import { FilterBar } from '@/features/tasks/FilterBar'
import { TasksView } from '@/features/tasks/TasksView'
import { filterInputFromParams, hasActiveFilters } from '@/features/tasks/filter-params'
import type { BoardLayout } from '@/features/tasks/types'
import { useViewLayout } from '@/components/layout/view-layout'

export function MyTask() {
const [layout, setLayout] = useState<BoardLayout>('list')
const { layout, setLayout } = useViewLayout()
const [searchParams] = useSearchParams()
const profile = useQuery({
queryKey: ['profile'],
queryFn: () => graphqlClient.request(ProfileDocument),
})
const profile = useProfile()

return (
<div className="flex h-full flex-col gap-5 lg:gap-4">
Expand Down
9 changes: 2 additions & 7 deletions src/features/tasks/TaskCard.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import avatarUrl from '@/assets/avatar.png'
import { avatarSrc } from '@/lib/avatar'
import { AlarmIcon } from '@/features/tasks/icons'
import {
avatarSrc,
dueInfo,
pointsLabel,
TAG_META,
tagToneClasses,
} from '@/features/tasks/task-display'
import { dueInfo, pointsLabel, TAG_META, tagToneClasses } from '@/features/tasks/task-display'
import { TaskActions } from '@/features/tasks/TaskActions'
import type { ApiTask } from '@/features/tasks/types'

Expand Down
5 changes: 3 additions & 2 deletions src/features/tasks/TaskForm.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import { useState } from 'react'
import { useQuery } from '@tanstack/react-query'
import avatarUrl from '@/assets/avatar.png'
import { avatarSrc } from '@/lib/avatar'
import { graphqlClient } from '@/lib/graphql-client'
import { UsersDocument } from '@/features/tasks/queries'
import { useDialogFocus } from '@/components/ui/use-dialog-focus'
import { MenuPanel } from '@/features/tasks/MenuPanel'
import { avatarSrc, POINTS, STATUS_COLUMNS, TAG_META } from '@/features/tasks/task-display'
import { POINTS, STATUS_COLUMNS, TAG_META } from '@/features/tasks/task-display'
import { DatePicker, DatePickerDialog } from '@/features/tasks/DatePicker'
import { UserIcon } from '@/components/ui/icons'
import {
CalendarIcon,
CheckboxBlankIcon,
CheckboxCheckedIcon,
CloseIcon,
EstimateIcon,
LabelIcon,
UserIcon,
} from '@/features/tasks/icons'
import type { PointEstimate, Status, TaskTag } from '@/graphql/generated/graphql'

Expand Down
2 changes: 1 addition & 1 deletion src/features/tasks/TaskList.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import avatarUrl from '@/assets/avatar.png'
import { avatarSrc } from '@/lib/avatar'
import { CaretDownIcon } from '@/features/tasks/icons'
import { TaskActions } from '@/features/tasks/TaskActions'
import {
avatarSrc,
dueInfo,
POINTS,
TAG_META,
Expand Down
Loading