-
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 #55 from SwiichyCode/resource
feat: implement add ressource modal / form
- Loading branch information
Showing
23 changed files
with
262 additions
and
45 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 { RepositoryCardSkeleton } from "@/modules/repositories/components/RepositoryCard/RepositoryCardSkeleton"; | ||
|
||
export default function loading() { | ||
return ( | ||
<div className="grid grid-cols-1 gap-4 p-8 md:grid-cols-3 lg:grid-cols-4"> | ||
{Array.from({ length: 15 }).map((_, index) => ( | ||
<RepositoryCardSkeleton key={index} /> | ||
))} | ||
</div> | ||
); | ||
} |
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,9 @@ | ||
import { AddResourceForm } from "@/modules/resources/components/_forms/add-resource-form"; | ||
|
||
export default async function ResourcesPage() { | ||
return ( | ||
<> | ||
<AddResourceForm /> | ||
</> | ||
); | ||
} |
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,51 @@ | ||
"use client"; | ||
import { usePathname } from "next/navigation"; | ||
import { signIn } from "next-auth/react"; | ||
import { Button } from "@/components/ui/button"; | ||
import { useShareRepositoryModal } from "@/modules/repositories/stores/useShareRepositoryModal"; | ||
import { useShareResourceModal } from "@/modules/resources/stores/useShareResourcesModal"; | ||
import { RepoIcon, FileDirectoryIcon } from "@primer/octicons-react"; | ||
import { URL } from "@/config/constants"; | ||
import type { Session } from "next-auth"; | ||
|
||
type Props = { | ||
session: Session | null; | ||
}; | ||
|
||
export const SharingBtn = ({ session }: Props) => { | ||
const { setOpen: setOpenShareRepositoryModal } = useShareRepositoryModal(); | ||
const { setOpen: setOpenShareResourceModal } = useShareResourceModal(); | ||
const pathname = usePathname(); | ||
|
||
const pageActions = { | ||
[URL.REPOSITORIES]: { | ||
action: setOpenShareRepositoryModal, | ||
label: "Share Repository", | ||
icon: RepoIcon, | ||
}, | ||
[URL.RESOURCES]: { | ||
action: setOpenShareResourceModal, | ||
label: "Share Resource", | ||
icon: FileDirectoryIcon, | ||
}, | ||
}; | ||
|
||
const currentPageAction = pageActions[pathname]; | ||
|
||
if (!currentPageAction) return null; | ||
|
||
const handleOpen = async () => { | ||
if (session) { | ||
currentPageAction.action(true); | ||
} else { | ||
await signIn("github"); | ||
} | ||
}; | ||
|
||
return ( | ||
<Button variant={"success"} onClick={handleOpen} className="space-x-2"> | ||
<currentPageAction.icon className="h-5 w-5" /> | ||
<span className="hidden lg:block">{currentPageAction.label}</span> | ||
</Button> | ||
); | ||
}; |
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,59 @@ | ||
"use client"; | ||
import { | ||
FormControl, | ||
FormField, | ||
FormItem, | ||
FormLabel, | ||
FormMessage, | ||
} from "@/components/ui/form"; | ||
import { | ||
Select, | ||
SelectTrigger, | ||
SelectValue, | ||
SelectContent, | ||
SelectItem, | ||
} from "@/components/ui/select"; | ||
|
||
interface SelectProps extends React.ComponentPropsWithoutRef<"select"> { | ||
control: any; | ||
name: string; | ||
placeholder: string; | ||
items: string[]; | ||
label: string; | ||
} | ||
|
||
export function SelectForm({ | ||
control, | ||
name, | ||
placeholder, | ||
label, | ||
...props | ||
}: SelectProps) { | ||
return ( | ||
<FormField | ||
control={control} | ||
name={name} | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel>{label}</FormLabel> | ||
<Select onValueChange={field.onChange} defaultValue={field.value}> | ||
<FormControl> | ||
<SelectTrigger> | ||
<SelectValue placeholder={placeholder} /> | ||
</SelectTrigger> | ||
</FormControl> | ||
<SelectContent> | ||
{props.items.map((item, index) => ( | ||
<SelectItem key={index} value={item}> | ||
{item} | ||
</SelectItem> | ||
))} | ||
</SelectContent> | ||
</Select> | ||
|
||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
); | ||
} |
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 |
---|---|---|
@@ -1,3 +1,16 @@ | ||
export { default } from "next-auth/middleware"; | ||
import { withAuth } from "next-auth/middleware"; | ||
import { env } from "@/config/env"; | ||
|
||
export default withAuth({ | ||
callbacks: { | ||
authorized: ({ req }) => { | ||
const sessionToken = req.cookies.get(env.SESSION_TOKEN_NAME); | ||
if (!sessionToken) return false; | ||
|
||
return true; | ||
}, | ||
}, | ||
secret: env.NEXTAUTH_SECRET, | ||
}); | ||
|
||
export const config = { matcher: ["/profile", "/settings"] }; |
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
30 changes: 0 additions & 30 deletions
30
src/modules/repositories/components/RepositoryShareBtn.tsx
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.