refactors, dynamic constants (lol)

This commit is contained in:
mrfry 2023-03-29 19:12:41 +02:00
parent 755891710a
commit d4553896af
25 changed files with 323 additions and 312 deletions

View file

@ -2,7 +2,7 @@ import React from 'react'
import Questions from './Questions'
import constants from '../constants.json'
import constants from '../constants'
const countReducer = (acc, subj) => {
return acc + subj.Questions.length

View file

@ -1,6 +1,6 @@
import React, { useState, useEffect } from 'react'
import constants from '../constants.json'
import constants from '../constants'
const soundCount = 7
function GetRandom(min, max) {

View file

@ -3,7 +3,7 @@ import React, { useState } from 'react'
import Modal from './modal'
import styles from './composer.module.css'
import constants from '../constants.json'
import constants from '../constants'
export default function Composer({ onSubmit, allowFile, fileOnly }) {
const [editorShowing, setEditorShowing] = useState(false)

View file

@ -1,7 +1,7 @@
import React, { useState, useEffect } from 'react'
import Modal from './modal'
import constants from '../constants.json'
import constants from '../constants'
import styles from './dbSelector.module.css'

View file

@ -1,7 +1,7 @@
import React, { useState } from 'react'
import styles from './feedbackArea.module.css'
import constants from '../constants.json'
import constants from '../constants'
function FileUploader({ onChange }) {
return (

View file

@ -8,7 +8,7 @@ import Header from '../components/header'
import Modal from '../components/modal'
import styles from './forum.module.css'
import constants from '../constants.json'
import constants from '../constants'
const forumPostPerPage = 5

View file

@ -7,7 +7,7 @@ const Snowfall = dynamic(() => import('react-snowfall'), { ssr: false })
import LogoutIcon from './logoutIcon'
import Modal from './modal'
import constants from '../constants.json'
import constants from '../constants'
import BB from './b'
import styles from './layout.module.css'
@ -67,36 +67,35 @@ function TopBar({
unreads,
userId,
}) {
return <>
<MenuIcon setSidebarOpen={setSidebarOpen} sidebarOpen={sidebarOpen} />
<Link href="/">
return (
<>
<MenuIcon setSidebarOpen={setSidebarOpen} sidebarOpen={sidebarOpen} />
<Link href="/">
<img
src={`${constants.siteUrl}img/frylabs-logo_small_transparent.png`}
alt="FryLabs"
/>
</Link>
<div className={styles.topBarLinks}>
{Object.keys(topBarLinks).map((key) => {
const item = topBarLinks[key]
<img
src={`${constants.siteUrl}img/frylabs-logo_small_transparent.png`}
alt="FryLabs"
/>
</Link>
<div className={styles.topBarLinks}>
{Object.keys(topBarLinks).map((key) => {
const item = topBarLinks[key]
return (
(<Link
key={key}
href={item.href}
onClick={closeSideBar}
className={href.includes(key) ? styles.active : undefined}>
{item.text}
</Link>)
);
})}
</div>
<div className={'seperator'} />
<UserStatus onClick={closeSideBar} unreads={unreads} userId={userId} />
</>;
return (
<Link
key={key}
href={item.href}
onClick={closeSideBar}
className={href.includes(key) ? styles.active : undefined}
>
{item.text}
</Link>
)
})}
</div>
<div className={'seperator'} />
<UserStatus onClick={closeSideBar} unreads={unreads} userId={userId} />
</>
)
}
function SideBar({ sidebarOpen, closeSideBar, href, setDonateShowing }) {
@ -110,17 +109,16 @@ function SideBar({ sidebarOpen, closeSideBar, href, setDonateShowing }) {
}
return (
(<Link
<Link
href={item.href}
key={key}
onClick={closeSideBar}
className={href.includes(key) ? styles.active : undefined}
id={item.id || undefined}>
id={item.id || undefined}
>
{item.text}
</Link>)
);
</Link>
)
})}
<a
onClick={() => {
@ -132,7 +130,7 @@ function SideBar({ sidebarOpen, closeSideBar, href, setDonateShowing }) {
</a>
</div>
</>
) : null;
) : null
}
function Donate() {
@ -187,11 +185,10 @@ function UserStatus({ userId, unreads, onClick }) {
href="/chat"
onClick={onClick}
title={`Chat${unreadCount ? ' (' + unreadCount + ' új üzenet)' : ''}`}
className={styles.unreadNotification}>
className={styles.unreadNotification}
>
<span>💬</span>
{unreadCount ? <div>{unreadCount}</div> : null}
</Link>
<div
@ -215,7 +212,7 @@ function UserStatus({ userId, unreads, onClick }) {
<LogoutIcon size={28} />
</div>
</div>
);
)
}
function MenuIcon({ setSidebarOpen, sidebarOpen }) {

View file

@ -4,7 +4,7 @@ import ReactButton from './reactButton'
import Comments from './comments'
import Link from 'next/link'
import constants from '../constants.json'
import constants from '../constants'
import styles from './newsEntry.module.css'
@ -95,9 +95,9 @@ export default function NewsEntry({
<Link
href={`/chat?user=${user}`}
title={`Chat #${user}-el`}
className={'userId'}>
className={'userId'}
>
User #{user}
</Link>
<div className={styles.newsDate} title={dateObj.toLocaleString()}>
@
@ -145,5 +145,5 @@ export default function NewsEntry({
/>
</div>
</div>
);
)
}

View file

@ -1,5 +1,5 @@
import React from 'react'
import constants from '../constants.json'
import constants from '../constants'
export default function Sleep() {
const hours = new Date().getHours()