diff --git a/packages/freesewing.shared/components/workbench/draft/error.js b/packages/freesewing.shared/components/workbench/draft/error.js index d48f19424d4..a9660d96a1c 100644 --- a/packages/freesewing.shared/components/workbench/draft/error.js +++ b/packages/freesewing.shared/components/workbench/draft/error.js @@ -1,17 +1,65 @@ +import { useState } from 'react' import Robot from 'shared/components/robot/index.js' -import Events from '../events.js' +import Popout from 'shared/components/popout.js' import { useTranslation } from 'next-i18next' -const Error = props => { +const Error = ({ draft, patternProps, error, updateGist }) => { + const { t } = useTranslation(['errors']) + const [share, setShare] = useState(false) return ( -
-
-

{t('errors:something')}

-
-
- +
+ +
+
+

{t('errors:something')}

+

Don't be alarmed, but we ran into some trouble while drafting this pattern.

+
+ +
+
+ +

Would you like to report this problem?

+

+ You can help us make FreeSewing better by reporting this problem. +

+

If you choose to report this:

+
    +
  • + We will compile a crash report that contains everything needed to recreate this problem +
  • +
  • + We will include personal data such as your username, + email address and measurements +
  • +
  • + We will share this report and the data in it with FreeSewing's bughunters team who will investigate the problem on your behalf +
  • +
  • Your personal data will not be shared publicly
  • +
+
+ +
+

+ +

+

+ If you rather not share any info, or investigate the problem yourself, you can do so: +

+
    +
  • + Check the +
  • +
  • Check the partially rendered pattern below to see which areas are problematic
  • +
+
) } diff --git a/packages/freesewing.shared/components/workbench/draft/index.js b/packages/freesewing.shared/components/workbench/draft/index.js index c6dee39d21e..bb0ff86a468 100644 --- a/packages/freesewing.shared/components/workbench/draft/index.js +++ b/packages/freesewing.shared/components/workbench/draft/index.js @@ -1,17 +1,14 @@ -import { useState } from 'react' import SvgWrapper from './svg-wrapper' import Error from './error.js' -import Popout from 'shared/components/popout.js' import Robot from 'shared/components/robot/index.js' const LabDraft = props => { const { app, draft, pattern, gist, updateGist, unsetGist, feedback } = props - const [share, setShare] = useState(false) if (!draft) return null + // Render as SVG if (gist?.renderer === 'svg') { - // Render as SVG let svg try { svg = draft.render() } catch(error) { @@ -23,70 +20,18 @@ const LabDraft = props => { // Render as React let patternProps = {} - try { patternProps = draft.draft().getRenderProps() } + try { patternProps = draft.getRenderProps() } catch(error) { console.log('Failed to get render props for pattern', error) return } - // Handle broken drafts - let error = null - if (patternProps.events.error.length > 0) { - error = ( - -
-
-

Got {patternProps.events.error.length} problems and a stitch ain't one

-

Don't be alarmed, but we ran into some trouble while drafting this pattern.

-

Help us make FreeSewing better

-

- If you like puzzles, you can try to figure out what went wrong: -

-
    -
  • - Check the -
  • -
  • Check the partially rendered pattern below to see which areas are problematic
  • -
-

- Alternatively, you can escalate this. Which means that: -

-
    -
  • - We will compile a crash report that contains everything needed to recreate this problem -
  • -
  • - We will include personal data such as your username, - email address and measurements -
  • -
  • - We will share this report and the data in it with FreeSewing's bughunters team -
  • -
-
- -
-

- -

- -
- -
-
- ) - } - console.log(patternProps) - return ( <> - {error} + {(!patternProps || patternProps.events.error.length > 0) + ? + : null + } )