Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Feat: admin page (history) #78

Merged
merged 20 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: history -> activity
  • Loading branch information
hetd54 committed Aug 5, 2024
commit 4219253f511c6e0921b959e1c017198efd225b2c
20 changes: 10 additions & 10 deletions src/components/HistoryPage.tsx → src/components/ActivityPage.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { useEffect, useState } from "react"
import type { UserInfo } from "firebase/auth"
import Login from "../components/Login"
import HistoryTable from "../components/HistoryTable"
import { getHistoryData } from "../firebase"
import ActivityTable from "./ActivityTable.tsx"

const HistoryPage = () => {
const ActivityPage = () => {
const [user, setUser] = useState<UserInfo | null | undefined>(null)
const [historyData, setHistoryData] = useState<any[] | null>(null)
const setUserFunction = (loggedUser: UserInfo | null | undefined) => {
Expand All @@ -25,24 +25,24 @@ const HistoryPage = () => {

return (
<div className="space-y-8">
<section>
<div className="flex justify-end">
<Login currentUser={user} setUserFunction={setUserFunction} />
</div>
<section className="space-y-6">
<Login currentUser={user} setUserFunction={setUserFunction} />
{!user && (
<p>
This section of the website is reserved for administrators to view download statistics.
</p>
)}
</section>
{historyData && (
{user && historyData && (
<section className="space-y-2">
<p>Number of downloads: {historyData.length}</p>
<HistoryTable data={historyData} />
<h3>
<span className="font-bold px-2">{historyData.length}</span> download(s)
</h3>
<ActivityTable data={historyData} />
</section>
)}
</div>
)
}

export default HistoryPage
export default ActivityPage
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react"
import { type Timestamp } from "firebase/firestore"

export interface HistoryTableProps {
export interface ActivityTableProps {
data: Array<{
name: string
institution: string
Expand All @@ -11,10 +11,10 @@ export interface HistoryTableProps {
}>
}

const HistoryTable: React.FC<HistoryTableProps> = ({ data }) => {
const ActivityTable: React.FC<ActivityTableProps> = ({ data }) => {
return (
<div className="w-full overflow-x-scroll no-scrollbar">
<table className="table-fixed border-spacing-2">
<table className="table-fixed border-spacing-2 w-full">
<thead>
<tr className="bg-neutral-100 text-left text-neutral-900">
<th>Name</th>
Expand Down Expand Up @@ -44,4 +44,4 @@ const HistoryTable: React.FC<HistoryTableProps> = ({ data }) => {
</div>
)
}
export default HistoryTable
export default ActivityTable
2 changes: 1 addition & 1 deletion src/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ export const LINKS = [
"study-design",
"data",
"documentation",
"history",
"activity",
]
4 changes: 2 additions & 2 deletions src/pages/history.astro → src/pages/activity.astro
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
import Layout from "../layouts/Layout.astro"
import HistoryPage from "../components/HistoryPage"
import ActivityPage from "../components/ActivityPage"
---

<Layout title="Admin" description="History Table of Downloads">
<HistoryPage client:only="react" />
<ActivityPage client:only="react" />
</Layout>