-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
237 additions
and
52 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { NextResponse } from "next/server"; | ||
const base_url = process.env.BASE_URL; | ||
const token = process.env.ACCESS_TOKEN | ||
|
||
export async function GET(req: any) { | ||
const endpoint = `${base_url}/api/issues/`; | ||
|
||
try { | ||
|
||
const response = await fetch(endpoint, { | ||
method: "GET", | ||
headers: { | ||
"Content-Type": "application/json", | ||
"Authorization": `Bearer ${token}`} | ||
}) | ||
|
||
if (response.ok) { | ||
const res = await response.json(); | ||
return NextResponse.json({ | ||
data: res, | ||
}); | ||
} else { | ||
const error = await response.json(); | ||
|
||
return NextResponse.json( | ||
{ | ||
error, | ||
}, | ||
{ | ||
status: response.status, | ||
}, | ||
); | ||
} | ||
} catch (error: any) { | ||
return NextResponse.json( | ||
{ | ||
message: "Failed to connect to the server.", | ||
error: error.message, | ||
}, | ||
{ | ||
status: 500, | ||
}, | ||
); | ||
} | ||
} |
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 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
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,83 @@ | ||
import { issuesData } from "@/app/types"; | ||
import Link from "next/link"; | ||
import { useRouter } from "next/navigation"; | ||
import React, { useEffect, useState } from "react"; | ||
|
||
function Issues() { | ||
const [issues, setIssues] = useState<[]>(); | ||
const [error, setError] = useState(""); | ||
const [success, setSuccess] = useState(""); | ||
|
||
const router = useRouter(); | ||
|
||
const handleGetIssues = async () => { | ||
const res = await fetch("/api/issues", { | ||
method: "GET", | ||
}); | ||
|
||
const data = await res.json(); | ||
console.log("data from issues", data); | ||
setIssues(data.data); | ||
}; | ||
|
||
useEffect(() => { | ||
handleGetIssues(); | ||
}, []); | ||
|
||
return ( | ||
<div className="pt-[60px] lg:pt-[75px] px-2"> | ||
<div className="hidden lg:flex items-center gap-2 pt-4"> | ||
<button className="border-2 border-[#01C909] rounded-xl py-1 px-2 text-center"> | ||
<Link href="#">Vote Now</Link> | ||
</button> | ||
<button className="border-2 border-[#01C909] rounded-xl py-1 px-2 text-center"> | ||
<Link href="#">View new laws</Link> | ||
</button> | ||
<button className="border-2 border-[#01C909] rounded-xl py-1 px-2 text-center"> | ||
<Link href="#">Explore discussions</Link> | ||
</button> | ||
</div> | ||
|
||
{issues && | ||
issues.map((issue: issuesData) => { | ||
return ( | ||
<div key={issue.id} className="bg-[#f8f9fb] rounded-xl p-2 "> | ||
<p className="p-2 text-[18px] text-semibold">Parliament</p> | ||
|
||
<div className="bg-white rounded-xl p-2"> | ||
<p className="text-[16px] text-semibold"> | ||
{issue.serial}:{issue.title} | ||
</p> | ||
<p className="text-[#a7a7ae] text-[14px]">{issue.content}</p> | ||
<p className="text-[#a7a7ae] text-[14px]">......</p> | ||
|
||
<p className="text-[#a7a7ae] text-[14px]"> | ||
Status:{" "} | ||
<span className="text-bold text-[#000000]"> | ||
{issue.status} | ||
</span> | ||
</p> | ||
<p className="text-[#a7a7ae] text-[14px]"> | ||
Deadline for voting:{" "} | ||
<span className="text-bold text-[#000000]"> | ||
{issue.deadline} | ||
</span> | ||
</p> | ||
|
||
<div className="flex items-center gap-2"> | ||
<button className="border-2 border-[#01C909] rounded-xl py-1 px-2 text-center"> | ||
<Link href="#">Read more</Link> | ||
</button> | ||
<button className="border-2 border-[#01C909] bg-[#01C909] rounded-xl py-1 px-2 text-center"> | ||
<Link href="#">Vote Now</Link> | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
); | ||
} | ||
|
||
export default Issues; |
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,46 @@ | ||
import { useRouter } from 'next/navigation'; | ||
import React, { useState } from 'react' | ||
|
||
function Law() { | ||
|
||
const [issues, setIssues] = useState(""); | ||
|
||
const [error, setError] = useState(""); | ||
const [success, setSuccess] = useState(""); | ||
|
||
const router = useRouter(); | ||
|
||
const handleGetIssues = async () => { | ||
|
||
const res = await fetch("/api/issues", { | ||
method: "GET", | ||
// headers: { | ||
// "Content-Type": "application/json", | ||
// }, | ||
}); | ||
|
||
const data = await res.json(); | ||
console.log("data from issues", data); | ||
|
||
if (res.ok) { | ||
setSuccess("issues successful!"); | ||
setError(""); | ||
// router.push("/dashboard"); | ||
} else { | ||
setError(data.message); | ||
setSuccess(""); | ||
} | ||
}; | ||
|
||
|
||
|
||
return ( | ||
<div> | ||
<p>Bonga is a unique and exciting platform designed to empower you to speak up and make a real impact on the issues that matter most to you. The name {'"'}Bonga{'"'} comes from the Swahili word meaning {'"'}speak up,{'"'} and that{"'"}s exactly what we want you to do here!</p> | ||
<p>Whether it{"’"}s about new laws being debated, how public funds are being used, or any other issue affecting your community, Bonga gives you the tools to have your voice heard and make a difference.</p> | ||
<p>Law</p> | ||
</div> | ||
) | ||
} | ||
|
||
export default Law |
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,7 +1,20 @@ | ||
export interface userData { | ||
data:{ | ||
email: string; | ||
id: string; | ||
id_number: string; | ||
} | ||
} | ||
data: { | ||
email: string; | ||
id: string; | ||
id_number: string; | ||
}; | ||
} | ||
|
||
export interface issuesData { | ||
|
||
author: string; | ||
content: string; | ||
created_at: string; | ||
deadline: string; | ||
id: string; | ||
serial: string; | ||
status: string; | ||
title: string; | ||
|
||
} |