Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
kovipu committed Apr 14, 2024
2 parents 41fcd1e + ab330ea commit cde37e2
Show file tree
Hide file tree
Showing 40 changed files with 1,980 additions and 1,388 deletions.
21 changes: 20 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
{
"extends": ["next", "prettier"],
"plugins": ["simple-import-sort"],
"rules": {
"semi": 2
"semi": 2,
"simple-import-sort/imports": [
2,
{
"groups": [
[
"^\\u0000", // Side effect imports.
"^react.*",
"^next.*",
"^node:",
"^@?\\w" // Things that start with a letter (or digit or underscore), or `@` followed by a letter.
],
[
"^", // Absolute imports and other imports such as `@/foo`. Anything not matched in another group.
"^\\." // Anything that starts with a dot.
]
]
}
]
}
}
21 changes: 16 additions & 5 deletions archiver/archive.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
import { Show, Showlist, showsToGroups } from 'scripts/google/showlistHelpers';
import {
Show,
ShowsByDate,
showsToGroups,
} from '@/scripts/google/showlistHelpers';

const showlistBaseUrl = process.env.ARCHIVE_SOURCE_URL;
const emptyResponse = { showsByDate: [], weekKeys: {} } as const;
const emptyResponse = {} as const;

interface LegacyShowList {
showsByDate: ShowsByDate;
weekKeys: Record<string, string[]>;
}

