core/components/ReportTemplate.tsx
2024-07-26 15:07:57 +09:00

128 lines
4.2 KiB
TypeScript

import { FC, useState } from 'react'
import dynamic from 'next/dynamic'
import { FormikErrors, FormikTouched } from 'formik'
const Button = dynamic(() => import('@components/Button'))
const TextArea = dynamic(() => import('@components/Form/TextArea'))
export const Check: FC<{ checked: boolean; text: string }> = ({ checked, text }) => (
<>
{checked && <i className='fas fa-check-circle mr-1 text-emerald-400' />}
{text}
</>
)
export const SubmitButton: FC = () => (
<div className='text-right'>
<Button type='submit'></Button>
</div>
)
export const TextField: FC<ReportTemplateProps> = ({ values, errors, touched, setFieldValue }) => (
<>
<TextArea
name='description'
placeholder='최대한 자세하게 설명해주세요!'
value={values.description}
setValue={(value) => setFieldValue('description', value)}
/>
<div className='mt-1 text-xs font-light text-red-500'>
{errors.description && touched.description ? errors.description : null}
</div>
<SubmitButton />
</>
)
export const DMCA: FC<ReportTemplateProps> = ({ values, errors, touched, setFieldValue }) => {
const [isOwner, setOwner] = useState(null)
const [contacted, setContacted] = useState(null)
return (
<div>
<h3 className='my-2 font-bold'> ?</h3>
<Button onClick={() => setOwner(true)}>
<Check checked={isOwner} text='권리자 본인 혹은 대리인입니다.' />
</Button>
<Button onClick={() => setOwner(false)}>
<Check checked={isOwner === false} text='권리자가 아닙니다.' />
</Button>
{isOwner === true ? (
<>
<h3 className='my-2 font-bold'>
?
</h3>
<Button onClick={() => setContacted(true)}>
<Check checked={contacted} text='최대한 연락을 시도하였지만 개선되지 않았습니다.' />
</Button>
<Button onClick={() => setContacted(false)}>
<Check checked={contacted === false} text='아니요, 아직 연락하지 않았습니다.' />
</Button>
{contacted ? (
<div>
<h3 className='mt-2 font-bold'></h3>
<p className='mb-1 text-sm text-gray-400'> .</p>
<ul className='mb-1 list-inside list-disc text-sm text-gray-400'>
<li>
(
)
</li>
<li> ( , )</li>
</ul>
<p className='mb-1 text-sm text-gray-400'>
{' '}
<a
className='text-blue-400'
target='_blank'
rel='noreferrer'
href={`mailto:dmca@koreanbots.dev?subject=${encodeURI(
'[DMCA] 추가 콘텐츠'
)}&body=${encodeURI('디스코드 태그:')}`}
>
dmca@koreanbots.dev
</a>
, .
</p>
<TextField
values={values}
errors={errors}
touched={touched}
setFieldValue={setFieldValue}
/>
</div>
) : contacted === false ? (
<>
<h2 className='mt-4 text-xl font-bold'> .</h2>
<p>
,
.
</p>
</>
) : (
''
)}
</>
) : isOwner === false ? (
<>
<h2 className='mt-4 text-xl font-bold'>
, .
</h2>
<p> , !</p>
</>
) : (
''
)}
</div>
)
}
interface ReportValues {
category: string | null
description: string
_csrf: string
}
interface ReportTemplateProps {
values?: ReportValues
errors?: FormikErrors<ReportValues>
touched?: FormikTouched<ReportValues>
setFieldValue?(field: string, value: unknown): void
}