Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Tentwenty Timesheet Application

A modern, fully-featured timesheet management application built with Next.js 14, TypeScript, and Tailwind CSS. This application allows users to create, manage, and track their weekly timesheets with a clean and intuitive interface.

Next.js TypeScript Tailwind CSS

✨ Features

  • πŸ” Authentication - Secure login with NextAuth.js
  • πŸ“… Dynamic Timesheet Management - Create timesheets for any week
  • ✏️ Task Management - Add, edit, and delete tasks with custom projects
  • πŸ’Ύ Persistent Storage - LocalStorage integration for data persistence
  • πŸ“Š Progress Tracking - Visual progress bars and status indicators
  • 🎨 Fully Responsive - Works seamlessly on mobile, tablet, and desktop
  • πŸš€ No Static Data - All data is user-generated and dynamic

πŸš€ Getting Started

Prerequisites

Make sure you have the following installed on your machine:

  • Node.js (v18 or higher)
  • npm or yarn or pnpm or bun

Installation

  1. Clone the repository

    git clone <repository-url>
    cd tentwenty-timesheet
  2. Install dependencies

    npm install
    # or
    yarn install
    # or
    pnpm install
    # or
    bun install
  3. Set up environment variables

    Create a .env file in the root directory:

    NEXTAUTH_URL=http://localhost:3000
    NEXTAUTH_SECRET=your-secret-key-here
  4. Run the development server

    npm run dev
    # or
    yarn dev
    # or
    pnpm dev
    # or
    bun dev
  5. Open your browser

    Navigate to http://localhost:3000


πŸ“ Default Login Credentials

For testing purposes, use these credentials:

  • Email: admin@tentwenty.com
  • Password: admin123

πŸ“ Project Structure

tentwenty-timesheet/
β”œβ”€β”€ app/                          # Next.js App Router
β”‚   β”œβ”€β”€ api/                      # API Routes
β”‚   β”‚   └── auth/                 # NextAuth.js authentication
β”‚   β”‚       └── [...nextauth]/
β”‚   β”‚           └── route.ts      # Auth configuration & handlers
β”‚   β”œβ”€β”€ dashboard/                # Dashboard pages
β”‚   β”‚   β”œβ”€β”€ page.tsx             # Main timesheet list page
β”‚   β”‚   └── [id]/                # Dynamic timesheet detail pages
β”‚   β”‚       └── page.tsx         # Individual timesheet view
β”‚   β”œβ”€β”€ login/                    # Authentication pages
β”‚   β”‚   └── page.tsx             # Login page
β”‚   β”œβ”€β”€ layout.tsx               # Root layout with providers
β”‚   β”œβ”€β”€ page.tsx                 # Home page (redirects to dashboard)
β”‚   └── globals.css              # Global styles & Tailwind
β”‚
β”œβ”€β”€ components/                   # Reusable React components
β”‚   β”œβ”€β”€ common/                  # Common/shared components
β”‚   β”‚   β”œβ”€β”€ Footer.tsx           # Footer component
β”‚   β”‚   β”œβ”€β”€ LoginForm.tsx        # Login form with validation
β”‚   β”‚   β”œβ”€β”€ Navbar.tsx           # Navigation bar
β”‚   β”‚   β”œβ”€β”€ TimesheetModal.tsx   # Modal for adding/editing tasks
β”‚   β”‚   └── TimesheetTable.tsx   # Table displaying all timesheets
β”‚   β”œβ”€β”€ providers/               # Context providers
β”‚   β”‚   └── Providers.tsx        # Wraps app with all providers
β”‚   └── ui/                      # UI components (design system)
β”‚       β”œβ”€β”€ button.tsx           # Reusable button component
β”‚       β”œβ”€β”€ Dropdown.tsx         # Dropdown select component
β”‚       β”œβ”€β”€ input.tsx            # Reusable input (text, checkbox)
β”‚       β”œβ”€β”€ pagination.tsx       # Pagination controls
β”‚       └── TaskMenu.tsx         # Task menu (edit/delete options)
β”‚
β”œβ”€β”€ context/                      # React Context for state management
β”‚   β”œβ”€β”€ AuthContext.tsx          # Authentication state & logic
β”‚   └── TimesheetContext.tsx     # Timesheet data & CRUD operations
β”‚
β”œβ”€β”€ hooks/                        # Custom React hooks
β”‚   └── useTimesheet.tsx         # Hooks for timesheet operations
β”‚
β”œβ”€β”€ types/                        # TypeScript type definitions
β”‚   └── timesheet.ts             # Timesheet & Task interfaces
β”‚
β”œβ”€β”€ utils/                        # Utility functions
β”‚   └── dateHelpers.ts           # Date manipulation & formatting
β”‚
β”œβ”€β”€ public/                       # Static assets
β”‚   └── *.svg                    # Icons and images
β”‚
β”œβ”€β”€ middleware.ts                 # Next.js middleware (auth protection)
β”œβ”€β”€ next.config.ts               # Next.js configuration
β”œβ”€β”€ tailwind.config.ts           # Tailwind CSS configuration
β”œβ”€β”€ tsconfig.json                # TypeScript configuration
└── package.json                 # Dependencies & scripts

πŸ—‚οΈ File & Folder Explanations

/app - Application Pages (Next.js App Router)

app/api/auth/[...nextauth]/route.ts

  • Configures NextAuth.js for authentication
  • Handles login/logout functionality
  • Credentials provider for demo login

app/dashboard/page.tsx

  • Main dashboard displaying all timesheets in a table
  • Features: Create new timesheet, filter by status, pagination
  • Shows week number, date range, status badges

