Skip to content

Commit

Permalink
Store finding themes into its own column
Browse files Browse the repository at this point in the history
  • Loading branch information
majakomel committed Oct 14, 2024
1 parent c79cd9f commit fc98fef
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions components/findings/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,25 +107,25 @@ const Form = ({ defaultValues, onSubmit }) => {

const themeOptions = useMemo(() => [
{
value: 'theme-human_rights',
value: 'human_rights',
label: intl.formatMessage({ id: 'Findings.Themes.Options.HumanRights' }),
},
{
value: 'theme-social_media',
value: 'social_media',
label: intl.formatMessage({ id: 'Findings.Themes.Options.SocialMedia' }),
},
{
value: 'theme-im',
value: 'im',
label: intl.formatMessage({ id: 'Findings.Themes.Options.IM' }),
},
{
value: 'theme-circumvention',
value: 'circumvention',
label: intl.formatMessage({
id: 'Findings.Themes.Options.Circumvention',
}),
},
{
value: 'theme-news_media',
value: 'news_media',
label: intl.formatMessage({ id: 'Findings.Themes.Options.NewsMedia' }),
},
])
Expand All @@ -145,15 +145,11 @@ const Form = ({ defaultValues, onSubmit }) => {
label: testNames[tn] ? intl.formatMessage({ id: testNames[tn].id }) : tn,
value: tn,
})),
tags: defaultValues.tags
.filter((t) => !t.includes('theme-'))
.map((t) => ({ label: t, value: t })),
themes: defaultValues.tags
.filter((t) => t.includes('theme-'))
.map((tn) => ({
label: themeOptions.find((t) => t.value === tn)?.label || tn,
value: tn,
})),
tags: defaultValues.tags.map((t) => ({ label: t, value: t })),
themes: defaultValues.themes.map((tn) => ({
label: themeOptions.find((t) => t.value === tn)?.label || tn,
value: tn,
})),
ASNs: defaultValues.ASNs.map((as) => ({ label: as, value: as })),
domains: defaultValues.domains.map((d) => ({ label: d, value: d })),
}
Expand Down Expand Up @@ -196,8 +192,6 @@ const Form = ({ defaultValues, onSubmit }) => {
}, [getValues])

const submit = (incident) => {
console.log(incident)
const tags = [...incident.tags, ...incident.themes]
return onSubmit({
...incident,
start_time: `${incident.start_time}T00:00:00Z`,
Expand All @@ -208,7 +202,8 @@ const Form = ({ defaultValues, onSubmit }) => {
? incident.test_names.map((test_name) => test_name.value)
: [],
CCs: incident.CCs.length ? incident.CCs.map((cc) => cc.value) : [],
tags: tags.length ? tags.map((t) => t.value) : [],
tags: incident.tags.length ? incident.tags.map((t) => t.value) : [],
themes: incident.themes.length ? incident.themes.map((t) => t.value) : [],
ASNs: incident.ASNs.length
? incident.ASNs.map((as) => Number(as.value))
: [],
Expand Down

0 comments on commit fc98fef

Please sign in to comment.