Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes #352

Merged
merged 2 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"start": "2023-11-15T00:00:00.000Z",
"end": "2023-11-16T00:00:00.000Z",
"location": "Istanbul, Türkiye",
"organizationId": "0xparc",
"organizationId": "oxparc",
"dataImporter": [
{
"type": "gsheet",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"start": "2023-11-16T00:00:00.000Z",
"end": "2023-11-17T00:00:00.000Z",
"location": "Istanbul, Türkiye",
"organizationId": "0xparc",
"organizationId": "oxparc",
"dataImporter": [
{
"type": "gsheet",
Expand Down
2 changes: 1 addition & 1 deletion data/organizations/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Base",
"description": "Base ",
"url": "https://test.com",
"logo": "https://test.com",
"logo": "https://streamethapp.ams3.cdn.digitaloceanspaces.com/events/base_logo.png",
"location": "Londo ",
"accentColor": "#FFF"
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"id": "0xparc",
"id": "oxparc",
"name": "0xParc",
"description": "Supporting the next generation of cryptography-enabled applications.",
"url": "https://0xparc.org",
"logo": "https://0xparc.org/logo_with_text.fd13ff62.svg",
"location": "metaverse"
"location": "metaverse and beyond"
}
2 changes: 1 addition & 1 deletion packages/app/app/(home)/components/HeroHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const HeroHeader = () => {
<Link href="https://info.streameth.org/contact-us">
<Button>Host your event</Button>
</Link>
<Link href="https://info.streameth.org/contact-us">
<Link href="https://info.streameth.org/services">
<Button variant="secondary">Learn More</Button>
</Link>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export default async function OrganizationStrip({
limit: 4,
})
).sessions

if (videos.length === 0) return false
return (
<div key="organization.id" className="bg-white flex flex-col">
Expand Down
4 changes: 3 additions & 1 deletion packages/app/app/(home)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import UpcomingEvents from './components/UpcomingEvents'
import Videos from '../../components/misc/Videos'
import { Suspense } from 'react'
import { fetchOrganizations } from '@/lib/data'
import OrganizationStrip from './components/OrganiationStrip'
import OrganizationStrip from './components/OrganizationStrip'
import {
CardDescription,
CardTitle,
Expand All @@ -18,6 +18,8 @@ const Loading = () => {
return <Skeleton className=" h-96 w-full bg-muted" />
}

export const revalidate = 3600 // 1 day

export default async function Home() {
const organizations = await fetchOrganizations()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default async function Stage({ params }: EventPageProps) {
}

return (
<div className="p-2 h-full flex flex-col w-full lg:flex-row relative lg:max-h-[calc(100vh-54px)]">
<div className="bg-accent p-2 h-full flex flex-col w-full lg:flex-row relative lg:max-h-[calc(100vh-54px)]">
<div className="flex flex-col w-full h-full z-40 lg:w-[70%] top-[54px] lg:p-4 lg:pr-2">
<Player
streamId={stage.streamSettings.streamId}
Expand Down
52 changes: 19 additions & 33 deletions packages/app/app/[organization]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Image from 'next/image'
import remarkGfm from 'remark-gfm'
import { notFound } from 'next/navigation'
import EventController from 'streameth-server/controller/event'
import OrganizationController from 'streameth-server/controller/organization'
import Markdown from 'react-markdown'
import { Metadata, ResolvingMetadata } from 'next'
import { fetchOrganization } from '@/lib/data'

interface Params {
params: {
Expand All @@ -17,34 +17,13 @@ export default async function OrganizationHome({ params }: Params) {
return notFound()
}

const events =
await new EventController().getAllEventsForOrganization(
params.organization
)
const organization = await fetchOrganization({
organization: params.organization,
})

const pastEvents = events
.filter((event) => {
const endDate = new Date(event?.end)
endDate.setUTCHours(0, 0, 0, 0)
return endDate.getTime() < new Date().getTime()
})
.map((event) => event.toJson())
const upComing = events
.filter((event) => {
const startDate = new Date(event?.end)
startDate.setUTCHours(0, 0, 0, 0)
return startDate.getTime() > new Date().getTime()
})
.map((event) => event.toJson())
.sort(
(a, b) =>
new Date(a.start).getTime() - new Date(b.start).getTime()
)

const organization =
await new OrganizationController().getOrganization(
params.organization
)
if (!organization) {
return notFound()
}

return (
<main className="w-screen mx-auto fixed overflow-auto h-screen">
Expand Down Expand Up @@ -81,13 +60,13 @@ export default async function OrganizationHome({ params }: Params) {
<hr className="h-px mx-9 bg-base" />
<div className="overflow-auto h-screen">
<div className="px-4">
{upComing.length > 0 && (
{/* {upComing.length > 0 && (
<>
<p className="px-4 mt-3 font-ubuntu font-bold lg:py-2 text-blue text-2xl lg:text-4xl">
Upcoming Events
</p>
</>
)}
)} */}
</div>
</div>
</main>
Expand All @@ -98,9 +77,16 @@ export async function generateMetadata(
{ params }: Params,
parent: ResolvingMetadata
): Promise<Metadata> {
const organizationController = new OrganizationController()
const organizationInfo =
await organizationController.getOrganization(params.organization)
const organizationInfo = await fetchOrganization({
organization: params.organization,
})

if (!organizationInfo) {
return {
title: 'Organization not found',
description: 'Organization not found',
}
}

const imageUrl = organizationInfo.logo
try {
Expand Down
17 changes: 17 additions & 0 deletions packages/app/app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Link from 'next/link'

export default function NotFound() {
return (
<div className="bg-gray-100 text-gray-800 flex flex-col items-center justify-center h-screen">
<h2 className="text-4xl font-bold mb-4">404: Not Found</h2>
<p className="text-lg mb-6">
Could not find the requested resource.
</p>
<Link href="/">
<p className="px-6 py-3 bg-blue-500 text-white rounded-full hover:bg-blue-700 transition-colors">
Return Home
</p>
</Link>
</div>
)
}
7 changes: 3 additions & 4 deletions packages/app/components/Layout/HomePageNavbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,13 @@ const HomePageNavbar = () => {

const pages = [
{
name: 'Videography services',
name: 'Videography',
href: 'https://info.streameth.org/stream-eth-studio',
bgColor: 'bg-muted text-background',
},

{
name: 'Case studies',
href: '/pricing',
name: 'Product',
href: 'https://info.streameth.org/services',
bgColor: 'bg-muted text-background',
},
{
Expand Down
2 changes: 1 addition & 1 deletion packages/app/components/sessions/SessionInfoBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const SessionInfoBox = ({
</div>
</div>
<CardContent className="bg-background rounded-md p-4">
{description && (
{description !== '' && (
<div
className={`transition-max-height duration-700 ease-in-out overflow-hidden ${
isOpened ? 'max-h-96' : 'max-h-10'
Expand Down
23 changes: 22 additions & 1 deletion packages/app/lib/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,27 @@ import SpeakerController from 'streameth-server/controller/speaker'
import OrganizationController from 'streameth-server/controller/organization'
import { NavBarProps, IPagination } from './types'
import FuzzySearch from 'fuzzy-search';
import { unstable_noStore as noStore } from 'next/cache';


export async function fetchOrganization ({
organization
}: {
organization: string
}): Promise<IOrganization | null > {
try {
const organizationController = new OrganizationController()
const data = await organizationController.getOrganization(organization)
if (!data) {
throw 'Organization not found'
}
return data.toJson()
} catch (e) {
console.log(e)
return null
}
}

export async function fetchOrganizations(): Promise<IOrganization[]> {
try {
const organizationController = new OrganizationController()
Expand Down Expand Up @@ -43,7 +64,7 @@ export async function fetchEvents({
return data.map((event) => event.toJson())
} catch (e) {
console.log(e)
throw 'Error fetching events'
throw 'Error fetching events' + e
}
}

Expand Down
15 changes: 15 additions & 0 deletions packages/app/middleware.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { NextRequest, NextResponse } from 'next/server';

export function middleware(request: NextRequest) {
const { pathname, origin } = new URL(request.url);
const pathRegex = /^\/([^/]+)\/([^/]+)\/archive$/;
const match = pathname.match(pathRegex);

if (match) {
const baseEvent = match[2];
const newUrl = `${origin}/archive?event=${encodeURIComponent(baseEvent)}`;
return NextResponse.redirect(newUrl);
}

return NextResponse.next();
}
11 changes: 11 additions & 0 deletions packages/app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Link from 'next/link'

export default function NotFound() {
return (
<div>
<h2>Not Found</h2>
<p>Could not find requested resource</p>
<Link href="/">Return Home</Link>
</div>
)
}
3 changes: 2 additions & 1 deletion packages/server/model/organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ export default class Organization {
accentColor: string

constructor({
id,
name,
description,
url,
logo,
location,
accentColor = '#FFF',
}: Omit<IOrganization, 'id'> & { id?: string }) {
this.id = generateId(name)
this.id = id ?? generateId(name)
this.name = name
this.description = description
this.url = url
Expand Down