-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from ruru-m07/main
🚀 dashboard
- Loading branch information
Showing
25 changed files
with
609 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"use server"; | ||
|
||
import { db } from "@/lib/db"; | ||
|
||
export const updateBio = async (username: string, bio: string) => { | ||
if (!username) { | ||
return { error: "Invalid user!" }; | ||
} | ||
await db.user.update({ | ||
where: { username: username }, | ||
data: { | ||
bio: bio, | ||
}, | ||
}); | ||
|
||
return { success: "Profile update Successfully! 🎉" }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
app/[username]/[repository]/upload/[branch]/[[...path]]/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import Upload from "../../components/Upload"; | ||
|
||
export default function Page() { | ||
return ( | ||
<main className="mx-6 my-5 xl:mx-60"> | ||
<div> | ||
<Upload /> | ||
</div> | ||
</main> | ||
); | ||
} |
157 changes: 157 additions & 0 deletions
157
app/[username]/[repository]/upload/components/Upload.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
"use client"; | ||
|
||
import React, { useEffect, useState } from "react"; | ||
import Dropzone from "react-dropzone"; | ||
import { FileWithPath } from "file-selector"; | ||
import { | ||
FileCode2, | ||
GitCommitHorizontal, | ||
GitPullRequestArrow, | ||
} from "lucide-react"; | ||
import { Card } from "@/components/ui/card"; | ||
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; | ||
import { useAuth } from "@/context/userContext"; | ||
import { Input } from "@/components/ui/input"; | ||
import { Textarea } from "@/components/ui/textarea"; | ||
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; | ||
import { Button } from "@/components/ui/button"; | ||
import { Label } from "@/components/ui/label"; | ||
import { useParams } from "next/navigation"; | ||
import Link from "next/link"; | ||
|
||
const Upload = () => { | ||
const { user } = useAuth(); | ||
const params = useParams<{ | ||
username: string; | ||
repository: string; | ||
branch: string; | ||
}>(); | ||
console.log(params); | ||
const [files, setFiles] = useState<FileWithPath[]>([]); | ||
|
||
const handlechange = async (acceptFiles: FileWithPath[]) => { | ||
// Items to ignore | ||
const ignoreList = [ | ||
".env", | ||
"node_modules", | ||
".git", | ||
".next", | ||
".vercel", | ||
"dist", | ||
]; | ||
|
||
// console.log(acceptFiles); | ||
// Filter out files or folders listed in the ignoreList | ||
|
||
const filteredFiles = acceptFiles.filter((file) => { | ||
const fileName = file.path && file.path.toLowerCase(); | ||
return !ignoreList.some((item) => fileName?.includes(item.toLowerCase())); | ||
}); | ||
|
||
setFiles((prevFiles) => [...prevFiles, ...filteredFiles]); | ||
}; | ||
|
||
useEffect(() => { | ||
console.log(files); | ||
}, [files]); | ||
|
||
return ( | ||
<div> | ||
<div className="my-2 text-xl"> | ||
<Link | ||
className=" hover:text-blue-700 hover:underline" | ||
href={`/${params.username}/${params.repository}`} | ||
> | ||
{params.repository}{" "} | ||
</Link>{" "} | ||
/ | ||
</div> | ||
<div className="items-center justify-center w-full p-5 border rounded-md"> | ||
<Dropzone onDrop={(acceptedFiles) => handlechange(acceptedFiles)}> | ||
{({ getRootProps, getInputProps, isDragActive }) => ( | ||
<section className="flex items-center justify-center h-96"> | ||
<div | ||
className="flex items-center justify-center w-full h-full " | ||
{...getRootProps()} | ||
> | ||
<input {...getInputProps()} /> | ||
{isDragActive ? ( | ||
<div className="flex items-center justify-center w-full h-full border-4 border-dashed rounded-md"> | ||
<div className="grid place-items-center"> | ||
<FileCode2 | ||
className="mb-5 text-muted-foreground" | ||
size={50} | ||
/> | ||
<p className="text-muted-foreground"> | ||
Drop to Upload file | ||
</p> | ||
</div> | ||
</div> | ||
) : ( | ||
<div className="grid w-full place-items-center"> | ||
<FileCode2 | ||
className="mb-5 text-muted-foreground" | ||
size={50} | ||
/> | ||
|
||
<p className="text-muted-foreground"> | ||
Drag files here to add them to your repository | ||
</p> | ||
<p className="text-muted-foreground"> | ||
or | ||
<span className="text-blue-600 cursor-pointer hover:underline"> | ||
choose your file | ||
</span> | ||
</p> | ||
</div> | ||
)} | ||
</div> | ||
</section> | ||
)} | ||
</Dropzone> | ||
</div> | ||
|
||
<Card className="flex my-5 border-none rounded-md"> | ||
<div> | ||
<Avatar> | ||
<AvatarImage | ||
src={user?.image || "https://asset-cocola.vercel.app/copilot.png"} | ||
alt={user?.username || "profile"} | ||
/> | ||
<AvatarFallback> </AvatarFallback> | ||
</Avatar> | ||
</div> | ||
<div className="w-full ml-4 comment-box"> | ||
<Card className="w-full p-4 rounded-md"> | ||
<h1 className="text-xl ">Commit changes</h1> | ||
<Input className="my-3" placeholder="Add file via upload" /> | ||
<Textarea | ||
rows={5} | ||
placeholder="Add an optional extended description..." | ||
/> | ||
<RadioGroup className="mt-3" defaultValue="main"> | ||
<div className="flex items-center space-x-2"> | ||
<RadioGroupItem value="main" id="r1" /> | ||
<GitCommitHorizontal size={25} /> | ||
<p className="ml-2">Commit directly to the main branch.</p> | ||
</div> | ||
<div className="flex items-center space-x-2"> | ||
<RadioGroupItem className="mr-1" value="new" id="r2" /> | ||
<GitPullRequestArrow size={20} /> | ||
<p className="ml-2"> | ||
Create a new branch for this commit and start a pull request. | ||
</p> | ||
</div> | ||
</RadioGroup> | ||
</Card> | ||
<div className="flex gap-3 my-4"> | ||
<Button variant={"default"}>Commit changes</Button> | ||
<Button variant={"danger2"}>Cancel</Button> | ||
</div> | ||
</div> | ||
</Card> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Upload; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import Loader2 from "@/components/Loader2"; | ||
import { Card } from "@/components/ui/card"; | ||
|
||
const Loading = () => { | ||
return ( | ||
<div className="ml-4 h-full w-full border-slate-100"> | ||
<Card className="h-full"> | ||
<div className="px-2 h-full flex justify-center items-center"> | ||
<Loader2 size={30} /> | ||
</div> | ||
</Card> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Loading; |
Binary file not shown.
Oops, something went wrong.