Skip to content

billing hooks, channel stats, trained-videos persistence, and stats tooling#148

Open
GauravOP-03 wants to merge 7 commits intoscriptaiapp:mainfrom
GauravOP-03:feat/web-billing-stats-hooks-tooling
Open

billing hooks, channel stats, trained-videos persistence, and stats tooling#148
GauravOP-03 wants to merge 7 commits intoscriptaiapp:mainfrom
GauravOP-03:feat/web-billing-stats-hooks-tooling

Conversation

@GauravOP-03
Copy link
Copy Markdown
Collaborator

📝 Description

Extend the web app with billing and channel stats hooks, stats formatting utilities, and trained-videos persistence. Integrate shared @repo/validation types for billing and channel stats, persist trained videos before AI training, and update styles/config. Only modified and new files are included; no unrelated changes.

🎯 Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🎨 Style/UI changes (formatting, missing semi colons, etc; no logic change)
  • ♻️ Refactoring (no functional changes, code improvements)
  • ⚡ Performance improvements
  • 🧪 Adding or updating tests
  • 🔧 Configuration changes

🧪 Testing

  • I have tested my changes locally
  • I have added tests for my changes
  • All existing tests pass
  • I have tested on different browsers/devices (if applicable)

Describe briefly:

  • Tested billing hook (plans, checkout, portal).
  • Tested channel stats hook (forceSync true/false).
  • Confirmed trained videos save before AI training.
  • Verified stats formatting and UI styles.

📋 Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have checked my code and corrected any misspellings
  • I have read the Contributing Guide

🔧 Technical Details

  • hooks/useBilling.ts

    • Uses Plan and BillingInfo from @repo/validation.
    • Fetches plans and billing info from /api/v1/billing/plans and /api/v1/billing/info.
    • Exposes subscribe(planId) for checkout and openPortal() for Stripe portal.
    • Exposes refresh: loadAll to reload plans and billing info.
  • hooks/useChannelStats.ts

    • Uses ChannelStats from @repo/validation.
    • Fetches from /api/v1/youtube/channel-stats?forceSync=${forceSync}.
    • Exposes stats, loading, error, fetchStats(forceSync?).
  • utils/toolsUtil.ts

    • formatCount(n) – K/M formatting for view counts.
    • formatFileSize(bytes) – Human-readable file size.
    • parseDuration(iso) – Parses YouTube ISO 8601 to m:ss or h:mm:ss.
    • timeAgo(dateStr) – Returns label + style for badges ("Today", "5d ago", etc.).
    • formatTime(seconds) – Formats as m:ss.
  • hooks/useAITraining.ts

    • Calls POST /api/v1/youtube/trained-videos with selectedVideos before starting training.
    • Ensures trained videos are persisted in youtube_channels.youtube_trained_videos before the AI training job runs.
  • package.json

    • Dependency updates (e.g. recharts, date-fns for stats, UI libraries).
  • tailwind.config.ts

    • Theme colors, keyframes, and animations for stats and other UI elements.
  • app/globals.css

    • Scrollbar, tiptap editor, and base/dark mode styles.

🚀 Deployment Notes

  • No extra env vars needed; uses existing API endpoints.
  • No deployment-specific changes.

📚 Documentation Updates

  • README.md updated
  • CONTRIBUTING.md updated (if applicable)
  • API documentation updated (if applicable)
  • Component documentation updated (if applicable)

🔍 Review Notes

  • Ensure useBilling and useChannelStats correctly use @repo/validation types.
  • Confirm toolsUtil helpers match usage (e.g. timeAgo label/style).
  • Confirm trained-videos persistence order in the AI training flow.

📊 Performance Impact

  • No performance impact
  • Performance improvement
  • Performance regression (explain below)

🔒 Security Considerations

  • No security implications
  • Security improvement
  • Potential security concern (explain below)

Details:

  • Billing and channel stats use authenticated API calls via requireAuth: true.

🎉 Additional Notes

  • Hooks and utilities are built to align with the backend billing and channel stats APIs and the shared @repo/validation schema.

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Feb 28, 2026

@GauravOP-03 is attempting to deploy a commit to the afrin127329's projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant