core/components/ReportTemplate.tsx
SKINMAKER bec6aa3554
chore: deps (#566)
* chore: remove zlib-sync

* chore: pin version of @types/react

* chore: remove next-session

* chore: update tailwind

* chore: update tailwind

* chore: update lint

* chore: remove abort-controller

* chore: regen lock file

* fix: remove transparent

* chore: set plugin to not mutate existing style
2023-06-20 12:59:42 +09:00

78 lines
3.9 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='text-emerald-400 fas fa-check-circle mr-1' />}
{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-red-500 text-xs font-light'>{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='font-bold my-2'> ?</h3>
<Button onClick={() => setOwner(true)}>
<Check checked={isOwner} text='권리자 본인 혹은 대리인입니다.' />
</Button>
<Button onClick={() => setOwner(false)}>
<Check checked={isOwner === false} text='권리자가 아닙니다.' />
</Button>
{
isOwner === true ? <>
<h3 className='font-bold my-2'> ?</h3>
<Button onClick={() => setContacted(true)}>
<Check checked={contacted} text='최대한 연락을 시도하였지만 개선되지 않았습니다.' />
</Button>
<Button onClick={() => setContacted(false)}>
<Check checked={contacted === false} text='아니요, 아직 연락하지 않았습니다.' />
</Button>
{
contacted ? <div>
<h3 className='font-bold mt-2'></h3>
<p className='text-gray-400 text-sm mb-1'> .</p>
<ul className='text-gray-400 text-sm mb-1 list-disc list-inside'>
<li> ( )</li>
<li> ( , )</li>
</ul>
<p className='text-gray-400 text-sm mb-1'> <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='font-bold mt-4 text-xl'> .</h2>
<p> , .</p>
</> : ''
}
</>
: isOwner === false ? <>
<h2 className='font-bold mt-4 text-xl'>, .</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
}