import { siteConfig } from 'site/site.config.mjs'
import yaml from 'js-yaml'
// Hooks
import { useContext } from 'react'
import { useTranslation } from 'next-i18next'
import { useAccount } from 'shared/hooks/use-account.mjs'
import { useBackend } from 'shared/hooks/use-backend.mjs'
import { useBugsnag } from 'shared/hooks/use-bugsnag.mjs'
// Context
import { ModalContext } from 'shared/context/modal-context.mjs'
// Components
import { ModalWrapper } from 'shared/components/wrappers/modal.mjs'
import { ChoiceButton } from 'shared/components/choice-button.mjs'
import { CopyToClipboard } from 'shared/components/copy-to-clipboard.mjs'
import { WebLink } from 'shared/components/link.mjs'
import { Spinner } from 'shared/components/spinner.mjs'
export const ns = ['errors']
const ReportId = ({ id, t }) => (
<>
{t('leadId')}:
{id}
>
)
const userInfo = (account) => `
## About the user
This report was submitted by FreeSewing user #${account.id}
with username **${account.username}**.`
const patronInfo = (account) =>
account.patron
? `
## :purple_heart: This was reported by a FreeSewing patron
> Please prioritize this issue as well as other issues by patrons as they are.
`
: `
## :snail: This was not reported by a FreeSewing patron
> With limited time and resources available, please prioritize issues from patrons instead.
`
const issueTemplate = ({ isPublic, account, data, bug = { id: 'unknown', url: '#' } }) => `
${patronInfo(account)}
- **Site**: ${siteConfig.site}
- **Public report**: ${isPublic ? 'Yes' : 'No'}
- **Bugsnag Context ID**: [${bug.id}](${bug.url})
Please refer to [the Bugsnag report](${bug.url}) for in-depth data and stack trace.
However, please note that this is not publicly available.
${isPublic ? userInfo(account) : ''}
## Data included in this issue
\`\`\`yaml
${yaml.dump(data)}
\`\`\`
`
const ModalSpinner = ({ t }) => (