Skip to content

Commit

Permalink
Merge pull request #13 from PoCInnovation/feat/repository_click_redir…
Browse files Browse the repository at this point in the history
…ection

feat(feat/respository_redirect): redirection on unique repo page from repo list
  • Loading branch information
eliestroun14 committed Aug 26, 2024
2 parents 853a834 + 5f8dff1 commit 596ac56
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/app/repository/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getSession } from "next-auth/react";
import "./page.css";
import { redirect } from "next/navigation";
import { SideBar } from "@/components/ui/side-bar";
import { useRouter } from "next/navigation"

interface Repository {
id: number;
Expand Down Expand Up @@ -60,6 +61,8 @@ const RepositoryPage: React.FC = () => {
const [organizations, setOrganizations] = useState<Organization[]>([]);
const [currentOrg, setCurrentOrg] = useState<Organization | null>(null);

const router = useRouter();

useEffect(() => {
const mode = localStorage.getItem("darkMode");
if (mode === "true") {
Expand Down Expand Up @@ -108,13 +111,6 @@ const RepositoryPage: React.FC = () => {
fetchRepositories().catch(console.error);
}, []);

useEffect(() => {
console.log("Repositories updated");
console.log("before");
console.log(repositories);
console.log("after");
}, [repositories]);

const toggleTheme = () => {
setTheme((prevTheme) => (prevTheme === "light" ? "dark" : "light"));
};
Expand All @@ -132,9 +128,11 @@ const RepositoryPage: React.FC = () => {
<>
<div className={`container ${theme}`}>
<h1 className="title">Your Repositories</h1>
{repositories.map((repo) => (
<div>
<ul className="repository-list">
{Array.isArray(repositories) && repositories.map((repo) => (
<li key={repo.id} className="repository-item">
<li key={repo.id} className="repository-item" onClick={() => router.replace('/repository/' + repo.owner.login + '/' + repo.name)}>
<div className="repo-details">
<h2>{repo.name}</h2>
<span>Language: {repo.language}</span>
Expand All @@ -146,6 +144,9 @@ const RepositoryPage: React.FC = () => {
</li>
))}
</ul>
</div>

))}
</div>
<SideBar organizations={organizations} currentOrg={currentOrg ?? { name: "Default Organization" }} />
</>
Expand Down

0 comments on commit 596ac56

Please sign in to comment.