Repository Name
string
Filepath in the Repository
string
File Contents
string
threads
components\cards\CommunityCard.tsx
import Image from "next/image"; import Link from "next/link"; import { Button } from "../ui/button"; interface Props { id: string; name: string; username: string; imgUrl: string; bio: string; members: { image: string; }[]; } function CommunityCard({ id, name, username, imgUrl, bio, members }: Props...
threads
components\cards\ThreadCard.tsx
import Image from "next/image"; import Link from "next/link"; import { formatDateString } from "@/lib/utils"; import DeleteThread from "../forms/DeleteThread"; interface Props { id: string; currentUserId: string; parentId: string | null; content: string; author: { name: string; image: string; id...
threads
components\cards\UserCard.tsx
"use client"; import Image from "next/image"; import { useRouter } from "next/navigation"; import { Button } from "../ui/button"; interface Props { id: string; name: string; username: string; imgUrl: string; personType: string; } function UserCard({ id, name, username, imgUrl, personType }: Props) { con...
threads
components\forms\AccountProfile.tsx
"use client"; import * as z from "zod"; import Image from "next/image"; import { useForm } from "react-hook-form"; import { usePathname, useRouter } from "next/navigation"; import { ChangeEvent, useState } from "react"; import { zodResolver } from "@hookform/resolvers/zod"; import { Form, FormControl, FormField...
threads
components\forms\Comment.tsx
"use client"; import { z } from "zod"; import Image from "next/image"; import { useForm } from "react-hook-form"; import { usePathname } from "next/navigation"; import { zodResolver } from "@hookform/resolvers/zod"; import { Form, FormControl, FormField, FormItem, FormLabel, } from "@/components/ui/form"; ...
threads
components\forms\DeleteThread.tsx
"use client"; import Image from "next/image"; import { usePathname, useRouter } from "next/navigation"; import { deleteThread } from "@/lib/actions/thread.actions"; interface Props { threadId: string; currentUserId: string; authorId: string; parentId: string | null; isComment?: boolean; } function DeleteT...
threads
components\forms\PostThread.tsx
"use client"; import * as z from "zod"; import { useForm } from "react-hook-form"; import { useOrganization } from "@clerk/nextjs"; import { zodResolver } from "@hookform/resolvers/zod"; import { usePathname, useRouter } from "next/navigation"; import { Form, FormControl, FormField, FormItem, FormLabel, F...
threads
components\shared\Bottombar.tsx
"use client"; import Image from "next/image"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { sidebarLinks } from "@/constants"; function Bottombar() { const pathname = usePathname(); return ( <section className='bottombar'> <div className='bottombar_container'> ...
threads
components\shared\LeftSidebar.tsx
"use client"; import Image from "next/image"; import Link from "next/link"; import { usePathname, useRouter } from "next/navigation"; import { SignOutButton, SignedIn, useAuth } from "@clerk/nextjs"; import { sidebarLinks } from "@/constants"; const LeftSidebar = () => { const router = useRouter(); const pathnam...
threads
components\shared\Pagination.tsx
"use client"; import { useRouter } from "next/navigation"; import { Button } from "../ui/button"; interface Props { pageNumber: number; isNext: boolean; path: string; } function Pagination({ pageNumber, isNext, path }: Props) { const router = useRouter(); const handleNavigation = (type: string) => { ...
threads
components\shared\ProfileHeader.tsx
import Link from "next/link"; import Image from "next/image"; interface Props { accountId: string; authUserId: string; name: string; username: string; imgUrl: string; bio: string; type?: string; } function ProfileHeader({ accountId, authUserId, name, username, imgUrl, bio, type, }: Props) ...
threads
components\shared\RightSidebar.tsx
import { currentUser } from "@clerk/nextjs"; import UserCard from "../cards/UserCard"; import { fetchCommunities } from "@/lib/actions/community.actions"; import { fetchUsers } from "@/lib/actions/user.actions"; async function RightSidebar() { const user = await currentUser(); if (!user) return null; const si...
threads
components\shared\Searchbar.tsx
"use client"; import Image from "next/image"; import { useRouter } from "next/navigation"; import { useEffect, useState } from "react"; import { Input } from "../ui/input"; interface Props { routeType: string; } function Searchbar({ routeType }: Props) { const router = useRouter(); const [search, setSearch] =...
threads
components\shared\ThreadsTab.tsx
import { redirect } from "next/navigation"; import { fetchCommunityPosts } from "@/lib/actions/community.actions"; import { fetchUserPosts } from "@/lib/actions/user.actions"; import ThreadCard from "../cards/ThreadCard"; interface Result { name: string; image: string; id: string; threads: { _id: string;...
threads
components\shared\Topbar.tsx
import { OrganizationSwitcher, SignedIn, SignOutButton } from "@clerk/nextjs"; import { dark } from "@clerk/themes"; import Image from "next/image"; import Link from "next/link"; function Topbar() { return ( <nav className='topbar'> <Link href='/' className='flex items-center gap-4'> <Image src='/l...
threads
components\ui\button.tsx
import * as React from "react" import { Slot } from "@radix-ui/react-slot" import { cva, type VariantProps } from "class-variance-authority" import { cn } from "@/lib/utils" const buttonVariants = cva( "inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-white transition-colors focus-...
threads
components\ui\form.tsx
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 "@/c...
threads
components\ui\input.tsx
import * as React from "react"; import { cn } from "@/lib/utils"; export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {} const Input = React.forwardRef<HTMLInputElement, InputProps>( ({ className, type, ...props }, ref) => { return ( <input type={type} classN...
threads
components\ui\label.tsx
"use client" 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-...
threads
components\ui\menubar.tsx
"use client" import * as React from "react" import * as MenubarPrimitive from "@radix-ui/react-menubar" import { Check, ChevronRight, Circle } from "lucide-react" import { cn } from "@/lib/utils" const MenubarMenu = MenubarPrimitive.Menu const MenubarGroup = MenubarPrimitive.Group const MenubarPortal = MenubarPrim...
threads
components\ui\select.tsx
"use client" import * as React from "react" import * as SelectPrimitive from "@radix-ui/react-select" import { Check, ChevronDown } from "lucide-react" import { cn } from "@/lib/utils" const Select = SelectPrimitive.Root const SelectGroup = SelectPrimitive.Group const SelectValue = SelectPrimitive.Value const Sel...
threads
components\ui\tabs.tsx
"use client"; import * as React from "react"; import * as TabsPrimitive from "@radix-ui/react-tabs"; import { cn } from "@/lib/utils"; const Tabs = TabsPrimitive.Root; const TabsList = React.forwardRef< React.ElementRef<typeof TabsPrimitive.List>, React.ComponentPropsWithoutRef<typeof TabsPrimitive.List> >(({ c...
threads
components\ui\textarea.tsx
import * as React from "react" import { cn } from "@/lib/utils" export interface TextareaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {} const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>( ({ className, ...props }, ref) => { return ( <textarea className={cn...
threads
components\ui\toast.tsx
import * as React from "react" import * as ToastPrimitives from "@radix-ui/react-toast" import { cva, type VariantProps } from "class-variance-authority" import { X } from "lucide-react" import { cn } from "@/lib/utils" const ToastProvider = ToastPrimitives.Provider const ToastViewport = React.forwardRef< React.El...
threads
components\ui\toaster.tsx
"use client" import { Toast, ToastClose, ToastDescription, ToastProvider, ToastTitle, ToastViewport, } from "@/components/ui/toast" import { useToast } from "@/components/ui/use-toast" export function Toaster() { const { toasts } = useToast() return ( <ToastProvider> {toasts.map(function ({...
threads
components\ui\use-toast.ts
// Inspired by react-hot-toast library import * as React from "react" import type { ToastActionElement, ToastProps, } from "@/components/ui/toast" const TOAST_LIMIT = 1 const TOAST_REMOVE_DELAY = 1000000 type ToasterToast = ToastProps & { id: string title?: React.ReactNode description?: React.ReactNode a...
threads
constants\index.js
export const sidebarLinks = [ { imgURL: "/assets/home.svg", route: "/", label: "Home", }, { imgURL: "/assets/search.svg", route: "/search", label: "Search", }, { imgURL: "/assets/heart.svg", route: "/activity", label: "Activity", }, { imgURL: "/assets/create.svg", ...
threads
lib\mongoose.ts
import mongoose from "mongoose"; let isConnected = false; // Variable to track the connection status export const connectToDB = async () => { // Set strict query mode for Mongoose to prevent unknown field queries. mongoose.set("strictQuery", true); if (!process.env.MONGODB_URL) return console.log("Missing Mong...
threads
lib\uploadthing.ts
// Resource: https://docs.uploadthing.com/api-reference/react#generatereacthelpers // Copy paste (be careful with imports) import { generateReactHelpers } from "@uploadthing/react/hooks"; import type { OurFileRouter } from "@/app/api/uploadthing/core"; export const { useUploadThing, uploadFiles } = generateReactHe...
threads
lib\utils.ts
import { type ClassValue, clsx } from "clsx"; import { twMerge } from "tailwind-merge"; // generated by shadcn export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); } // created by chatgpt export function isBase64Image(imageData: string) { const base64Regex = /^data:image\/(png|jpe?g|gif|web...
threads
lib\actions\community.actions.ts
"use server"; import { FilterQuery, SortOrder } from "mongoose"; import Community from "../models/community.model"; import Thread from "../models/thread.model"; import User from "../models/user.model"; import { connectToDB } from "../mongoose"; export async function createCommunity( id: string, name: string, ...
threads
lib\actions\thread.actions.ts
"use server"; import { revalidatePath } from "next/cache"; import { connectToDB } from "../mongoose"; import User from "../models/user.model"; import Thread from "../models/thread.model"; import Community from "../models/community.model"; export async function fetchPosts(pageNumber = 1, pageSize = 20) { connectTo...
threads
lib\actions\user.actions.ts
"use server"; import { FilterQuery, SortOrder } from "mongoose"; import { revalidatePath } from "next/cache"; import Community from "../models/community.model"; import Thread from "../models/thread.model"; import User from "../models/user.model"; import { connectToDB } from "../mongoose"; export async function fetc...
threads
lib\models\community.model.ts
import mongoose from "mongoose"; const communitySchema = new mongoose.Schema({ id: { type: String, required: true, }, username: { type: String, unique: true, required: true, }, name: { type: String, required: true, }, image: String, bio: String, createdBy: { type: mong...
threads
lib\models\thread.model.ts
import mongoose from "mongoose"; const threadSchema = new mongoose.Schema({ text: { type: String, required: true, }, author: { type: mongoose.Schema.Types.ObjectId, ref: "User", required: true, }, community: { type: mongoose.Schema.Types.ObjectId, ref: "Community", }, createdA...
threads
lib\models\user.model.ts
import mongoose from "mongoose"; const userSchema = new mongoose.Schema({ id: { type: String, required: true, }, username: { type: String, unique: true, required: true, }, name: { type: String, required: true, }, image: String, bio: String, threads: [ { type: mon...
threads
lib\validations\thread.ts
import * as z from "zod"; export const ThreadValidation = z.object({ thread: z.string().nonempty().min(3, { message: "Minimum 3 characters." }), accountId: z.string(), }); export const CommentValidation = z.object({ thread: z.string().nonempty().min(3, { message: "Minimum 3 characters." }), });
threads
lib\validations\user.ts
import * as z from "zod"; export const UserValidation = z.object({ profile_photo: z.string().url().nonempty(), name: z .string() .min(3, { message: "Minimum 3 characters." }) .max(30, { message: "Maximum 30 caracters." }), username: z .string() .min(3, { message: "Minimum 3 characters." }) ...