app/dashboard/[id]/page.tsx

  • Detailed view of a single timesheet
  • Displays tasks grouped by weekday (Mon-Fri)
  • Add/edit/delete tasks for each day
  • Shows progress bar (hours logged / 40 hours target)

app/login/page.tsx

  • Login page with email/password form
  • Split layout: form on left, branding on right
  • Responsive design for mobile

app/layout.tsx

  • Root layout wrapping entire app
  • Includes all providers (Auth, Timesheet)
  • Sets up fonts and metadata

/components - Reusable UI Components

/components/common - Shared Components

LoginForm.tsx
  • Handles user authentication
  • Uses common Input component for fields
  • Integrates with AuthContext for login logic
Navbar.tsx
  • Top navigation bar
  • User profile dropdown
  • Logout functionality
TimesheetModal.tsx
  • Modal for adding/editing tasks
  • Dynamic input fields (no static dropdowns)
  • Pre-fills data when editing existing tasks
  • Validates required fields
TimesheetTable.tsx
  • Table component displaying all timesheets
  • Filter by status (COMPLETED, INCOMPLETE, MISSING)
  • Pagination controls
  • "Create New Timesheet" button
Footer.tsx
  • Simple footer with copyright

/components/ui - UI Design System

button.tsx
  • Reusable button component
  • Props: fullWidth, variant, disabled
  • Consistent styling across app
input.tsx
  • Versatile input component
  • Supports: text, email, password, checkbox
  • checkboxLabel prop for inline labels
  • Focus states and validation
Dropdown.tsx
  • Select dropdown component
  • Used for filters (date range, status)
pagination.tsx
  • Pagination controls for table
  • Change items per page
  • Navigate between pages
TaskMenu.tsx
  • Three-dot menu for task actions
  • Options: Edit, Delete
  • Hover/click to show menu

/context - State Management

AuthContext.tsx

  • Manages authentication state
  • Login/logout functions
  • User session management
  • Error handling

TimesheetContext.tsx

  • Centralized timesheet data management
  • CRUD operations: Create, Read, Update, Delete
  • LocalStorage integration for persistence
  • Auto-calculates timesheet status based on hours:
    • MISSING: 0 hours logged
    • INCOMPLETE: 1-39 hours logged
    • COMPLETED: 40+ hours logged

/hooks - Custom React Hooks

useTimesheet.tsx

Contains two hooks:

useTimesheet(timesheetId)
  • For detail page - manages individual timesheet
  • Returns: tasks grouped by date, progress percentage
  • Functions: addTask, updateTask, deleteTask
useTimesheetsList()
  • For list page - manages all timesheets
  • Handles filtering and pagination
  • Functions: createTimesheet, deleteTimesheet

/types - TypeScript Definitions

timesheet.ts

Defines interfaces for type safety:

interface Task {
  id: string;
  date: string;
  project: string;      // User-entered project name
  workType: string;     // User-entered work type
  description: string;
  hours: number;
  status?: "completed" | "incomplete" | "pending";
}

interface TimesheetRecord {
  id: string;
  week: number;
  dateRange: string;
  status: "COMPLETED" | "INCOMPLETE" | "MISSING";
  tasks: Task[];
  startDate: string;
  endDate: string;
}

/utils - Helper Functions

dateHelpers.ts

Date manipulation utilities:

getWeekStartDate(date: Date)
  • Returns Monday of any given week
getWeekDates(weekOffset: number)
  • Calculates week dates based on current date + offset
  • Returns formatted date strings and week number
generateWeekDates(startDateString: string)
  • Generates 5 working days (Mon-Fri) from a start date
  • Returns array of dates with labels

πŸ”„ How It Works

1. Authentication Flow

User enters credentials β†’ AuthContext validates β†’ NextAuth creates session β†’ Redirect to dashboard

2. Creating a Timesheet

Click "Create New Timesheet" β†’ System calculates current week + offset β†’ Creates new timesheet β†’ Saves to localStorage

3. Adding Tasks

Click "Add new task" β†’ Modal opens β†’ User enters project, work type, description, hours β†’ Task saved β†’ Status auto-updates

4. Data Persistence

Any CRUD operation β†’ TimesheetContext updates state β†’ useEffect triggers β†’ Data saved to localStorage β†’ Survives page refresh

5. Status Calculation

Task added/updated/deleted β†’ Calculate total hours β†’ Update status:
  - 0 hours = MISSING
  - 1-39 hours = INCOMPLETE
  - 40+ hours = COMPLETED

🎨 Styling

  • Framework: Tailwind CSS
  • Custom Theme: Extended in tailwind.config.ts
  • Responsive: Mobile-first approach
  • Colors:
    • Primary: #FF8A4C (Orange)
    • Status badges: Green, Yellow, Pink

πŸ”§ Available Scripts

# Development
npm run dev          # Start dev server at localhost:3000

# Production
npm run build        # Build for production
npm run start        # Start production server

# Code Quality
npm run lint         # Run ESLint

🌟 Key Features Explained

1. Fully Dynamic Data

  • No hardcoded projects or work types
  • Users enter any text they want
  • True flexibility for different workflows

2. LocalStorage Persistence

  • All data saved automatically
  • Survives browser refresh and closure
  • No backend required for demo

3. Responsive Design

  • Mobile: Stacked layouts, full-width buttons
  • Tablet: Hybrid layouts
  • Desktop: Side-by-side layouts, optimal spacing

4. Type Safety

  • Full TypeScript coverage
  • Interfaces for all data structures
  • Type-safe API calls

πŸ“š Technologies Used


Tentwenty Team

For questions or support, please contact: muhammadahmedite@gmail.com


Made for ❀️ Tentwenty

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages