1
0
Fork 0
freesewing/sites/org/pages/support.mjs

188 lines
6.3 KiB
JavaScript
Raw Normal View History

2023-08-01 21:03:24 +02:00
// Dependencies
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
import { nsMerge } from 'shared/utils.mjs'
2023-08-23 21:02:05 +02:00
import { freeSewingConfig as config } from 'shared/config/freesewing.config.mjs'
2023-08-01 21:03:24 +02:00
// Hooks
import { useTranslation } from 'next-i18next'
2023-08-23 21:02:05 +02:00
import { useState } from 'react'
2023-08-01 21:03:24 +02:00
// Components
import { PageWrapper, ns as pageNs } from 'shared/components/wrappers/page.mjs'
import { Joost } from 'shared/components/joost.mjs'
2023-08-23 21:02:05 +02:00
import { BareLayout } from 'site/components/layouts/bare.mjs'
import { Breadcrumbs } from 'shared/components/navigation/sitenav.mjs'
import {
DiscordIcon,
FacebookIcon,
GitHubIcon,
InstagramIcon,
RedditIcon,
2023-11-03 19:41:21 +01:00
MastodonIcon,
2023-08-23 21:02:05 +02:00
YouTubeIcon,
2023-08-24 17:49:35 +02:00
CommunityIcon,
ChatIcon,
EmailIcon,
2023-08-23 21:02:05 +02:00
} from 'shared/components/icons.mjs'
import { PleaseSubscribe, ns as subNs } from 'shared/components/patrons/please-subscribe.mjs'
2023-08-24 17:49:35 +02:00
import { SupportForm, ns as supportNs } from 'shared/components/support.mjs'
2023-08-01 21:03:24 +02:00
// Translation namespaces used on this page
const ns = nsMerge(pageNs, supportNs, subNs)
2023-08-01 21:03:24 +02:00
2023-08-24 17:50:55 +02:00
const SupportCard = ({ bg, textColor, title, icon, nr }) => (
2023-08-24 17:49:35 +02:00
<div
className={`px-4 bg-${bg} pt-2 pb-4 rounded-lg block ${textColor} shadow-lg
grow w-full bg-gradient-to-tr from-${bg} from-10% to-primary`}
>
<h3 className="text-inherit font-heavy flex flex-row w-full items-center justify-between relative">
<span
className={`p-2 w-8 h-8 flex flex-col items-center justify-center shrink-0 rounded-full
text-center p-0 py-2 bg-transparent text-${bg}-content border-2 border-base-100 text-xl mr-4`}
>
{nr}
</span>
2023-08-23 21:02:05 +02:00
{title}
2023-08-01 21:03:24 +02:00
{icon}
2023-08-23 21:02:05 +02:00
</h3>
</div>
2023-08-01 21:03:24 +02:00
)
2023-08-23 21:02:05 +02:00
const socialIcon = {
2023-11-03 19:41:21 +01:00
mastodon: <MastodonIcon />,
github: <GitHubIcon />,
2023-08-23 21:02:05 +02:00
discord: <DiscordIcon />,
facebook: <FacebookIcon />,
instagram: <InstagramIcon />,
reddit: <RedditIcon />,
youtube: <YouTubeIcon fill stroke={0} />,
}
2023-08-01 21:03:24 +02:00
/*
* Each page MUST be wrapped in the PageWrapper component.
* You also MUST spread props.page into this wrapper component
* when path and locale come from static props (as here)
* or set them manually.
*/
const SupportPage = ({ page }) => {
2023-08-24 17:49:35 +02:00
const { t } = useTranslation(ns)
2023-08-23 21:02:05 +02:00
2023-08-27 16:41:12 +02:00
const [request, setRequest] = useState(false)
2023-08-23 21:02:05 +02:00
2023-08-24 17:49:35 +02:00
const pageTitle = request ? t('createSupportRequest') : t('sections:support')
2023-08-23 21:02:05 +02:00
2023-08-24 17:49:35 +02:00
if (request)
2023-08-23 21:02:05 +02:00
return (
<PageWrapper {...page} title={pageTitle} layout={BareLayout}>
2023-08-24 17:49:35 +02:00
<div className="max-w-7xl mx-auto mb-24 px-4 mt-16">
2023-08-23 21:02:05 +02:00
<Breadcrumbs />
<h1>{pageTitle}</h1>
2023-08-24 17:49:35 +02:00
<SupportForm />
2023-08-23 21:02:05 +02:00
</div>
</PageWrapper>
)
2023-08-01 21:03:24 +02:00
return (
2023-08-23 21:02:05 +02:00
<PageWrapper {...page} title={pageTitle} layout={BareLayout}>
<div className="max-w-7xl mx-auto mb-24 px-4 mt-16">
<Breadcrumbs />
<h1>{pageTitle}</h1>
2023-11-03 19:41:21 +01:00
<h2>{t('support:howCanWeSupportYou')}</h2>
2023-08-24 17:49:35 +02:00
<div className="flex flex-row flex-wrap gap-4 lg:grid lg:grid-cols-3 lg:gap-8 justify-around -mt-4">
2023-08-23 21:02:05 +02:00
{/* Community */}
<div className="w-full md:max-w-md my-8">
<SupportCard
2023-08-24 17:49:35 +02:00
nr={1}
bg="accent"
textColor="text-accent-content"
2023-08-23 21:02:05 +02:00
title={t('support:communitySupport')}
2023-08-24 17:49:35 +02:00
icon={<CommunityIcon className="w-10 h-10 lg:w-14 lg:h-14 shrink-0" />}
2023-08-23 21:02:05 +02:00
/>
2023-11-03 19:41:21 +01:00
<p
className="font-normal text-inherit"
dangerouslySetInnerHTML={{ __html: t('support:communitySupport1') }}
/>
2023-08-23 21:02:05 +02:00
<p className="font-normal text-inherit">{t('support:communitySupport2')}</p>
<div className="grid grid-cols-2 gap-2">
{Object.keys(config.social)
.sort()
.map((key) => (
<a
2023-08-24 17:49:35 +02:00
className="btn btn-neutral btn-outline w-full flex flex-row items-center justify-between hover:btn-accent"
2023-08-23 21:02:05 +02:00
href={config.social[key]}
key={key}
>
{socialIcon[key.toLowerCase()]}
{key}
</a>
))}
</div>
</div>
2023-08-01 21:03:24 +02:00
2023-08-23 21:02:05 +02:00
{/* Contributors */}
<div className="w-full md:max-w-md my-8">
<SupportCard
2023-08-24 17:49:35 +02:00
nr={2}
bg="secondary"
textColor="text-secondary-content"
2023-08-23 21:02:05 +02:00
title={t('support:contributorSupport')}
2023-08-24 17:49:35 +02:00
icon={<GitHubIcon className="w-10 h-10 lg:w-14 lg:h-14 shrink-0" />}
2023-08-23 21:02:05 +02:00
/>
<p
className="font-medium text-inherit text-lg"
dangerouslySetInnerHTML={{ __html: t('support:contributorSupport1') }}
/>
<p className="font-normal text-inherit">{t('support:contributorSupport2')}</p>
2023-08-24 17:49:35 +02:00
<button
className="btn btn-secondary btn-lg w-full flex flex-row items-center justify-between"
onClick={() => setRequest(true)}
>
<ChatIcon className="w-8 h-8" />
2023-08-23 21:02:05 +02:00
{t('createSupportRequest')}
</button>
</div>
2023-08-01 21:03:24 +02:00
2023-08-23 21:02:05 +02:00
{/* Maintainer */}
<div className="w-full md:max-w-md my-8">
<SupportCard
2023-08-24 17:49:35 +02:00
nr={3}
bg="neutral"
textColor="text-neutral-content"
2023-08-23 21:02:05 +02:00
title={t('support:maintainerSupport')}
2023-08-24 17:49:35 +02:00
icon={<Joost className="w-20 lg:w-28 shrink-0" stroke={1} />}
2023-08-23 21:02:05 +02:00
/>
<p
className="font-medium text-inherit text-lg"
dangerouslySetInnerHTML={{ __html: t('support:maintainerSupport1') }}
/>
<p className="font-normal text-inherit">{t('support:maintainerSupport2')}</p>
2023-08-24 17:49:35 +02:00
<a
className="btn btn-neutral w-full flex flex-row items-center justify-between"
href="mailto:joost@joost.at"
>
<EmailIcon className="w-8 h-8" />
{t('emailAddress', { address: 'joost@joost.at' })}
</a>
2023-08-23 21:02:05 +02:00
</div>
</div>
2023-08-24 17:49:35 +02:00
<h2 className="pb-8">{t('howCanYouSupportFreeSewing')}</h2>
<div className="-mx-4 md:mx-auto">
<PleaseSubscribe dense />
</div>
2023-08-01 21:03:24 +02:00
</div>
</PageWrapper>
)
}
export default SupportPage
export async function getStaticProps({ locale }) {
return {
props: {
2023-08-24 17:49:35 +02:00
...(await serverSideTranslations(locale, ns)),
2023-08-01 21:03:24 +02:00
page: {
locale,
path: ['patrons', 'thanks'],
},
},
}
}