Removed troublesome Immutable type
This commit is contained in:
parent
24a8b43701
commit
6ae54c39d4
|
@ -190,10 +190,10 @@ module.exports = {
|
||||||
"@typescript-eslint/promise-function-async": "error",
|
"@typescript-eslint/promise-function-async": "error",
|
||||||
"@typescript-eslint/require-array-sort-compare": "error",
|
"@typescript-eslint/require-array-sort-compare": "error",
|
||||||
"@typescript-eslint/sort-type-union-intersection-members": "warn",
|
"@typescript-eslint/sort-type-union-intersection-members": "warn",
|
||||||
"@typescript-eslint/strict-boolean-expressions": [
|
// "@typescript-eslint/strict-boolean-expressions": [
|
||||||
"error",
|
// "error",
|
||||||
{ allowAny: true },
|
// { allowAny: true },
|
||||||
],
|
// ],
|
||||||
"@typescript-eslint/switch-exhaustiveness-check": "error",
|
"@typescript-eslint/switch-exhaustiveness-check": "error",
|
||||||
"@typescript-eslint/typedef": "error",
|
"@typescript-eslint/typedef": "error",
|
||||||
"@typescript-eslint/unified-signatures": "error",
|
"@typescript-eslint/unified-signatures": "error",
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { prettyLanguage, prettySlug } from "helpers/formatters";
|
||||||
import { getOgImage, ImageQuality } from "helpers/img";
|
import { getOgImage, ImageQuality } from "helpers/img";
|
||||||
import { isDefined, isDefinedAndNotEmpty } from "helpers/others";
|
import { isDefined, isDefinedAndNotEmpty } from "helpers/others";
|
||||||
// import { getClient, Indexes, search, SearchResult } from "helpers/search";
|
// import { getClient, Indexes, search, SearchResult } from "helpers/search";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { useMediaMobile } from "hooks/useMediaQuery";
|
import { useMediaMobile } from "hooks/useMediaQuery";
|
||||||
import { AnchorIds } from "hooks/useScrollTopOnChange";
|
import { AnchorIds } from "hooks/useScrollTopOnChange";
|
||||||
import Head from "next/head";
|
import Head from "next/head";
|
||||||
|
@ -35,7 +35,7 @@ interface Props extends AppStaticProps {
|
||||||
const SENSIBILITY_SWIPE = 1.1;
|
const SENSIBILITY_SWIPE = 1.1;
|
||||||
const TITLE_PREFIX = "Accord’s Library";
|
const TITLE_PREFIX = "Accord’s Library";
|
||||||
|
|
||||||
export function AppLayout(props: Immutable<Props>): JSX.Element {
|
export function AppLayout(props: Props): JSX.Element {
|
||||||
const {
|
const {
|
||||||
langui,
|
langui,
|
||||||
currencies,
|
currencies,
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
import { cJoin } from "helpers/className";
|
import { cJoin } from "helpers/className";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
className?: string;
|
className?: string;
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Chip(props: Immutable<Props>): JSX.Element {
|
export function Chip(props: Props): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={cJoin(
|
className={cJoin(
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
import { cJoin } from "helpers/className";
|
import { cJoin } from "helpers/className";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
className?: string;
|
className?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function HorizontalLine(props: Immutable<Props>): JSX.Element {
|
export function HorizontalLine(props: Props): JSX.Element {
|
||||||
const { className } = props;
|
const { className } = props;
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { cJoin } from "helpers/className";
|
import { cJoin } from "helpers/className";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { MouseEventHandler } from "react";
|
import { MouseEventHandler } from "react";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
@ -8,7 +8,7 @@ interface Props {
|
||||||
icon: Icon;
|
icon: Icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Ico(props: Immutable<Props>): JSX.Element {
|
export function Ico(props: Props): JSX.Element {
|
||||||
const { onClick, icon, className } = props;
|
const { onClick, icon, className } = props;
|
||||||
return (
|
return (
|
||||||
<span
|
<span
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { UploadImageFragment } from "graphql/generated";
|
import { UploadImageFragment } from "graphql/generated";
|
||||||
import { getAssetURL, getImgSizesByQuality, ImageQuality } from "helpers/img";
|
import { getAssetURL, getImgSizesByQuality, ImageQuality } from "helpers/img";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { ImageProps } from "next/image";
|
import { ImageProps } from "next/image";
|
||||||
import { MouseEventHandler } from "react";
|
import { MouseEventHandler } from "react";
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ interface Props {
|
||||||
onClick?: MouseEventHandler<HTMLImageElement>;
|
onClick?: MouseEventHandler<HTMLImageElement>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Img(props: Immutable<Props>): JSX.Element {
|
export function Img(props: Props): JSX.Element {
|
||||||
const {
|
const {
|
||||||
className,
|
className,
|
||||||
image,
|
image,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Ico, Icon } from "components/Ico";
|
import { Ico, Icon } from "components/Ico";
|
||||||
import { cIf, cJoin } from "helpers/className";
|
import { cIf, cJoin } from "helpers/className";
|
||||||
import { ConditionalWrapper, Wrapper } from "helpers/component";
|
import { ConditionalWrapper, Wrapper } from "helpers/component";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { isDefined, isDefinedAndNotEmpty } from "helpers/others";
|
import { isDefined, isDefinedAndNotEmpty } from "helpers/others";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import React, { MouseEventHandler } from "react";
|
import React, { MouseEventHandler } from "react";
|
||||||
|
@ -20,7 +20,7 @@ interface Props {
|
||||||
badgeNumber?: number;
|
badgeNumber?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Button(props: Immutable<Props>): JSX.Element {
|
export function Button(props: Props): JSX.Element {
|
||||||
const {
|
const {
|
||||||
draggable,
|
draggable,
|
||||||
id,
|
id,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { cJoin } from "helpers/className";
|
import { cJoin } from "helpers/className";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { useLayoutEffect, useRef } from "react";
|
import { useLayoutEffect, useRef } from "react";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
@ -7,7 +7,7 @@ interface Props {
|
||||||
className?: string;
|
className?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ButtonGroup(props: Immutable<Props>): JSX.Element {
|
export function ButtonGroup(props: Props): JSX.Element {
|
||||||
const { children, className } = props;
|
const { children, className } = props;
|
||||||
const ref = useRef<HTMLDivElement>(null);
|
const ref = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { Icon } from "components/Ico";
|
||||||
import { AppStaticProps } from "graphql/getAppStaticProps";
|
import { AppStaticProps } from "graphql/getAppStaticProps";
|
||||||
import { cJoin } from "helpers/className";
|
import { cJoin } from "helpers/className";
|
||||||
import { prettyLanguage } from "helpers/formatters";
|
import { prettyLanguage } from "helpers/formatters";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { Fragment } from "react";
|
import { Fragment } from "react";
|
||||||
import { ToolTip } from "../ToolTip";
|
import { ToolTip } from "../ToolTip";
|
||||||
import { Button } from "./Button";
|
import { Button } from "./Button";
|
||||||
|
@ -15,7 +15,7 @@ interface Props {
|
||||||
onLanguageChanged: (index: number) => void;
|
onLanguageChanged: (index: number) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function LanguageSwitcher(props: Immutable<Props>): JSX.Element {
|
export function LanguageSwitcher(props: Props): JSX.Element {
|
||||||
const { locales, className, localesIndex, onLanguageChanged } = props;
|
const { locales, className, localesIndex, onLanguageChanged } = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Ico, Icon } from "components/Ico";
|
import { Ico, Icon } from "components/Ico";
|
||||||
import { arrayMove, isDefinedAndNotEmpty } from "helpers/others";
|
import { arrayMove, isDefinedAndNotEmpty } from "helpers/others";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { Fragment, useCallback, useState } from "react";
|
import { Fragment, useCallback, useState } from "react";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
@ -10,7 +10,7 @@ interface Props {
|
||||||
onChange?: (items: Map<string, string>) => void;
|
onChange?: (items: Map<string, string>) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function OrderableList(props: Immutable<Props>): JSX.Element {
|
export function OrderableList(props: Props): JSX.Element {
|
||||||
const { onChange } = props;
|
const { onChange } = props;
|
||||||
const [items, setItems] = useState<Map<string, string>>(props.items);
|
const [items, setItems] = useState<Map<string, string>>(props.items);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Icon } from "components/Ico";
|
import { Icon } from "components/Ico";
|
||||||
import { cJoin } from "helpers/className";
|
import { cJoin } from "helpers/className";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { Dispatch, SetStateAction } from "react";
|
import { Dispatch, SetStateAction } from "react";
|
||||||
import { Button } from "./Button";
|
import { Button } from "./Button";
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ interface Props {
|
||||||
setPage: Dispatch<SetStateAction<number>>;
|
setPage: Dispatch<SetStateAction<number>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function PageSelector(props: Immutable<Props>): JSX.Element {
|
export function PageSelector(props: Props): JSX.Element {
|
||||||
const { page, setPage, maxPage, className } = props;
|
const { page, setPage, maxPage, className } = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Ico, Icon } from "components/Ico";
|
import { Ico, Icon } from "components/Ico";
|
||||||
import { cIf, cJoin } from "helpers/className";
|
import { cIf, cJoin } from "helpers/className";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { useToggle } from "hooks/useToggle";
|
import { useToggle } from "hooks/useToggle";
|
||||||
import { Dispatch, Fragment, SetStateAction, useState } from "react";
|
import { Dispatch, Fragment, SetStateAction, useState } from "react";
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ interface Props {
|
||||||
className?: string;
|
className?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Select(props: Immutable<Props>): JSX.Element {
|
export function Select(props: Props): JSX.Element {
|
||||||
const { className, state, options, allowEmpty, setState } = props;
|
const { className, state, options, allowEmpty, setState } = props;
|
||||||
const [opened, setOpened] = useState(false);
|
const [opened, setOpened] = useState(false);
|
||||||
const toggleOpened = useToggle(setOpened);
|
const toggleOpened = useToggle(setOpened);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { cIf, cJoin } from "helpers/className";
|
import { cIf, cJoin } from "helpers/className";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { useToggle } from "hooks/useToggle";
|
import { useToggle } from "hooks/useToggle";
|
||||||
import { Dispatch, SetStateAction } from "react";
|
import { Dispatch, SetStateAction } from "react";
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ interface Props {
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Switch(props: Immutable<Props>): JSX.Element {
|
export function Switch(props: Props): JSX.Element {
|
||||||
const { state, setState, className, disabled } = props;
|
const { state, setState, className, disabled } = props;
|
||||||
const toggleState = useToggle(setState);
|
const toggleState = useToggle(setState);
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Ico, Icon } from "components/Ico";
|
import { Ico, Icon } from "components/Ico";
|
||||||
import { cJoin } from "helpers/className";
|
import { cJoin } from "helpers/className";
|
||||||
import { isDefinedAndNotEmpty } from "helpers/others";
|
import { isDefinedAndNotEmpty } from "helpers/others";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { Dispatch, SetStateAction } from "react";
|
import { Dispatch, SetStateAction } from "react";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
@ -14,7 +14,7 @@ interface Props {
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function TextInput(props: Immutable<Props>): JSX.Element {
|
export function TextInput(props: Props): JSX.Element {
|
||||||
const { state, setState, className, name, placeholder } = props;
|
const { state, setState, className, name, placeholder } = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { cIf, cJoin } from "helpers/className";
|
import { cIf, cJoin } from "helpers/className";
|
||||||
import { isDefinedAndNotEmpty } from "helpers/others";
|
import { isDefinedAndNotEmpty } from "helpers/others";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
label: string | null | undefined;
|
label: string | null | undefined;
|
||||||
|
@ -8,7 +7,7 @@ interface Props {
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function WithLabel(props: Immutable<Props>): JSX.Element {
|
export function WithLabel(props: Props): JSX.Element {
|
||||||
const { label, input, disabled } = props;
|
const { label, input, disabled } = props;
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { cJoin } from "helpers/className";
|
import { cJoin } from "helpers/className";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
className?: string;
|
className?: string;
|
||||||
|
@ -7,7 +6,7 @@ interface Props {
|
||||||
id?: string;
|
id?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function InsetBox(props: Immutable<Props>): JSX.Element {
|
export function InsetBox(props: Props): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
id={props.id}
|
id={props.id}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { Button } from "components/Inputs/Button";
|
||||||
import { GetLibraryItemQuery } from "graphql/generated";
|
import { GetLibraryItemQuery } from "graphql/generated";
|
||||||
import { AppStaticProps } from "graphql/getAppStaticProps";
|
import { AppStaticProps } from "graphql/getAppStaticProps";
|
||||||
import { prettyinlineTitle, prettySlug } from "helpers/formatters";
|
import { prettyinlineTitle, prettySlug } from "helpers/formatters";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { useToggle } from "hooks/useToggle";
|
import { useToggle } from "hooks/useToggle";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ interface Props {
|
||||||
langui: AppStaticProps["langui"];
|
langui: AppStaticProps["langui"];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ContentLine(props: Immutable<Props>): JSX.Element {
|
export function ContentLine(props: Props): JSX.Element {
|
||||||
const { content, langui, parentSlug } = props;
|
const { content, langui, parentSlug } = props;
|
||||||
|
|
||||||
const [opened, setOpened] = useState(false);
|
const [opened, setOpened] = useState(false);
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { AppStaticProps } from "graphql/getAppStaticProps";
|
||||||
import { getAssetFilename, getAssetURL, ImageQuality } from "helpers/img";
|
import { getAssetFilename, getAssetURL, ImageQuality } from "helpers/img";
|
||||||
import { isInteger } from "helpers/numbers";
|
import { isInteger } from "helpers/numbers";
|
||||||
import { getStatusDescription, isDefinedAndNotEmpty } from "helpers/others";
|
import { getStatusDescription, isDefinedAndNotEmpty } from "helpers/others";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { useSmartLanguage } from "hooks/useSmartLanguage";
|
import { useSmartLanguage } from "hooks/useSmartLanguage";
|
||||||
import { Fragment } from "react";
|
import { Fragment } from "react";
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ interface Props {
|
||||||
>["content"];
|
>["content"];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ScanSet(props: Immutable<Props>): JSX.Element {
|
export function ScanSet(props: Props): JSX.Element {
|
||||||
const { openLightBox, scanSet, slug, title, languages, langui, content } =
|
const { openLightBox, scanSet, slug, title, languages, langui, content } =
|
||||||
props;
|
props;
|
||||||
|
|
||||||
|
@ -49,36 +49,34 @@ export function ScanSet(props: Immutable<Props>): JSX.Element {
|
||||||
languages: languages,
|
languages: languages,
|
||||||
languageExtractor: (item) => item.language?.data?.attributes?.code,
|
languageExtractor: (item) => item.language?.data?.attributes?.code,
|
||||||
transform: (item) => {
|
transform: (item) => {
|
||||||
(item as NonNullable<Props["scanSet"][number]>).pages?.data.sort(
|
item.pages?.data.sort((a, b) => {
|
||||||
(a, b) => {
|
if (
|
||||||
if (
|
a.attributes &&
|
||||||
a.attributes &&
|
b.attributes &&
|
||||||
b.attributes &&
|
isDefinedAndNotEmpty(a.attributes.url) &&
|
||||||
isDefinedAndNotEmpty(a.attributes.url) &&
|
isDefinedAndNotEmpty(b.attributes.url)
|
||||||
isDefinedAndNotEmpty(b.attributes.url)
|
) {
|
||||||
) {
|
let aName = getAssetFilename(a.attributes.url);
|
||||||
let aName = getAssetFilename(a.attributes.url);
|
let bName = getAssetFilename(b.attributes.url);
|
||||||
let bName = getAssetFilename(b.attributes.url);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the number is a succession of 0s, make the number
|
* If the number is a succession of 0s, make the number
|
||||||
* incrementally smaller than 0 (i.e: 00 becomes -1)
|
* incrementally smaller than 0 (i.e: 00 becomes -1)
|
||||||
*/
|
*/
|
||||||
if (aName.replaceAll("0", "").length === 0) {
|
if (aName.replaceAll("0", "").length === 0) {
|
||||||
aName = (1 - aName.length).toString(10);
|
aName = (1 - aName.length).toString(10);
|
||||||
}
|
|
||||||
if (bName.replaceAll("0", "").length === 0) {
|
|
||||||
bName = (1 - bName.length).toString(10);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isInteger(aName) && isInteger(bName)) {
|
|
||||||
return parseInt(aName, 10) - parseInt(bName, 10);
|
|
||||||
}
|
|
||||||
return a.attributes.url.localeCompare(b.attributes.url);
|
|
||||||
}
|
}
|
||||||
return 0;
|
if (bName.replaceAll("0", "").length === 0) {
|
||||||
|
bName = (1 - bName.length).toString(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isInteger(aName) && isInteger(bName)) {
|
||||||
|
return parseInt(aName, 10) - parseInt(bName, 10);
|
||||||
|
}
|
||||||
|
return a.attributes.url.localeCompare(b.attributes.url);
|
||||||
}
|
}
|
||||||
);
|
return 0;
|
||||||
|
});
|
||||||
return item;
|
return item;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,7 +9,7 @@ import {
|
||||||
import { AppStaticProps } from "graphql/getAppStaticProps";
|
import { AppStaticProps } from "graphql/getAppStaticProps";
|
||||||
import { getAssetURL, ImageQuality } from "helpers/img";
|
import { getAssetURL, ImageQuality } from "helpers/img";
|
||||||
import { getStatusDescription } from "helpers/others";
|
import { getStatusDescription } from "helpers/others";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { useSmartLanguage } from "hooks/useSmartLanguage";
|
import { useSmartLanguage } from "hooks/useSmartLanguage";
|
||||||
import { Fragment } from "react";
|
import { Fragment } from "react";
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ interface Props {
|
||||||
langui: AppStaticProps["langui"];
|
langui: AppStaticProps["langui"];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ScanSetCover(props: Immutable<Props>): JSX.Element {
|
export function ScanSetCover(props: Props): JSX.Element {
|
||||||
const { openLightBox, images, languages, langui } = props;
|
const { openLightBox, images, languages, langui } = props;
|
||||||
|
|
||||||
const [selectedScan, LanguageSwitcher] = useSmartLanguage({
|
const [selectedScan, LanguageSwitcher] = useSmartLanguage({
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { Dispatch, SetStateAction, useCallback } from "react";
|
import { Dispatch, SetStateAction, useCallback } from "react";
|
||||||
import Hotkeys from "react-hot-keys";
|
import Hotkeys from "react-hot-keys";
|
||||||
import { useSwipeable } from "react-swipeable";
|
import { useSwipeable } from "react-swipeable";
|
||||||
|
@ -19,7 +18,7 @@ interface Props {
|
||||||
|
|
||||||
const SENSIBILITY_SWIPE = 0.5;
|
const SENSIBILITY_SWIPE = 0.5;
|
||||||
|
|
||||||
export function LightBox(props: Immutable<Props>): JSX.Element {
|
export function LightBox(props: Props): JSX.Element {
|
||||||
const { state, setState, images, index, setIndex } = props;
|
const { state, setState, images, index, setIndex } = props;
|
||||||
|
|
||||||
const handlePrevious = useCallback(() => {
|
const handlePrevious = useCallback(() => {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { cJoin } from "helpers/className";
|
||||||
import { slugify } from "helpers/formatters";
|
import { slugify } from "helpers/formatters";
|
||||||
import { getAssetURL, ImageQuality } from "helpers/img";
|
import { getAssetURL, ImageQuality } from "helpers/img";
|
||||||
import { isDefined, isDefinedAndNotEmpty } from "helpers/others";
|
import { isDefined, isDefinedAndNotEmpty } from "helpers/others";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { useLightBox } from "hooks/useLightBox";
|
import { useLightBox } from "hooks/useLightBox";
|
||||||
import Markdown from "markdown-to-jsx";
|
import Markdown from "markdown-to-jsx";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
|
@ -20,7 +20,7 @@ interface Props {
|
||||||
text: string;
|
text: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Markdawn(props: Immutable<Props>): JSX.Element {
|
export function Markdawn(props: Props): JSX.Element {
|
||||||
const { className, text: rawText } = props;
|
const { className, text: rawText } = props;
|
||||||
const appLayout = useAppLayout();
|
const appLayout = useAppLayout();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { slugify } from "helpers/formatters";
|
import { slugify } from "helpers/formatters";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { Fragment, useMemo } from "react";
|
import { Fragment, useMemo } from "react";
|
||||||
import { preprocessMarkDawn } from "./Markdawn";
|
import { preprocessMarkDawn } from "./Markdawn";
|
||||||
|
@ -9,7 +9,7 @@ interface Props {
|
||||||
title?: string;
|
title?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function TOC(props: Immutable<Props>): JSX.Element {
|
export function TOC(props: Props): JSX.Element {
|
||||||
const { text, title } = props;
|
const { text, title } = props;
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const toc = useMemo(
|
const toc = useMemo(
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { Ico, Icon } from "components/Ico";
|
||||||
import { ToolTip } from "components/ToolTip";
|
import { ToolTip } from "components/ToolTip";
|
||||||
import { cJoin, cIf } from "helpers/className";
|
import { cJoin, cIf } from "helpers/className";
|
||||||
import { isDefinedAndNotEmpty } from "helpers/others";
|
import { isDefinedAndNotEmpty } from "helpers/others";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { MouseEventHandler, useMemo } from "react";
|
import { MouseEventHandler, useMemo } from "react";
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ interface Props {
|
||||||
onClick?: MouseEventHandler<HTMLDivElement>;
|
onClick?: MouseEventHandler<HTMLDivElement>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function NavOption(props: Immutable<Props>): JSX.Element {
|
export function NavOption(props: Props): JSX.Element {
|
||||||
const { url, icon, title, subtitle, border, reduced, onClick } = props;
|
const { url, icon, title, subtitle, border, reduced, onClick } = props;
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const isActive = useMemo(
|
const isActive = useMemo(
|
||||||
|
@ -66,7 +66,9 @@ export function NavOption(props: Immutable<Props>): JSX.Element {
|
||||||
{reduced === false && (
|
{reduced === false && (
|
||||||
<div>
|
<div>
|
||||||
<h3 className="text-2xl">{title}</h3>
|
<h3 className="text-2xl">{title}</h3>
|
||||||
{isDefinedAndNotEmpty(subtitle) && <p className="col-start-2">{subtitle}</p>}
|
{isDefinedAndNotEmpty(subtitle) && (
|
||||||
|
<p className="col-start-2">{subtitle}</p>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { HorizontalLine } from "components/HorizontalLine";
|
import { HorizontalLine } from "components/HorizontalLine";
|
||||||
import { Ico, Icon } from "components/Ico";
|
import { Ico, Icon } from "components/Ico";
|
||||||
import { isDefinedAndNotEmpty } from "helpers/others";
|
import { isDefinedAndNotEmpty } from "helpers/others";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
icon?: Icon;
|
icon?: Icon;
|
||||||
|
@ -9,7 +8,7 @@ interface Props {
|
||||||
description?: string | null | undefined;
|
description?: string | null | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function PanelHeader(props: Immutable<Props>): JSX.Element {
|
export function PanelHeader(props: Props): JSX.Element {
|
||||||
const { icon, description, title } = props;
|
const { icon, description, title } = props;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
|
@ -4,7 +4,6 @@ import { Button } from "components/Inputs/Button";
|
||||||
import { useAppLayout } from "contexts/AppLayoutContext";
|
import { useAppLayout } from "contexts/AppLayoutContext";
|
||||||
import { AppStaticProps } from "graphql/getAppStaticProps";
|
import { AppStaticProps } from "graphql/getAppStaticProps";
|
||||||
import { cJoin } from "helpers/className";
|
import { cJoin } from "helpers/className";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
href: string;
|
href: string;
|
||||||
|
@ -21,7 +20,7 @@ export enum ReturnButtonType {
|
||||||
Both = "both",
|
Both = "both",
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ReturnButton(props: Immutable<Props>): JSX.Element {
|
export function ReturnButton(props: Props): JSX.Element {
|
||||||
const { href, title, langui, displayOn, horizontalLine, className } = props;
|
const { href, title, langui, displayOn, horizontalLine, className } = props;
|
||||||
const appLayout = useAppLayout();
|
const appLayout = useAppLayout();
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { cJoin } from "helpers/className";
|
import { cJoin } from "helpers/className";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
|
@ -12,7 +11,7 @@ export enum ContentPanelWidthSizes {
|
||||||
Full = "full",
|
Full = "full",
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ContentPanel(props: Immutable<Props>): JSX.Element {
|
export function ContentPanel(props: Props): JSX.Element {
|
||||||
const { width = ContentPanelWidthSizes.Default, children } = props;
|
const { width = ContentPanelWidthSizes.Default, children } = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { NavOption } from "components/PanelComponents/NavOption";
|
||||||
import { ToolTip } from "components/ToolTip";
|
import { ToolTip } from "components/ToolTip";
|
||||||
import { useAppLayout } from "contexts/AppLayoutContext";
|
import { useAppLayout } from "contexts/AppLayoutContext";
|
||||||
import { AppStaticProps } from "graphql/getAppStaticProps";
|
import { AppStaticProps } from "graphql/getAppStaticProps";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { useMediaDesktop } from "hooks/useMediaQuery";
|
import { useMediaDesktop } from "hooks/useMediaQuery";
|
||||||
import Markdown from "markdown-to-jsx";
|
import Markdown from "markdown-to-jsx";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
@ -16,7 +16,7 @@ interface Props {
|
||||||
langui: AppStaticProps["langui"];
|
langui: AppStaticProps["langui"];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function MainPanel(props: Immutable<Props>): JSX.Element {
|
export function MainPanel(props: Props): JSX.Element {
|
||||||
const { langui } = props;
|
const { langui } = props;
|
||||||
const isDesktop = useMediaDesktop();
|
const isDesktop = useMediaDesktop();
|
||||||
const {
|
const {
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SubPanel(props: Immutable<Props>): JSX.Element {
|
export function SubPanel(props: Props): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<div className="grid gap-y-2 px-6 pt-10 pb-20 text-center desktop:py-8 desktop:px-10">
|
<div className="grid gap-y-2 px-6 pt-10 pb-20 text-center desktop:py-8 desktop:px-10">
|
||||||
{props.children}
|
{props.children}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { useAppLayout } from "contexts/AppLayoutContext";
|
import { useAppLayout } from "contexts/AppLayoutContext";
|
||||||
import { cIf, cJoin } from "helpers/className";
|
import { cIf, cJoin } from "helpers/className";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { Dispatch, SetStateAction, useEffect } from "react";
|
import { Dispatch, SetStateAction, useEffect } from "react";
|
||||||
import Hotkeys from "react-hot-keys";
|
import Hotkeys from "react-hot-keys";
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ interface Props {
|
||||||
padding?: boolean;
|
padding?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Popup(props: Immutable<Props>): JSX.Element {
|
export function Popup(props: Props): JSX.Element {
|
||||||
const {
|
const {
|
||||||
setState,
|
setState,
|
||||||
state,
|
state,
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { AppStaticProps } from "graphql/getAppStaticProps";
|
||||||
import { getDescription } from "helpers/description";
|
import { getDescription } from "helpers/description";
|
||||||
import { prettySlug } from "helpers/formatters";
|
import { prettySlug } from "helpers/formatters";
|
||||||
import { getStatusDescription } from "helpers/others";
|
import { getStatusDescription } from "helpers/others";
|
||||||
import { Immutable, PostWithTranslations } from "helpers/types";
|
import { PostWithTranslations } from "helpers/types";
|
||||||
import { useSmartLanguage } from "hooks/useSmartLanguage";
|
import { useSmartLanguage } from "hooks/useSmartLanguage";
|
||||||
import { Fragment, useMemo } from "react";
|
import { Fragment, useMemo } from "react";
|
||||||
import { AppLayout } from "./AppLayout";
|
import { AppLayout } from "./AppLayout";
|
||||||
|
@ -33,7 +33,7 @@ interface Props {
|
||||||
appendBody?: JSX.Element;
|
appendBody?: JSX.Element;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function PostPage(props: Immutable<Props>): JSX.Element {
|
export function PostPage(props: Props): JSX.Element {
|
||||||
const {
|
const {
|
||||||
post,
|
post,
|
||||||
langui,
|
langui,
|
||||||
|
|
|
@ -14,7 +14,7 @@ import {
|
||||||
prettySlug,
|
prettySlug,
|
||||||
} from "helpers/formatters";
|
} from "helpers/formatters";
|
||||||
import { ImageQuality } from "helpers/img";
|
import { ImageQuality } from "helpers/img";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { useSmartLanguage } from "hooks/useSmartLanguage";
|
import { useSmartLanguage } from "hooks/useSmartLanguage";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { Chip } from "./Chip";
|
import { Chip } from "./Chip";
|
||||||
|
@ -52,7 +52,7 @@ interface Props {
|
||||||
| { __typename: "anotherHoverlayName" };
|
| { __typename: "anotherHoverlayName" };
|
||||||
}
|
}
|
||||||
|
|
||||||
export function PreviewCard(props: Immutable<Props>): JSX.Element {
|
export function PreviewCard(props: Props): JSX.Element {
|
||||||
const {
|
const {
|
||||||
href,
|
href,
|
||||||
thumbnail,
|
thumbnail,
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { UploadImageFragment } from "graphql/generated";
|
||||||
import { AppStaticProps } from "graphql/getAppStaticProps";
|
import { AppStaticProps } from "graphql/getAppStaticProps";
|
||||||
import { prettySlug } from "helpers/formatters";
|
import { prettySlug } from "helpers/formatters";
|
||||||
import { ImageQuality } from "helpers/img";
|
import { ImageQuality } from "helpers/img";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { useSmartLanguage } from "hooks/useSmartLanguage";
|
import { useSmartLanguage } from "hooks/useSmartLanguage";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { Chip } from "./Chip";
|
import { Chip } from "./Chip";
|
||||||
|
@ -19,7 +19,7 @@ interface Props {
|
||||||
bottomChips?: string[];
|
bottomChips?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function PreviewLine(props: Immutable<Props>): JSX.Element {
|
export function PreviewLine(props: Props): JSX.Element {
|
||||||
const {
|
const {
|
||||||
href,
|
href,
|
||||||
thumbnail,
|
thumbnail,
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { Chip } from "components/Chip";
|
||||||
import { RecorderChipFragment } from "graphql/generated";
|
import { RecorderChipFragment } from "graphql/generated";
|
||||||
import { AppStaticProps } from "graphql/getAppStaticProps";
|
import { AppStaticProps } from "graphql/getAppStaticProps";
|
||||||
import { ImageQuality } from "helpers/img";
|
import { ImageQuality } from "helpers/img";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { Fragment } from "react";
|
import { Fragment } from "react";
|
||||||
import { Img } from "./Img";
|
import { Img } from "./Img";
|
||||||
import { Markdawn } from "./Markdown/Markdawn";
|
import { Markdawn } from "./Markdown/Markdawn";
|
||||||
|
@ -14,7 +14,7 @@ interface Props {
|
||||||
langui: AppStaticProps["langui"];
|
langui: AppStaticProps["langui"];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function RecorderChip(props: Immutable<Props>): JSX.Element {
|
export function RecorderChip(props: Props): JSX.Element {
|
||||||
const { recorder, langui } = props;
|
const { recorder, langui } = props;
|
||||||
return (
|
return (
|
||||||
<ToolTip
|
<ToolTip
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { GetContentTextQuery, UploadImageFragment } from "graphql/generated";
|
||||||
import { AppStaticProps } from "graphql/getAppStaticProps";
|
import { AppStaticProps } from "graphql/getAppStaticProps";
|
||||||
import { prettyinlineTitle, prettySlug, slugify } from "helpers/formatters";
|
import { prettyinlineTitle, prettySlug, slugify } from "helpers/formatters";
|
||||||
import { getAssetURL, ImageQuality } from "helpers/img";
|
import { getAssetURL, ImageQuality } from "helpers/img";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { useLightBox } from "hooks/useLightBox";
|
import { useLightBox } from "hooks/useLightBox";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
@ -25,7 +25,7 @@ interface Props {
|
||||||
languageSwitcher?: JSX.Element;
|
languageSwitcher?: JSX.Element;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ThumbnailHeader(props: Immutable<Props>): JSX.Element {
|
export function ThumbnailHeader(props: Props): JSX.Element {
|
||||||
const {
|
const {
|
||||||
langui,
|
langui,
|
||||||
pre_title,
|
pre_title,
|
||||||
|
|
|
@ -7,7 +7,7 @@ import {
|
||||||
} from "graphql/generated";
|
} from "graphql/generated";
|
||||||
import { AppStaticProps } from "graphql/getAppStaticProps";
|
import { AppStaticProps } from "graphql/getAppStaticProps";
|
||||||
import { getStatusDescription } from "helpers/others";
|
import { getStatusDescription } from "helpers/others";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { Fragment } from "react";
|
import { Fragment } from "react";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
@ -16,7 +16,7 @@ interface Props {
|
||||||
langui: AppStaticProps["langui"];
|
langui: AppStaticProps["langui"];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ChronologyItemComponent(props: Immutable<Props>): JSX.Element {
|
export function ChronologyItemComponent(props: Props): JSX.Element {
|
||||||
const { langui } = props;
|
const { langui } = props;
|
||||||
|
|
||||||
if (props.item.attributes) {
|
if (props.item.attributes) {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { ChronologyItemComponent } from "components/Wiki/Chronology/ChronologyItemComponent";
|
import { ChronologyItemComponent } from "components/Wiki/Chronology/ChronologyItemComponent";
|
||||||
import { GetChronologyItemsQuery } from "graphql/generated";
|
import { GetChronologyItemsQuery } from "graphql/generated";
|
||||||
import { AppStaticProps } from "graphql/getAppStaticProps";
|
import { AppStaticProps } from "graphql/getAppStaticProps";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
year: number;
|
year: number;
|
||||||
|
@ -11,7 +10,7 @@ interface Props {
|
||||||
langui: AppStaticProps["langui"];
|
langui: AppStaticProps["langui"];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ChronologyYearComponent(props: Immutable<Props>): JSX.Element {
|
export function ChronologyYearComponent(props: Props): JSX.Element {
|
||||||
const { langui } = props;
|
const { langui } = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
import { isDefined } from "helpers/others";
|
import { isDefined } from "helpers/others";
|
||||||
import {
|
import { LibraryItemUserStatus, RequiredNonNullable } from "helpers/types";
|
||||||
Immutable,
|
|
||||||
LibraryItemUserStatus,
|
|
||||||
RequiredNonNullable,
|
|
||||||
} from "helpers/types";
|
|
||||||
import { useDarkMode } from "hooks/useDarkMode";
|
import { useDarkMode } from "hooks/useDarkMode";
|
||||||
import { useStateWithLocalStorage } from "hooks/useStateWithLocalStorage";
|
import { useStateWithLocalStorage } from "hooks/useStateWithLocalStorage";
|
||||||
import React, { ReactNode, useContext, useState } from "react";
|
import React, { ReactNode, useContext, useState } from "react";
|
||||||
|
@ -120,7 +116,7 @@ interface Props {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function AppContextProvider(props: Immutable<Props>): JSX.Element {
|
export function AppContextProvider(props: Props): JSX.Element {
|
||||||
const [subPanelOpen, setSubPanelOpen] = useStateWithLocalStorage(
|
const [subPanelOpen, setSubPanelOpen] = useStateWithLocalStorage(
|
||||||
"subPanelOpen",
|
"subPanelOpen",
|
||||||
initialState.subPanelOpen
|
initialState.subPanelOpen
|
||||||
|
|
|
@ -4,10 +4,10 @@ import {
|
||||||
GetWebsiteInterfaceQuery,
|
GetWebsiteInterfaceQuery,
|
||||||
} from "graphql/generated";
|
} from "graphql/generated";
|
||||||
import { getReadySdk } from "graphql/sdk";
|
import { getReadySdk } from "graphql/sdk";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { GetStaticPropsContext } from "next";
|
import { GetStaticPropsContext } from "next";
|
||||||
|
|
||||||
export type AppStaticProps = Immutable<{
|
export type AppStaticProps = {
|
||||||
langui: NonNullable<
|
langui: NonNullable<
|
||||||
NonNullable<
|
NonNullable<
|
||||||
GetWebsiteInterfaceQuery["websiteInterfaces"]
|
GetWebsiteInterfaceQuery["websiteInterfaces"]
|
||||||
|
@ -15,7 +15,7 @@ export type AppStaticProps = Immutable<{
|
||||||
>;
|
>;
|
||||||
currencies: NonNullable<GetCurrenciesQuery["currencies"]>["data"];
|
currencies: NonNullable<GetCurrenciesQuery["currencies"]>["data"];
|
||||||
languages: NonNullable<GetLanguagesQuery["languages"]>["data"];
|
languages: NonNullable<GetLanguagesQuery["languages"]>["data"];
|
||||||
}>;
|
};
|
||||||
|
|
||||||
export async function getAppStaticProps(
|
export async function getAppStaticProps(
|
||||||
context: GetStaticPropsContext
|
context: GetStaticPropsContext
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
import { ContentWithTranslations, Immutable } from "./types";
|
import { ContentWithTranslations } from "./types";
|
||||||
|
|
||||||
type Group = Immutable<
|
type Group = NonNullable<
|
||||||
NonNullable<
|
NonNullable<
|
||||||
NonNullable<
|
NonNullable<
|
||||||
NonNullable<
|
NonNullable<ContentWithTranslations["group"]>["data"]
|
||||||
NonNullable<ContentWithTranslations["group"]>["data"]
|
>["attributes"]
|
||||||
>["attributes"]
|
>["contents"]
|
||||||
>["contents"]
|
>["data"];
|
||||||
>["data"]
|
|
||||||
>;
|
|
||||||
|
|
||||||
export function getPreviousContent(group: Group, currentSlug: string) {
|
export function getPreviousContent(group: Group, currentSlug: string) {
|
||||||
for (let index = 0; index < group.length; index += 1) {
|
for (let index = 0; index < group.length; index += 1) {
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import { AppStaticProps } from "graphql/getAppStaticProps";
|
import { AppStaticProps } from "graphql/getAppStaticProps";
|
||||||
import { prettySlug } from "./formatters";
|
import { prettySlug } from "./formatters";
|
||||||
import { isDefined } from "./others";
|
import { isDefined } from "./others";
|
||||||
import { Content, Immutable } from "./types";
|
import { Content } from "./types";
|
||||||
|
|
||||||
interface Description {
|
interface Description {
|
||||||
langui: AppStaticProps["langui"];
|
langui: AppStaticProps["langui"];
|
||||||
description?: string | null | undefined;
|
description?: string | null | undefined;
|
||||||
type?: Immutable<Content["type"]>;
|
type?: Content["type"];
|
||||||
categories?: Immutable<Content["categories"]>;
|
categories?: Content["categories"];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDescription(props: Description): string {
|
export function getDescription(props: Description): string {
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
import { DatePickerFragment, PricePickerFragment } from "graphql/generated";
|
import { DatePickerFragment, PricePickerFragment } from "graphql/generated";
|
||||||
import { AppStaticProps } from "../graphql/getAppStaticProps";
|
import { AppStaticProps } from "../graphql/getAppStaticProps";
|
||||||
import { convertPrice } from "./numbers";
|
import { convertPrice } from "./numbers";
|
||||||
import { Immutable } from "./types";
|
|
||||||
|
|
||||||
export function prettyDate(datePicker: Immutable<DatePickerFragment>): string {
|
export function prettyDate(datePicker: DatePickerFragment): string {
|
||||||
let result = "";
|
let result = "";
|
||||||
if (datePicker.year) result += datePicker.year.toString();
|
if (datePicker.year) result += datePicker.year.toString();
|
||||||
if (datePicker.month)
|
if (datePicker.month)
|
||||||
|
@ -14,7 +13,7 @@ export function prettyDate(datePicker: Immutable<DatePickerFragment>): string {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function prettyPrice(
|
export function prettyPrice(
|
||||||
pricePicker: Immutable<PricePickerFragment>,
|
pricePicker: PricePickerFragment,
|
||||||
currencies: AppStaticProps["currencies"],
|
currencies: AppStaticProps["currencies"],
|
||||||
targetCurrencyCode?: string
|
targetCurrencyCode?: string
|
||||||
): string {
|
): string {
|
||||||
|
@ -58,7 +57,7 @@ export function prettyinlineTitle(
|
||||||
}
|
}
|
||||||
|
|
||||||
export function prettyItemType(
|
export function prettyItemType(
|
||||||
metadata: Immutable<any>,
|
metadata: any,
|
||||||
langui: AppStaticProps["langui"]
|
langui: AppStaticProps["langui"]
|
||||||
): string | undefined | null {
|
): string | undefined | null {
|
||||||
switch (metadata.__typename) {
|
switch (metadata.__typename) {
|
||||||
|
@ -80,7 +79,7 @@ export function prettyItemType(
|
||||||
}
|
}
|
||||||
|
|
||||||
export function prettyItemSubType(
|
export function prettyItemSubType(
|
||||||
metadata: Immutable<
|
metadata:
|
||||||
| {
|
| {
|
||||||
__typename: "ComponentMetadataAudio";
|
__typename: "ComponentMetadataAudio";
|
||||||
subtype?: {
|
subtype?: {
|
||||||
|
@ -157,7 +156,6 @@ export function prettyItemSubType(
|
||||||
}
|
}
|
||||||
| { __typename: "Error" }
|
| { __typename: "Error" }
|
||||||
| null
|
| null
|
||||||
>
|
|
||||||
): string {
|
): string {
|
||||||
if (metadata) {
|
if (metadata) {
|
||||||
switch (metadata.__typename) {
|
switch (metadata.__typename) {
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { UploadImageFragment } from "graphql/generated";
|
import { UploadImageFragment } from "graphql/generated";
|
||||||
import { Immutable } from "./types";
|
|
||||||
|
|
||||||
export enum ImageQuality {
|
export enum ImageQuality {
|
||||||
Small = "small",
|
Small = "small",
|
||||||
|
@ -25,10 +24,7 @@ export function getAssetFilename(path: string): string {
|
||||||
return result[0];
|
return result[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getAssetURL(
|
export function getAssetURL(url: string, quality: ImageQuality): string {
|
||||||
url: string,
|
|
||||||
quality: Immutable<ImageQuality>
|
|
||||||
): string {
|
|
||||||
let newUrl = url;
|
let newUrl = url;
|
||||||
newUrl = newUrl.replace(/^\/uploads/u, `/${quality}`);
|
newUrl = newUrl.replace(/^\/uploads/u, `/${quality}`);
|
||||||
newUrl = newUrl.replace(/.jpg$/u, ".webp");
|
newUrl = newUrl.replace(/.jpg$/u, ".webp");
|
||||||
|
@ -71,8 +67,8 @@ export function getImgSizesByQuality(
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getOgImage(
|
export function getOgImage(
|
||||||
quality: Immutable<ImageQuality>,
|
quality: ImageQuality,
|
||||||
image: Immutable<UploadImageFragment>
|
image: UploadImageFragment
|
||||||
): OgImage {
|
): OgImage {
|
||||||
const imgSize = getImgSizesByQuality(
|
const imgSize = getImgSizesByQuality(
|
||||||
image.width ?? 0,
|
image.width ?? 0,
|
||||||
|
|
|
@ -4,14 +4,14 @@ import { AppStaticProps } from "graphql/getAppStaticProps";
|
||||||
import { prettyinlineTitle, prettyDate } from "./formatters";
|
import { prettyinlineTitle, prettyDate } from "./formatters";
|
||||||
import { convertPrice } from "./numbers";
|
import { convertPrice } from "./numbers";
|
||||||
import { isDefined } from "./others";
|
import { isDefined } from "./others";
|
||||||
import { Immutable, LibraryItemUserStatus } from "./types";
|
import { LibraryItemUserStatus } from "./types";
|
||||||
type Items = NonNullable<GetLibraryItemsPreviewQuery["libraryItems"]>["data"];
|
type Items = NonNullable<GetLibraryItemsPreviewQuery["libraryItems"]>["data"];
|
||||||
type GroupLibraryItems = Map<string, Immutable<Items>>;
|
type GroupLibraryItems = Map<string, Items>;
|
||||||
|
|
||||||
export function getGroups(
|
export function getGroups(
|
||||||
langui: AppStaticProps["langui"],
|
langui: AppStaticProps["langui"],
|
||||||
groupByType: number,
|
groupByType: number,
|
||||||
items: Immutable<Items>
|
items: Items
|
||||||
): GroupLibraryItems {
|
): GroupLibraryItems {
|
||||||
switch (groupByType) {
|
switch (groupByType) {
|
||||||
case 0: {
|
case 0: {
|
||||||
|
@ -148,13 +148,13 @@ export function getGroups(
|
||||||
|
|
||||||
export function filterItems(
|
export function filterItems(
|
||||||
appLayout: AppLayoutState,
|
appLayout: AppLayoutState,
|
||||||
items: Immutable<Items>,
|
items: Items,
|
||||||
searchName: string,
|
searchName: string,
|
||||||
showSubitems: boolean,
|
showSubitems: boolean,
|
||||||
showPrimaryItems: boolean,
|
showPrimaryItems: boolean,
|
||||||
showSecondaryItems: boolean,
|
showSecondaryItems: boolean,
|
||||||
filterUserStatus: LibraryItemUserStatus | undefined
|
filterUserStatus: LibraryItemUserStatus | undefined
|
||||||
): Immutable<Items> {
|
): Items {
|
||||||
return [...items].filter((item) => {
|
return [...items].filter((item) => {
|
||||||
if (!showSubitems && !item.attributes?.root_item) return false;
|
if (!showSubitems && !item.attributes?.root_item) return false;
|
||||||
if (showSubitems && isUntangibleGroupItem(item.attributes?.metadata?.[0])) {
|
if (showSubitems && isUntangibleGroupItem(item.attributes?.metadata?.[0])) {
|
||||||
|
@ -196,7 +196,6 @@ export function filterItems(
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Properly type this shit
|
// TODO: Properly type this shit
|
||||||
// Best attempt was Immutable<NonNullable<NonNullable<Items[number]["attributes"]>["metadata"]>[number]>
|
|
||||||
export function isUntangibleGroupItem(metadata: any) {
|
export function isUntangibleGroupItem(metadata: any) {
|
||||||
return (
|
return (
|
||||||
metadata &&
|
metadata &&
|
||||||
|
@ -208,9 +207,9 @@ export function isUntangibleGroupItem(metadata: any) {
|
||||||
|
|
||||||
export function sortBy(
|
export function sortBy(
|
||||||
orderByType: number,
|
orderByType: number,
|
||||||
items: Immutable<Items>,
|
items: Items,
|
||||||
currencies: AppStaticProps["currencies"]
|
currencies: AppStaticProps["currencies"]
|
||||||
): Immutable<Items> {
|
): Items {
|
||||||
switch (orderByType) {
|
switch (orderByType) {
|
||||||
case 0:
|
case 0:
|
||||||
return [...items].sort((a, b) => {
|
return [...items].sort((a, b) => {
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
import { GetCurrenciesQuery, PricePickerFragment } from "graphql/generated";
|
import { GetCurrenciesQuery, PricePickerFragment } from "graphql/generated";
|
||||||
import { Immutable } from "./types";
|
|
||||||
|
|
||||||
export function convertPrice(
|
export function convertPrice(
|
||||||
pricePicker: Immutable<PricePickerFragment>,
|
pricePicker: PricePickerFragment,
|
||||||
targetCurrency: Immutable<
|
targetCurrency: NonNullable<GetCurrenciesQuery["currencies"]>["data"][number]
|
||||||
NonNullable<GetCurrenciesQuery["currencies"]>["data"][number]
|
|
||||||
>
|
|
||||||
): number {
|
): number {
|
||||||
if (
|
if (
|
||||||
pricePicker.amount &&
|
pricePicker.amount &&
|
||||||
|
|
|
@ -4,7 +4,6 @@ import {
|
||||||
GetLibraryItemScansQuery,
|
GetLibraryItemScansQuery,
|
||||||
} from "graphql/generated";
|
} from "graphql/generated";
|
||||||
import { AppStaticProps } from "../graphql/getAppStaticProps";
|
import { AppStaticProps } from "../graphql/getAppStaticProps";
|
||||||
import { Immutable } from "./types";
|
|
||||||
|
|
||||||
type SortContentProps =
|
type SortContentProps =
|
||||||
| NonNullable<
|
| NonNullable<
|
||||||
|
@ -18,9 +17,9 @@ type SortContentProps =
|
||||||
>["data"][number]["attributes"]
|
>["data"][number]["attributes"]
|
||||||
>["contents"];
|
>["contents"];
|
||||||
|
|
||||||
export function sortContent(contents: Immutable<SortContentProps>) {
|
export function sortContent(contents: SortContentProps) {
|
||||||
if (contents) {
|
if (contents) {
|
||||||
const newContent = { ...contents } as SortContentProps;
|
const newContent = { ...contents };
|
||||||
newContent?.data.sort((a, b) => {
|
newContent?.data.sort((a, b) => {
|
||||||
if (
|
if (
|
||||||
a.attributes?.range[0]?.__typename === "ComponentRangePageRange" &&
|
a.attributes?.range[0]?.__typename === "ComponentRangePageRange" &&
|
||||||
|
@ -33,7 +32,7 @@ export function sortContent(contents: Immutable<SortContentProps>) {
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
return newContent as Immutable<SortContentProps>;
|
return newContent;
|
||||||
}
|
}
|
||||||
return contents;
|
return contents;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,14 +30,6 @@ export interface WikiPageWithTranslations
|
||||||
translations: NonNullable<WikiPage["translations"]>;
|
translations: NonNullable<WikiPage["translations"]>;
|
||||||
}
|
}
|
||||||
|
|
||||||
type ImmutableBlackList<T> = JSX.Element | React.ReactNode | Function;
|
|
||||||
|
|
||||||
export type Immutable<T> = {
|
|
||||||
readonly [K in keyof T]: T[K] extends ImmutableBlackList<T>
|
|
||||||
? T[K]
|
|
||||||
: Immutable<T[K]>;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type RequiredNonNullable<T> = Required<{
|
export type RequiredNonNullable<T> = Required<{
|
||||||
[P in keyof T]: NonNullable<T[P]>;
|
[P in keyof T]: NonNullable<T[P]>;
|
||||||
}>;
|
}>;
|
||||||
|
|
|
@ -2,15 +2,15 @@ import { LanguageSwitcher } from "components/Inputs/LanguageSwitcher";
|
||||||
import { useAppLayout } from "contexts/AppLayoutContext";
|
import { useAppLayout } from "contexts/AppLayoutContext";
|
||||||
import { AppStaticProps } from "graphql/getAppStaticProps";
|
import { AppStaticProps } from "graphql/getAppStaticProps";
|
||||||
import { isDefined } from "helpers/others";
|
import { isDefined } from "helpers/others";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { useEffect, useMemo, useState } from "react";
|
import { useEffect, useMemo, useState } from "react";
|
||||||
|
|
||||||
interface Props<T> {
|
interface Props<T> {
|
||||||
items: Immutable<T[]>;
|
items: T[];
|
||||||
languages: AppStaticProps["languages"];
|
languages: AppStaticProps["languages"];
|
||||||
languageExtractor: (item: NonNullable<Immutable<T>>) => string | undefined;
|
languageExtractor: (item: NonNullable<T>) => string | undefined;
|
||||||
transform?: (item: NonNullable<Immutable<T>>) => NonNullable<Immutable<T>>;
|
transform?: (item: NonNullable<T>) => NonNullable<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPreferredLanguage(
|
function getPreferredLanguage(
|
||||||
|
@ -27,7 +27,7 @@ function getPreferredLanguage(
|
||||||
|
|
||||||
export function useSmartLanguage<T>(
|
export function useSmartLanguage<T>(
|
||||||
props: Props<T>
|
props: Props<T>
|
||||||
): [Immutable<T | undefined>, () => JSX.Element] {
|
): [T | undefined, () => JSX.Element] {
|
||||||
const {
|
const {
|
||||||
items,
|
items,
|
||||||
languageExtractor,
|
languageExtractor,
|
||||||
|
@ -63,13 +63,15 @@ export function useSmartLanguage<T>(
|
||||||
);
|
);
|
||||||
}, [preferredLanguages, availableLocales, router.locale]);
|
}, [preferredLanguages, availableLocales, router.locale]);
|
||||||
|
|
||||||
const selectedTranslation = useMemo(
|
const selectedTranslation = useMemo(() => {
|
||||||
() =>
|
if (isDefined(selectedTranslationIndex)) {
|
||||||
isDefined(selectedTranslationIndex)
|
const item = items[selectedTranslationIndex];
|
||||||
? transform(items[selectedTranslationIndex])
|
if (isDefined(item)) {
|
||||||
: undefined,
|
return transform(item);
|
||||||
[items, selectedTranslationIndex, transform]
|
}
|
||||||
);
|
}
|
||||||
|
return undefined;
|
||||||
|
}, [items, selectedTranslationIndex, transform]);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
selectedTranslation,
|
selectedTranslation,
|
||||||
|
|
|
@ -5,12 +5,12 @@ import {
|
||||||
} from "components/PanelComponents/ReturnButton";
|
} from "components/PanelComponents/ReturnButton";
|
||||||
import { ContentPanel } from "components/Panels/ContentPanel";
|
import { ContentPanel } from "components/Panels/ContentPanel";
|
||||||
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { GetStaticPropsContext } from "next";
|
import { GetStaticPropsContext } from "next";
|
||||||
|
|
||||||
interface Props extends AppStaticProps {}
|
interface Props extends AppStaticProps {}
|
||||||
|
|
||||||
export default function FourOhFour(props: Immutable<Props>): JSX.Element {
|
export default function FourOhFour(props: Props): JSX.Element {
|
||||||
const { langui } = props;
|
const { langui } = props;
|
||||||
const contentPanel = (
|
const contentPanel = (
|
||||||
<ContentPanel>
|
<ContentPanel>
|
||||||
|
|
|
@ -5,12 +5,12 @@ import {
|
||||||
} from "components/PanelComponents/ReturnButton";
|
} from "components/PanelComponents/ReturnButton";
|
||||||
import { ContentPanel } from "components/Panels/ContentPanel";
|
import { ContentPanel } from "components/Panels/ContentPanel";
|
||||||
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { GetStaticPropsContext } from "next";
|
import { GetStaticPropsContext } from "next";
|
||||||
|
|
||||||
interface Props extends AppStaticProps {}
|
interface Props extends AppStaticProps {}
|
||||||
|
|
||||||
export default function FiveHundred(props: Immutable<Props>): JSX.Element {
|
export default function FiveHundred(props: Props): JSX.Element {
|
||||||
const { langui } = props;
|
const { langui } = props;
|
||||||
const contentPanel = (
|
const contentPanel = (
|
||||||
<ContentPanel>
|
<ContentPanel>
|
||||||
|
|
|
@ -3,11 +3,8 @@ import {
|
||||||
getPostStaticProps,
|
getPostStaticProps,
|
||||||
PostStaticProps,
|
PostStaticProps,
|
||||||
} from "graphql/getPostStaticProps";
|
} from "graphql/getPostStaticProps";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
|
|
||||||
export default function AccordsHandbook(
|
export default function AccordsHandbook(props: PostStaticProps): JSX.Element {
|
||||||
props: Immutable<PostStaticProps>
|
|
||||||
): JSX.Element {
|
|
||||||
const { post, langui, languages, currencies } = props;
|
const { post, langui, languages, currencies } = props;
|
||||||
return (
|
return (
|
||||||
<PostPage
|
<PostPage
|
||||||
|
|
|
@ -6,14 +6,12 @@ import {
|
||||||
} from "graphql/getPostStaticProps";
|
} from "graphql/getPostStaticProps";
|
||||||
import { cIf, cJoin } from "helpers/className";
|
import { cIf, cJoin } from "helpers/className";
|
||||||
import { randomInt } from "helpers/numbers";
|
import { randomInt } from "helpers/numbers";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { RequestMailProps, ResponseMailProps } from "pages/api/mail";
|
import { RequestMailProps, ResponseMailProps } from "pages/api/mail";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
export default function AboutUs(
|
export default function AboutUs(props: PostStaticProps): JSX.Element {
|
||||||
props: Immutable<PostStaticProps>
|
|
||||||
): JSX.Element {
|
|
||||||
const { post, langui, languages, currencies } = props;
|
const { post, langui, languages, currencies } = props;
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
|
@ -4,12 +4,12 @@ import { NavOption } from "components/PanelComponents/NavOption";
|
||||||
import { PanelHeader } from "components/PanelComponents/PanelHeader";
|
import { PanelHeader } from "components/PanelComponents/PanelHeader";
|
||||||
import { SubPanel } from "components/Panels/SubPanel";
|
import { SubPanel } from "components/Panels/SubPanel";
|
||||||
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { GetStaticPropsContext } from "next";
|
import { GetStaticPropsContext } from "next";
|
||||||
|
|
||||||
interface Props extends AppStaticProps {}
|
interface Props extends AppStaticProps {}
|
||||||
|
|
||||||
export default function AboutUs(props: Immutable<Props>): JSX.Element {
|
export default function AboutUs(props: Props): JSX.Element {
|
||||||
const { langui } = props;
|
const { langui } = props;
|
||||||
const subPanel = (
|
const subPanel = (
|
||||||
<SubPanel>
|
<SubPanel>
|
||||||
|
|
|
@ -3,13 +3,13 @@ import { NavOption } from "components/PanelComponents/NavOption";
|
||||||
import { PanelHeader } from "components/PanelComponents/PanelHeader";
|
import { PanelHeader } from "components/PanelComponents/PanelHeader";
|
||||||
import { SubPanel } from "components/Panels/SubPanel";
|
import { SubPanel } from "components/Panels/SubPanel";
|
||||||
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { GetStaticPropsContext } from "next";
|
import { GetStaticPropsContext } from "next";
|
||||||
import { Icon } from "components/Ico";
|
import { Icon } from "components/Ico";
|
||||||
|
|
||||||
interface Props extends AppStaticProps {}
|
interface Props extends AppStaticProps {}
|
||||||
|
|
||||||
export default function Archives(props: Immutable<Props>): JSX.Element {
|
export default function Archives(props: Props): JSX.Element {
|
||||||
const { langui } = props;
|
const { langui } = props;
|
||||||
const subPanel = (
|
const subPanel = (
|
||||||
<SubPanel>
|
<SubPanel>
|
||||||
|
|
|
@ -2,13 +2,13 @@ import { AppLayout } from "components/AppLayout";
|
||||||
import { PanelHeader } from "components/PanelComponents/PanelHeader";
|
import { PanelHeader } from "components/PanelComponents/PanelHeader";
|
||||||
import { SubPanel } from "components/Panels/SubPanel";
|
import { SubPanel } from "components/Panels/SubPanel";
|
||||||
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { GetStaticPropsContext } from "next";
|
import { GetStaticPropsContext } from "next";
|
||||||
import { Icon } from "components/Ico";
|
import { Icon } from "components/Ico";
|
||||||
|
|
||||||
interface Props extends AppStaticProps {}
|
interface Props extends AppStaticProps {}
|
||||||
|
|
||||||
export default function Chronicles(props: Immutable<Props>): JSX.Element {
|
export default function Chronicles(props: Props): JSX.Element {
|
||||||
const { langui } = props;
|
const { langui } = props;
|
||||||
const subPanel = (
|
const subPanel = (
|
||||||
<SubPanel>
|
<SubPanel>
|
||||||
|
|
|
@ -27,7 +27,7 @@ import {
|
||||||
} from "helpers/formatters";
|
} from "helpers/formatters";
|
||||||
import { isUntangibleGroupItem } from "helpers/libraryItem";
|
import { isUntangibleGroupItem } from "helpers/libraryItem";
|
||||||
import { getStatusDescription } from "helpers/others";
|
import { getStatusDescription } from "helpers/others";
|
||||||
import { ContentWithTranslations, Immutable } from "helpers/types";
|
import { ContentWithTranslations } from "helpers/types";
|
||||||
import { useMediaMobile } from "hooks/useMediaQuery";
|
import { useMediaMobile } from "hooks/useMediaQuery";
|
||||||
import { AnchorIds, useScrollTopOnChange } from "hooks/useScrollTopOnChange";
|
import { AnchorIds, useScrollTopOnChange } from "hooks/useScrollTopOnChange";
|
||||||
import { useSmartLanguage } from "hooks/useSmartLanguage";
|
import { useSmartLanguage } from "hooks/useSmartLanguage";
|
||||||
|
@ -42,7 +42,7 @@ interface Props extends AppStaticProps {
|
||||||
content: ContentWithTranslations;
|
content: ContentWithTranslations;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Content(props: Immutable<Props>): JSX.Element {
|
export default function Content(props: Props): JSX.Element {
|
||||||
const { langui, content, languages, currencies } = props;
|
const { langui, content, languages, currencies } = props;
|
||||||
const isMobile = useMediaMobile();
|
const isMobile = useMediaMobile();
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ import { GetContentsQuery } from "graphql/generated";
|
||||||
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
||||||
import { getReadySdk } from "graphql/sdk";
|
import { getReadySdk } from "graphql/sdk";
|
||||||
import { prettyinlineTitle, prettySlug } from "helpers/formatters";
|
import { prettyinlineTitle, prettySlug } from "helpers/formatters";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { GetStaticPropsContext } from "next";
|
import { GetStaticPropsContext } from "next";
|
||||||
import { Fragment, useState, useMemo } from "react";
|
import { Fragment, useState, useMemo } from "react";
|
||||||
import { Icon } from "components/Ico";
|
import { Icon } from "components/Ico";
|
||||||
|
@ -26,7 +26,7 @@ interface Props extends AppStaticProps {
|
||||||
contents: NonNullable<GetContentsQuery["contents"]>["data"];
|
contents: NonNullable<GetContentsQuery["contents"]>["data"];
|
||||||
}
|
}
|
||||||
|
|
||||||
type GroupContentItems = Map<string, Immutable<Props["contents"]>>;
|
type GroupContentItems = Map<string, Props["contents"]>;
|
||||||
|
|
||||||
const defaultFiltersState = {
|
const defaultFiltersState = {
|
||||||
groupingMethod: -1,
|
groupingMethod: -1,
|
||||||
|
@ -35,7 +35,7 @@ const defaultFiltersState = {
|
||||||
searchName: "",
|
searchName: "",
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function Contents(props: Immutable<Props>): JSX.Element {
|
export default function Contents(props: Props): JSX.Element {
|
||||||
const { langui, contents, languages } = props;
|
const { langui, contents, languages } = props;
|
||||||
const hoverable = useMediaHoverable();
|
const hoverable = useMediaHoverable();
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ export async function getStaticProps(
|
||||||
function getGroups(
|
function getGroups(
|
||||||
langui: AppStaticProps["langui"],
|
langui: AppStaticProps["langui"],
|
||||||
groupByType: number,
|
groupByType: number,
|
||||||
items: Immutable<Props["contents"]>
|
items: Props["contents"]
|
||||||
): GroupContentItems {
|
): GroupContentItems {
|
||||||
switch (groupByType) {
|
switch (groupByType) {
|
||||||
case 0: {
|
case 0: {
|
||||||
|
|
|
@ -9,14 +9,14 @@ import { ToolTip } from "components/ToolTip";
|
||||||
import { DevGetContentsQuery } from "graphql/generated";
|
import { DevGetContentsQuery } from "graphql/generated";
|
||||||
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
||||||
import { getReadySdk } from "graphql/sdk";
|
import { getReadySdk } from "graphql/sdk";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { GetStaticPropsContext } from "next";
|
import { GetStaticPropsContext } from "next";
|
||||||
|
|
||||||
interface Props extends AppStaticProps {
|
interface Props extends AppStaticProps {
|
||||||
contents: DevGetContentsQuery;
|
contents: DevGetContentsQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function CheckupContents(props: Immutable<Props>): JSX.Element {
|
export default function CheckupContents(props: Props): JSX.Element {
|
||||||
const { contents } = props;
|
const { contents } = props;
|
||||||
const testReport = testingContent(contents);
|
const testReport = testingContent(contents);
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ type ReportLine = {
|
||||||
frontendUrl: string;
|
frontendUrl: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
function testingContent(contents: Immutable<Props["contents"]>): Report {
|
function testingContent(contents: Props["contents"]): Report {
|
||||||
const report: Report = {
|
const report: Report = {
|
||||||
title: "Contents",
|
title: "Contents",
|
||||||
lines: [],
|
lines: [],
|
||||||
|
|
|
@ -12,16 +12,14 @@ import {
|
||||||
} from "graphql/generated";
|
} from "graphql/generated";
|
||||||
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
||||||
import { getReadySdk } from "graphql/sdk";
|
import { getReadySdk } from "graphql/sdk";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { GetStaticPropsContext } from "next";
|
import { GetStaticPropsContext } from "next";
|
||||||
|
|
||||||
interface Props extends AppStaticProps {
|
interface Props extends AppStaticProps {
|
||||||
libraryItems: DevGetLibraryItemsQuery;
|
libraryItems: DevGetLibraryItemsQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function CheckupLibraryItems(
|
export default function CheckupLibraryItems(props: Props): JSX.Element {
|
||||||
props: Immutable<Props>
|
|
||||||
): JSX.Element {
|
|
||||||
const { libraryItems } = props;
|
const { libraryItems } = props;
|
||||||
const testReport = testingLibraryItem(libraryItems);
|
const testReport = testingLibraryItem(libraryItems);
|
||||||
|
|
||||||
|
@ -115,9 +113,7 @@ type ReportLine = {
|
||||||
frontendUrl: string;
|
frontendUrl: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
function testingLibraryItem(
|
function testingLibraryItem(libraryItems: Props["libraryItems"]): Report {
|
||||||
libraryItems: Immutable<Props["libraryItems"]>
|
|
||||||
): Report {
|
|
||||||
const report: Report = {
|
const report: Report = {
|
||||||
title: "Contents",
|
title: "Contents",
|
||||||
lines: [],
|
lines: [],
|
||||||
|
|
|
@ -8,7 +8,7 @@ import {
|
||||||
import { Popup } from "components/Popup";
|
import { Popup } from "components/Popup";
|
||||||
import { ToolTip } from "components/ToolTip";
|
import { ToolTip } from "components/ToolTip";
|
||||||
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { GetStaticPropsContext } from "next";
|
import { GetStaticPropsContext } from "next";
|
||||||
import { useCallback, useState } from "react";
|
import { useCallback, useState } from "react";
|
||||||
import TurndownService from "turndown";
|
import TurndownService from "turndown";
|
||||||
|
@ -17,7 +17,7 @@ import { TOC } from "components/Markdown/TOC";
|
||||||
|
|
||||||
interface Props extends AppStaticProps {}
|
interface Props extends AppStaticProps {}
|
||||||
|
|
||||||
export default function Editor(props: Immutable<Props>): JSX.Element {
|
export default function Editor(props: Props): JSX.Element {
|
||||||
const handleInput = useCallback((text: string) => {
|
const handleInput = useCallback((text: string) => {
|
||||||
setMarkdown(text);
|
setMarkdown(text);
|
||||||
}, []);
|
}, []);
|
||||||
|
@ -62,19 +62,20 @@ export default function Editor(props: Immutable<Props>): JSX.Element {
|
||||||
properties?: Record<string, string>,
|
properties?: Record<string, string>,
|
||||||
addInnerNewLines?: boolean
|
addInnerNewLines?: boolean
|
||||||
) {
|
) {
|
||||||
const textarea = document.querySelector(
|
const textarea =
|
||||||
"#editorTextArea"
|
document.querySelector<HTMLTextAreaElement>("#editorTextArea");
|
||||||
) as HTMLTextAreaElement;
|
if (textarea) {
|
||||||
const { value, selectionStart, selectionEnd } = textarea;
|
const { value, selectionStart, selectionEnd } = textarea;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
value.slice(selectionStart - wrapper.length, selectionStart) ===
|
value.slice(selectionStart - wrapper.length, selectionStart) ===
|
||||||
wrapper &&
|
wrapper &&
|
||||||
value.slice(selectionEnd, selectionEnd + wrapper.length) === wrapper
|
value.slice(selectionEnd, selectionEnd + wrapper.length) === wrapper
|
||||||
) {
|
) {
|
||||||
unwrap(wrapper);
|
unwrap(wrapper);
|
||||||
} else {
|
} else {
|
||||||
wrap(wrapper, properties, addInnerNewLines);
|
wrap(wrapper, properties, addInnerNewLines);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,23 +127,24 @@ export default function Editor(props: Immutable<Props>): JSX.Element {
|
||||||
selectedEnd: number
|
selectedEnd: number
|
||||||
) => { prependLength: number; transformedValue: string }
|
) => { prependLength: number; transformedValue: string }
|
||||||
) {
|
) {
|
||||||
const textarea = document.querySelector(
|
const textarea =
|
||||||
"#editorTextArea"
|
document.querySelector<HTMLTextAreaElement>("#editorTextArea");
|
||||||
) as HTMLTextAreaElement;
|
if (textarea) {
|
||||||
const { value, selectionStart, selectionEnd } = textarea;
|
const { value, selectionStart, selectionEnd } = textarea;
|
||||||
|
|
||||||
const { prependLength, transformedValue } = transformation(
|
const { prependLength, transformedValue } = transformation(
|
||||||
value,
|
value,
|
||||||
selectionStart,
|
selectionStart,
|
||||||
selectionEnd
|
selectionEnd
|
||||||
);
|
);
|
||||||
|
|
||||||
textarea.value = transformedValue;
|
textarea.value = transformedValue;
|
||||||
handleInput(textarea.value);
|
handleInput(textarea.value);
|
||||||
|
|
||||||
textarea.focus();
|
textarea.focus();
|
||||||
textarea.selectionStart = selectionStart + prependLength;
|
textarea.selectionStart = selectionStart + prependLength;
|
||||||
textarea.selectionEnd = selectionEnd + prependLength;
|
textarea.selectionEnd = selectionEnd + prependLength;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const contentPanel = (
|
const contentPanel = (
|
||||||
|
|
|
@ -3,9 +3,8 @@ import {
|
||||||
getPostStaticProps,
|
getPostStaticProps,
|
||||||
PostStaticProps,
|
PostStaticProps,
|
||||||
} from "graphql/getPostStaticProps";
|
} from "graphql/getPostStaticProps";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
|
|
||||||
export default function Home(props: Immutable<PostStaticProps>): JSX.Element {
|
export default function Home(props: PostStaticProps): JSX.Element {
|
||||||
const { post, langui, languages, currencies } = props;
|
const { post, langui, languages, currencies } = props;
|
||||||
return (
|
return (
|
||||||
<PostPage
|
<PostPage
|
||||||
|
|
|
@ -36,7 +36,7 @@ import {
|
||||||
import { getAssetURL, ImageQuality } from "helpers/img";
|
import { getAssetURL, ImageQuality } from "helpers/img";
|
||||||
import { convertMmToInch } from "helpers/numbers";
|
import { convertMmToInch } from "helpers/numbers";
|
||||||
import { isDefined, sortContent } from "helpers/others";
|
import { isDefined, sortContent } from "helpers/others";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { useLightBox } from "hooks/useLightBox";
|
import { useLightBox } from "hooks/useLightBox";
|
||||||
import { AnchorIds, useScrollTopOnChange } from "hooks/useScrollTopOnChange";
|
import { AnchorIds, useScrollTopOnChange } from "hooks/useScrollTopOnChange";
|
||||||
import {
|
import {
|
||||||
|
@ -58,7 +58,7 @@ interface Props extends AppStaticProps {
|
||||||
>["data"][number]["id"];
|
>["data"][number]["id"];
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function LibrarySlug(props: Immutable<Props>): JSX.Element {
|
export default function LibrarySlug(props: Props): JSX.Element {
|
||||||
const { item, itemId, langui, currencies } = props;
|
const { item, itemId, langui, currencies } = props;
|
||||||
const appLayout = useAppLayout();
|
const appLayout = useAppLayout();
|
||||||
const hoverable = useMediaHoverable();
|
const hoverable = useMediaHoverable();
|
||||||
|
|
|
@ -16,7 +16,7 @@ import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
||||||
import { getReadySdk } from "graphql/sdk";
|
import { getReadySdk } from "graphql/sdk";
|
||||||
import { prettyinlineTitle, prettySlug } from "helpers/formatters";
|
import { prettyinlineTitle, prettySlug } from "helpers/formatters";
|
||||||
import { isDefined, sortContent } from "helpers/others";
|
import { isDefined, sortContent } from "helpers/others";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { useLightBox } from "hooks/useLightBox";
|
import { useLightBox } from "hooks/useLightBox";
|
||||||
import {
|
import {
|
||||||
GetStaticPathsContext,
|
GetStaticPathsContext,
|
||||||
|
@ -34,7 +34,7 @@ interface Props extends AppStaticProps {
|
||||||
>["data"][number]["id"];
|
>["data"][number]["id"];
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function LibrarySlug(props: Immutable<Props>): JSX.Element {
|
export default function LibrarySlug(props: Props): JSX.Element {
|
||||||
const { item, langui, languages } = props;
|
const { item, langui, languages } = props;
|
||||||
const [openLightBox, LightBox] = useLightBox();
|
const [openLightBox, LightBox] = useLightBox();
|
||||||
sortContent(item?.contents);
|
sortContent(item?.contents);
|
||||||
|
|
|
@ -12,7 +12,7 @@ import { GetLibraryItemsPreviewQuery } from "graphql/generated";
|
||||||
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
||||||
import { getReadySdk } from "graphql/sdk";
|
import { getReadySdk } from "graphql/sdk";
|
||||||
import { prettyItemSubType } from "helpers/formatters";
|
import { prettyItemSubType } from "helpers/formatters";
|
||||||
import { Immutable, LibraryItemUserStatus } from "helpers/types";
|
import { LibraryItemUserStatus } from "helpers/types";
|
||||||
import { GetStaticPropsContext } from "next";
|
import { GetStaticPropsContext } from "next";
|
||||||
import { Fragment, useState, useMemo } from "react";
|
import { Fragment, useState, useMemo } from "react";
|
||||||
import { Icon } from "components/Ico";
|
import { Icon } from "components/Ico";
|
||||||
|
@ -48,7 +48,7 @@ const defaultFiltersState = {
|
||||||
filterUserStatus: undefined,
|
filterUserStatus: undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function Library(props: Immutable<Props>): JSX.Element {
|
export default function Library(props: Props): JSX.Element {
|
||||||
const { langui, items: libraryItems, currencies } = props;
|
const { langui, items: libraryItems, currencies } = props;
|
||||||
const appLayout = useAppLayout();
|
const appLayout = useAppLayout();
|
||||||
const hoverable = useMediaHoverable();
|
const hoverable = useMediaHoverable();
|
||||||
|
|
|
@ -2,12 +2,12 @@ import { AppLayout } from "components/AppLayout";
|
||||||
import { PanelHeader } from "components/PanelComponents/PanelHeader";
|
import { PanelHeader } from "components/PanelComponents/PanelHeader";
|
||||||
import { SubPanel } from "components/Panels/SubPanel";
|
import { SubPanel } from "components/Panels/SubPanel";
|
||||||
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { GetStaticPropsContext } from "next";
|
import { GetStaticPropsContext } from "next";
|
||||||
import { Icon } from "components/Ico";
|
import { Icon } from "components/Ico";
|
||||||
|
|
||||||
interface Props extends AppStaticProps {}
|
interface Props extends AppStaticProps {}
|
||||||
export default function Merch(props: Immutable<Props>): JSX.Element {
|
export default function Merch(props: Props): JSX.Element {
|
||||||
const { langui } = props;
|
const { langui } = props;
|
||||||
const subPanel = (
|
const subPanel = (
|
||||||
<SubPanel>
|
<SubPanel>
|
||||||
|
|
|
@ -6,7 +6,7 @@ import {
|
||||||
} from "graphql/getPostStaticProps";
|
} from "graphql/getPostStaticProps";
|
||||||
import { getReadySdk } from "graphql/sdk";
|
import { getReadySdk } from "graphql/sdk";
|
||||||
import { isDefined } from "helpers/others";
|
import { isDefined } from "helpers/others";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import {
|
import {
|
||||||
GetStaticPathsContext,
|
GetStaticPathsContext,
|
||||||
GetStaticPathsResult,
|
GetStaticPathsResult,
|
||||||
|
@ -15,7 +15,7 @@ import {
|
||||||
|
|
||||||
interface Props extends AppStaticProps, PostStaticProps {}
|
interface Props extends AppStaticProps, PostStaticProps {}
|
||||||
|
|
||||||
export default function LibrarySlug(props: Immutable<Props>): JSX.Element {
|
export default function LibrarySlug(props: Props): JSX.Element {
|
||||||
const { post, langui, languages, currencies } = props;
|
const { post, langui, languages, currencies } = props;
|
||||||
return (
|
return (
|
||||||
<PostPage
|
<PostPage
|
||||||
|
|
|
@ -11,7 +11,7 @@ import { GetPostsPreviewQuery } from "graphql/generated";
|
||||||
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
||||||
import { getReadySdk } from "graphql/sdk";
|
import { getReadySdk } from "graphql/sdk";
|
||||||
import { prettyDate, prettySlug } from "helpers/formatters";
|
import { prettyDate, prettySlug } from "helpers/formatters";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { GetStaticPropsContext } from "next";
|
import { GetStaticPropsContext } from "next";
|
||||||
import { Fragment, useMemo, useState } from "react";
|
import { Fragment, useMemo, useState } from "react";
|
||||||
import { Icon } from "components/Ico";
|
import { Icon } from "components/Ico";
|
||||||
|
@ -29,7 +29,7 @@ const defaultFiltersState = {
|
||||||
keepInfoVisible: true,
|
keepInfoVisible: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function News(props: Immutable<Props>): JSX.Element {
|
export default function News(props: Props): JSX.Element {
|
||||||
const { langui } = props;
|
const { langui } = props;
|
||||||
const posts = sortPosts(props.posts);
|
const posts = sortPosts(props.posts);
|
||||||
const hoverable = useMediaHoverable();
|
const hoverable = useMediaHoverable();
|
||||||
|
@ -144,10 +144,8 @@ export async function getStaticProps(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function sortPosts(
|
function sortPosts(posts: Props["posts"]): Props["posts"] {
|
||||||
posts: Immutable<Props["posts"]>
|
const sortedPosts = [...posts];
|
||||||
): Immutable<Props["posts"]> {
|
|
||||||
const sortedPosts = [...posts] as Props["posts"];
|
|
||||||
sortedPosts
|
sortedPosts
|
||||||
.sort((a, b) => {
|
.sort((a, b) => {
|
||||||
const dateA = a.attributes?.date ? prettyDate(a.attributes.date) : "9999";
|
const dateA = a.attributes?.date ? prettyDate(a.attributes.date) : "9999";
|
||||||
|
@ -155,10 +153,10 @@ function sortPosts(
|
||||||
return dateA.localeCompare(dateB);
|
return dateA.localeCompare(dateB);
|
||||||
})
|
})
|
||||||
.reverse();
|
.reverse();
|
||||||
return sortedPosts as Immutable<Props["posts"]>;
|
return sortedPosts;
|
||||||
}
|
}
|
||||||
|
|
||||||
function filterItems(posts: Immutable<Props["posts"]>, searchName: string) {
|
function filterItems(posts: Props["posts"], searchName: string) {
|
||||||
return [...posts].filter((post) => {
|
return [...posts].filter((post) => {
|
||||||
if (searchName.length > 1) {
|
if (searchName.length > 1) {
|
||||||
if (
|
if (
|
||||||
|
|
|
@ -15,7 +15,7 @@ import DefinitionCard from "components/Wiki/DefinitionCard";
|
||||||
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
||||||
import { getReadySdk } from "graphql/sdk";
|
import { getReadySdk } from "graphql/sdk";
|
||||||
import { isDefined, isDefinedAndNotEmpty } from "helpers/others";
|
import { isDefined, isDefinedAndNotEmpty } from "helpers/others";
|
||||||
import { Immutable, WikiPageWithTranslations } from "helpers/types";
|
import { WikiPageWithTranslations } from "helpers/types";
|
||||||
import { useSmartLanguage } from "hooks/useSmartLanguage";
|
import { useSmartLanguage } from "hooks/useSmartLanguage";
|
||||||
import {
|
import {
|
||||||
GetStaticPathsContext,
|
GetStaticPathsContext,
|
||||||
|
@ -27,7 +27,7 @@ interface Props extends AppStaticProps {
|
||||||
page: WikiPageWithTranslations;
|
page: WikiPageWithTranslations;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function WikiPage(props: Immutable<Props>): JSX.Element {
|
export default function WikiPage(props: Props): JSX.Element {
|
||||||
const { page, langui, languages } = props;
|
const { page, langui, languages } = props;
|
||||||
|
|
||||||
const [selectedTranslation, LanguageSwitcher] = useSmartLanguage({
|
const [selectedTranslation, LanguageSwitcher] = useSmartLanguage({
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { NavOption } from "components/PanelComponents/NavOption";
|
||||||
import { PanelHeader } from "components/PanelComponents/PanelHeader";
|
import { PanelHeader } from "components/PanelComponents/PanelHeader";
|
||||||
import { SubPanel } from "components/Panels/SubPanel";
|
import { SubPanel } from "components/Panels/SubPanel";
|
||||||
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
||||||
import { Immutable } from "helpers/types";
|
|
||||||
import { GetStaticPropsContext } from "next";
|
import { GetStaticPropsContext } from "next";
|
||||||
import { Icon } from "components/Ico";
|
import { Icon } from "components/Ico";
|
||||||
import { getReadySdk } from "graphql/sdk";
|
import { getReadySdk } from "graphql/sdk";
|
||||||
|
@ -30,7 +30,7 @@ const defaultFiltersState = {
|
||||||
keepInfoVisible: true,
|
keepInfoVisible: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function Wiki(props: Immutable<Props>): JSX.Element {
|
export default function Wiki(props: Props): JSX.Element {
|
||||||
const { langui, languages } = props;
|
const { langui, languages } = props;
|
||||||
const pages = sortPages(props.pages);
|
const pages = sortPages(props.pages);
|
||||||
const hoverable = useMediaHoverable();
|
const hoverable = useMediaHoverable();
|
||||||
|
@ -149,19 +149,17 @@ export async function getStaticProps(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function sortPages(
|
function sortPages(pages: Props["pages"]): Props["pages"] {
|
||||||
pages: Immutable<Props["pages"]>
|
const sortedPages = [...pages];
|
||||||
): Immutable<Props["pages"]> {
|
|
||||||
const sortedPages = [...pages] as Props["pages"];
|
|
||||||
sortedPages.sort((a, b) => {
|
sortedPages.sort((a, b) => {
|
||||||
const slugA = a.attributes?.slug ?? "";
|
const slugA = a.attributes?.slug ?? "";
|
||||||
const slugB = b.attributes?.slug ?? "";
|
const slugB = b.attributes?.slug ?? "";
|
||||||
return slugA.localeCompare(slugB);
|
return slugA.localeCompare(slugB);
|
||||||
});
|
});
|
||||||
return sortedPages as Immutable<Props["pages"]>;
|
return sortedPages;
|
||||||
}
|
}
|
||||||
|
|
||||||
function filterPages(posts: Immutable<Props["pages"]>, searchName: string) {
|
function filterPages(posts: Props["pages"], searchName: string) {
|
||||||
return [...posts].filter((post) => {
|
return [...posts].filter((post) => {
|
||||||
if (searchName.length > 1) {
|
if (searchName.length > 1) {
|
||||||
if (
|
if (
|
||||||
|
|
Loading…
Reference in New Issue