Skip to content

Commit

Permalink
Merge pull request #41 from langaracpsc/notion-as-a-backend
Browse files Browse the repository at this point in the history
use notion as a backend
  • Loading branch information
rishit-singh authored Apr 19, 2024
2 parents 9fdde80 + b041d19 commit cc8c737
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
7 changes: 6 additions & 1 deletion frontend/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ const nextConfig = {
{
protocol: "https",
hostname: "via.placeholder.com"
}
},
{
protocol: "https",
hostname: "api3.langaracs.tech",
pathname: "/executives/image/**"
},
]
}
}
Expand Down
7 changes: 4 additions & 3 deletions frontend/src/app/ExecProfiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { selectProfile, ExecProfileObject } from './slices/execProfileSlice';
export default function ExecProfiles() {
const profiles = useAppSelector(selectProfile);

const profilesSorted = [...profiles].sort((a, b) => (a.Position.ID - b.Position.ID)).slice(0, 12);
// TODO: don't hardcode the value of 1000
const profilesSorted = [...profiles].sort((a, b) => (a.Position.ID - b.Position.ID)).slice(0, 1000);

const [profileSections, setProfileSections] = useState<ExecProfileObject[][]>([]);

Expand Down Expand Up @@ -68,15 +69,15 @@ export default function ExecProfiles() {
<div className="flex flex-col gap-5">
{
profileSections.map(profiles => (
<div className={"flex flex-row gap-32 max-[800px]:gap-10"} key={profileSections.indexOf(profiles)}>
<div className={"flex flex-row gap-32 max-[800px]:gap-10 justify-around"} key={profileSections.indexOf(profiles)}>
{
profiles.map(profile => (
<ExecProfile
key={profile.ID}
Position={profile.Position.Title}
ID={profile.ID}
Name={profile.Name}
ImageBuffer={`https://${process.env.APIURL}/${profile.ImageBuffer}`}
ImageBuffer= {(profile.ImageBuffer != null) ? `https://api3.langaracs.tech/executives/image/${profile.ImageBuffer}` : "https://via.placeholder.com/200x200"}
Description={profile.Description} />
))
}
Expand Down
16 changes: 9 additions & 7 deletions frontend/src/app/thunks/ProfileThunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@ import { AppDispatch, RootState } from "../stores/store";
import { ExecProfileObject } from "../slices/execProfileSlice";

export const loadProfilesAsync = () => async (state: RootState, dispatch: AppDispatch): Promise<ExecProfileObject[]> => {
const response = (await (await fetch(`https://${process.env.APIURL}/Exec/Profile/Active?image=true&complete=true`, {
const response = (await (await fetch(`https://api3.langaracs.tech/executives/active`, {
method: "GET",
headers: {
"apikey": `${process.env.APIKEY}`
}
})).json())["Payload"];
})).json());

// console.log(response)

return response.map((element: any) => {
const execProfile: ExecProfileObject = {
ID: element.ID,
Name: `${element.Name.FirstName} ${element.Name.LastName}`,
ImageBuffer: element.Image,
Position: element.Position,
Description: element.Description
ID: element.student_id,
Name: element.name,
ImageBuffer: element.profile_picture,
Position: element.roles,
Description: element.bio
};

return execProfile;
Expand Down

0 comments on commit cc8c737

Please sign in to comment.