/**
* Archive S3 bucket API
*/
export const fetchArchivedShowlist = async (showlistId: string) => {
export const fetchArchivedShowlist = async (
showlistId: string
): Promise<ShowsByDate> => {
if (!showlistBaseUrl) {
console.error('Arkiston polkua ei ole määritetty');
return emptyResponse;
Expand All @@ -15,13 +26,13 @@ export const fetchArchivedShowlist = async (showlistId: string) => {

try {
const response = await fetch(url);
const showlist: Show[] | Showlist = await response.json();
const showlist: Show[] | LegacyShowList = await response.json();

if (Array.isArray(showlist)) {
return showsToGroups(showlist);
}
if (showlist?.showsByDate) {
return showlist;
return showlist.showsByDate;
}
return emptyResponse;
} catch (error) {
Expand Down
6 changes: 3 additions & 3 deletions archiver/archiveCrawlers.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { parseSheetToShowList } from 'scripts/google/client';
import { GoogleConfigSheets, getSheet } from 'scripts/google/google';
import { mkdirSync } from 'node:fs';
import fs from 'node:fs/promises';
import path from 'node:path';
import { getImagePath } from 'utils/fileHelpers';

import { parseSheetToShowList } from '@/scripts/google/client';
import { getSheet, GoogleConfigSheets } from '@/scripts/google/google';

export const archiveOldShowlists = async () => {
// NOTE: Uncomment for archiving google sheet data
Expand Down
1 change: 1 addition & 0 deletions components/ShoutBox/messageformatter.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';

import NameFormatter from './nameformatter';

interface MessageFormatterProps {
Expand Down
1 change: 1 addition & 0 deletions components/ShoutBox/messageinput.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { ChangeEvent, Component, useEffect, useState } from 'react';
import { AiOutlineSend } from 'react-icons/ai';

import NameFormatter from './nameformatter';
import TextField from './textfield';

Expand Down
2 changes: 1 addition & 1 deletion components/ShoutBox/nameformatter.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { format } from 'date-fns';
import React from 'react';
import Image from 'next/image';
import { format } from 'date-fns';

interface NameFormatterProps {
name: string;
Expand Down
1 change: 1 addition & 0 deletions components/ShoutBox/nameinput.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { ChangeEvent, useState } from 'react';

import TextField from './textfield';

const isButtonDisabled = (name: string) => name === '';
Expand Down
6 changes: 3 additions & 3 deletions components/ShoutBox/shoutbox.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { useState, useEffect, useRef } from 'react';
import React, { useEffect, useRef, useState } from 'react';
import { GrFormClose } from 'react-icons/gr';

import useShoutBoxAndVideo from '../../hooks/useShoutboxAndVideo';
import MessageFormatter from './messageformatter';
import MessageInput from './messageinput';
import NameInput from './nameinput';
import MessageFormatter from './messageformatter';
import useShoutBoxAndVideo from '../../hooks/useShoutboxAndVideo';

const wsURL = process.env.NEXT_PUBLIC_SHOUTBOX_SOURCE || 'ws://localhost:3030';

Expand Down
2 changes: 1 addition & 1 deletion components/button.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Link from 'next/link';
import { FC, ReactNode } from 'react';
import Link from 'next/link';

const buttonStyle =
'bg-teal px-6 md:px-8 py-2 md:py-3 text-blue font-bold hover:bg-coral transition ease-in-out rounded';
Expand Down
4 changes: 2 additions & 2 deletions components/calendar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FC, useState, useEffect } from 'react';
import { startOfDay, format, parseISO, isSameDay } from 'date-fns';
import { FC, useEffect, useState } from 'react';
import { format, isSameDay, parseISO, startOfDay } from 'date-fns';
import fi from 'date-fns/locale/fi';

// Fetch next events but not more than 6 months from now
Expand Down
2 changes: 1 addition & 1 deletion components/controls.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FiPlay, FiPause, FiVolumeX, FiVolume2 } from 'react-icons/fi';
import { FiPause, FiPlay, FiVolume2, FiVolumeX } from 'react-icons/fi';

import VolumeSlider from './volumeSlider';

Expand Down
10 changes: 5 additions & 5 deletions components/footer.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import Image from 'next/image';
import Link from 'next/link';
import {
AiOutlineInstagram,
AiFillFacebook,
AiOutlineMail,
AiFillGithub,
AiOutlineInstagram,
AiOutlineMail,
} from 'react-icons/ai';
import { FaDiscord, FaTelegramPlane } from 'react-icons/fa';
import Image from 'next/image';
import Link from 'next/link';

import { NavigationItem } from 'contentful/client';
import { NavigationItem } from '@/contentful/client';

interface FooterProps {
navigationItems: NavigationItem[];
Expand Down
9 changes: 5 additions & 4 deletions components/hero.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { FC, useState } from 'react';
import Image from 'next/image';
import Link from 'next/link';
import { FC, useState } from 'react';

import { contentfulImageLoader } from 'contentful/contentfulImageLoader';
import { LinkButton } from './button';
import { NavigationItem } from 'contentful/client';
import { NavigationItem } from '@/contentful/client';
import { contentfulImageLoader } from '@/contentful/contentfulImageLoader';
import heroImage from '../public/hero.webp';
import { LinkButton } from './button';
import Hamburger from './hamburger/hamburger';
import Menu from './menu';

Expand Down Expand Up @@ -74,6 +74,7 @@ const Hero: FC<HeroProps> = ({
))}

<NavLink href="/arkisto" name="Arkisto" />
<NavLink href="/esittelyt" name="Esittelyt" />
</ul>
</header>

Expand Down
2 changes: 1 addition & 1 deletion components/menu.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Link from 'next/link';

import { NavigationItem } from 'contentful/client';
import { NavigationItem } from '@/contentful/client';

interface MenuProps {
navigationItems: NavigationItem[];
Expand Down
10 changes: 5 additions & 5 deletions components/player.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import Image from 'next/image';
import { useEffect, useState } from 'react';
import { FiMessageSquare, FiPause, FiPlay, FiVideo } from 'react-icons/fi';
import Image from 'next/image';
import { format } from 'date-fns';

import testcard from '../public/testcard.webp';
import useShoutBoxAndVideo from '@/hooks/useShoutboxAndVideo';
import { Show } from '@/scripts/google/showlistHelpers';
import placeholderImage from '../public/kuva_puuttuu_v2.jpeg';
import useShoutBoxAndVideo from 'hooks/useShoutboxAndVideo';
import { FiPause, FiPlay, FiMessageSquare, FiVideo } from 'react-icons/fi';
import { Show } from 'scripts/google/showlistHelpers';
import testcard from '../public/testcard.webp';

const SHOW_REFRESH_TIME = 10000; // 10 seconds

Expand Down
2 changes: 1 addition & 1 deletion components/playerControlPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import useMetadata from 'hooks/useMetadata';
import useMetadata from '@/hooks/useMetadata';
import Controls from './controls';

interface PlayerControlPanelProps {
Expand Down
8 changes: 4 additions & 4 deletions components/responsiveShowlist.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { format, parse } from 'date-fns';
import fi from 'date-fns/locale/fi';
import { Dispatch, SetStateAction, useState } from 'react';
import { BsArrowLeft, BsArrowRight } from 'react-icons/bs';
import { format, parse } from 'date-fns';
import fi from 'date-fns/locale/fi';

import { ShowCard } from 'components/showcard';
import { Show } from 'scripts/google/showlistHelpers';
import { ShowCard } from '@/components/showcard';
import { Show } from '@/scripts/google/showlistHelpers';

interface NavButton {
value: string | null;
Expand Down
4 changes: 2 additions & 2 deletions components/richtext.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { FC } from 'react';
import { MARKS, BLOCKS, INLINES } from '@contentful/rich-text-types';
import Image from 'next/image';
import {
documentToReactComponents,
Options,
} from '@contentful/rich-text-react-renderer';
import Image from 'next/image';
import { BLOCKS, INLINES, MARKS } from '@contentful/rich-text-types';

import { contentfulImageLoader } from '../contentful/contentfulImageLoader';
import { LinkButton } from './button';
Expand Down
6 changes: 3 additions & 3 deletions components/showcard.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { useState } from 'react';
import Image from 'next/image';
import { format } from 'date-fns';
import fi from 'date-fns/locale/fi';
import Image from 'next/image';
import { useState } from 'react';

import { Show } from '@/scripts/google/showlistHelpers';
import placeholderImage from '../public/kuva_puuttuu_v2.jpeg';
import { Show } from 'scripts/google/showlistHelpers';

interface ShowCard {
show: Show;
Expand Down
32 changes: 9 additions & 23 deletions components/showlist.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
import { useState } from 'react';

import { Show } from 'scripts/google/showlistHelpers';
import { useViewport } from '@/hooks/useViewport';
import { Show, ShowsByDate } from '@/scripts/google/showlistHelpers';
import { ModeButton } from './button';
import ResponsiveShowlist from './responsiveShowlist';
import ShowlistMap from './showlistMap';
import { ModeButton } from './button';
import { useViewport } from 'hooks/useViewport';

interface ShowlistProps {
showsByDate: {
[key: string]: Show[];
};
weekKeys: Record<string, string[]>;
showsByDate: ShowsByDate;
}

export const Showlist = ({ showsByDate, weekKeys }: ShowlistProps) => {
export const Showlist = ({ showsByDate }: ShowlistProps) => {
const [mode, setMode] = useState<'list' | 'map'>('list');

const { isDesktop } = useViewport();
Expand All @@ -39,28 +36,17 @@ export const Showlist = ({ showsByDate, weekKeys }: ShowlistProps) => {
</div>
)}
</div>
<ShowlistSelector
showsByDate={showsByDate}
weekKeys={weekKeys}
mode={mode}
/>
<ShowlistSelector showsByDate={showsByDate} mode={mode} />
</div>
);
};

interface ShowlistSelectorProps {
showsByDate: {
[key: string]: Show[];
};
weekKeys: Record<string, string[]>;
showsByDate: ShowsByDate;
mode: 'list' | 'map';
}

const ShowlistSelector = ({
showsByDate,
weekKeys,
mode,
}: ShowlistSelectorProps) => {
const ShowlistSelector = ({ showsByDate, mode }: ShowlistSelectorProps) => {
const { isDesktop } = useViewport();

if (!isDesktop) {
Expand All @@ -71,7 +57,7 @@ const ShowlistSelector = ({
case 'list':
return <ResponsiveShowlist showsByDate={showsByDate} />;
case 'map':
return <ShowlistMap showsByDate={showsByDate} weekKeys={weekKeys} />;
return <ShowlistMap showsByDate={showsByDate} />;
}
};

Expand Down
Loading

0 comments on commit cde37e2

Please sign in to comment.