• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

EcrituresNumeriques / stylo / 13547287365

26 Feb 2025 03:20PM UTC coverage: 12.024% (+0.3%) from 11.684%
13547287365

push

github

web-flow
Merge pull request #1255 from ggrossetie/fix-1171-hooks-renaming

157 of 305 branches covered (51.48%)

Branch coverage included in aggregate %.

67 of 264 new or added lines in 25 files covered. (25.38%)

10 existing lines in 4 files now uncovered.

1144 of 10515 relevant lines covered (10.88%)

1.83 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/front/src/components/TagCreate.jsx
1
import { Button, useInput, useToasts } from '@geist-ui/core'
×
2
import React, { useCallback } from 'react'
×
3
import { useTranslation } from 'react-i18next'
×
4

5
import { randomColor } from '../helpers/colors.js'
×
NEW
6
import { useGraphQLClient } from '../helpers/graphQL'
×
7
import { useMutate } from '../hooks/graphql'
×
8
import { createTag, getTags } from './Tag.graphql'
×
9

10
import styles from './TagCreate.module.scss'
×
11
import Field from './Field'
×
12
import { useCurrentUser } from '../contexts/CurrentUser'
×
13

14
export default function TagCreate() {
×
15
  const { setToast } = useToasts()
×
16
  const { data, mutate } = useMutate({ query: getTags, variables: {} })
×
17
  const { t } = useTranslation()
×
18
  const { state: name, bindings: nameBindings } = useInput('')
×
19
  const { state: description, bindings: descriptionBindings } = useInput('')
×
20
  const { state: color, bindings: colorBindings } = useInput(randomColor())
×
21

22
  const activeUser = useCurrentUser()
×
NEW
23
  const { query } = useGraphQLClient()
×
24

25
  const variables = {
×
26
    user: activeUser._id,
×
27
    name,
×
28
    description,
×
29
    color,
×
30
  }
×
31

32
  const handleCreateTag = useCallback(
×
33
    (event) => {
×
34
      event.preventDefault()
×
35
      ;(async () => {
×
36
        try {
×
NEW
37
          const result = await query({
×
38
            query: createTag,
×
39
            variables,
×
40
          })
×
41
          await mutate(
×
42
            {
×
43
              user: {
×
44
                tags: [...data.user.tags, result.createTag],
×
45
              },
×
46
            },
×
47
            { revalidate: false }
×
48
          )
×
49
        } catch (err) {
×
50
          setToast({
×
51
            type: 'error',
×
52
            text: `Unable to create a new tag: ${err.message}`,
×
53
          })
×
54
        }
×
55
      })()
×
56
    },
×
57
    [variables]
×
58
  )
×
59

60
  return (
×
61
    <section className={styles.create}>
×
62
      <form onSubmit={handleCreateTag}>
×
63
        <Field
×
64
          autoFocus={true}
×
65
          label={t('tag.createForm.nameField')}
×
66
          type="text"
×
67
          {...nameBindings}
×
68
        />
×
69
        <Field
×
70
          label={t('tag.createForm.descriptionField')}
×
71
          type="text"
×
72
          {...descriptionBindings}
×
73
        />
×
74
        <Field
×
75
          label={t('tag.createForm.colorField')}
×
76
          type="color"
×
77
          {...colorBindings}
×
78
        />
×
79
        <ul className={styles.actions}>
×
80
          <li>
×
81
            <Button
×
82
              onClick={handleCreateTag}
×
83
              type="secondary"
×
84
              title={t('tag.createForm.buttonTitle')}
×
85
            >
86
              {t('tag.createForm.buttonText')}
×
87
            </Button>
×
88
          </li>
×
89
        </ul>
×
90
      </form>
×
91
    </section>
×
92
  )
93
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc