Commit 0e9c0111 authored by Stefan Probst's avatar Stefan Probst
Browse files

fix: use singular category labels in toast

parent 8746cd7e
Pipeline #178016 passed with stage
in 5 minutes and 8 seconds
import { useRouter } from 'next/router'
import { useQueryClient } from 'react-query'
import type { DatasetCore, DatasetDto } from '@/api/sshoc'
import { useCreateDataset, useGetItemCategories } from '@/api/sshoc'
import { useCreateDataset } from '@/api/sshoc'
import type { ItemCategory } from '@/api/sshoc/types'
import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection'
import { DateFormSection } from '@/components/item/DateFormSection/DateFormSection'
import { MainFormSection } from '@/components/item/MainFormSection/MainFormSection'
......@@ -15,6 +14,7 @@ import { useToast } from '@/elements/Toast/useToast'
import { validate } from '@/lib/sshoc/validate'
import { useAuth } from '@/modules/auth/AuthContext'
import { Form } from '@/modules/form/Form'
import { getSingularItemCategoryLabel } from '@/utils/getSingularItemCategoryLabel'
export type ItemFormValues = DatasetCore
......@@ -29,8 +29,7 @@ export interface ItemFormProps<T> {
export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
const { category, initialValues } = props
const categories = useGetItemCategories()
const categoryLabel = categories.data?.[category] ?? category
const categoryLabel = getSingularItemCategoryLabel(category)
const useItemMutation = useCreateDataset
......
import { useRouter } from 'next/router'
import { useQueryClient } from 'react-query'
import type { DatasetCore, DatasetDto } from '@/api/sshoc'
import { useGetItemCategories, useUpdateDataset } from '@/api/sshoc'
import { useUpdateDataset } from '@/api/sshoc'
import type { ItemCategory } from '@/api/sshoc/types'
import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection'
import { DateFormSection } from '@/components/item/DateFormSection/DateFormSection'
import { MainFormSection } from '@/components/item/MainFormSection/MainFormSection'
......@@ -15,6 +14,7 @@ import { useToast } from '@/elements/Toast/useToast'
import { validate } from '@/lib/sshoc/validate'
import { useAuth } from '@/modules/auth/AuthContext'
import { Form } from '@/modules/form/Form'
import { getSingularItemCategoryLabel } from '@/utils/getSingularItemCategoryLabel'
export type ItemFormValues = DatasetCore
......@@ -31,8 +31,7 @@ export interface ItemFormProps<T> {
export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
const { id, category, initialValues } = props
const categories = useGetItemCategories()
const categoryLabel = categories.data?.[category] ?? category
const categoryLabel = getSingularItemCategoryLabel(category)
const useItemMutation = useUpdateDataset
......
import { useRouter } from 'next/router'
import { useQueryClient } from 'react-query'
import type { PublicationCore, PublicationDto } from '@/api/sshoc'
import { useGetItemCategories, useCreatePublication } from '@/api/sshoc'
import { useCreatePublication } from '@/api/sshoc'
import type { ItemCategory } from '@/api/sshoc/types'
import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection'
import { DateFormSection } from '@/components/item/DateFormSection/DateFormSection'
import { MainFormSection } from '@/components/item/MainFormSection/MainFormSection'
......@@ -15,6 +14,7 @@ import { useToast } from '@/elements/Toast/useToast'
import { validate } from '@/lib/sshoc/validate'
import { useAuth } from '@/modules/auth/AuthContext'
import { Form } from '@/modules/form/Form'
import { getSingularItemCategoryLabel } from '@/utils/getSingularItemCategoryLabel'
export type ItemFormValues = PublicationCore
......@@ -29,8 +29,7 @@ export interface ItemFormProps<T> {
export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
const { category, initialValues } = props
const categories = useGetItemCategories()
const categoryLabel = categories.data?.[category] ?? category
const categoryLabel = getSingularItemCategoryLabel(category)
const useItemMutation = useCreatePublication
......
import { useRouter } from 'next/router'
import { useQueryClient } from 'react-query'
import type { PublicationCore, PublicationDto } from '@/api/sshoc'
import { useUpdatePublication, useGetItemCategories } from '@/api/sshoc'
import { useUpdatePublication } from '@/api/sshoc'
import type { ItemCategory } from '@/api/sshoc/types'
import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection'
import { DateFormSection } from '@/components/item/DateFormSection/DateFormSection'
import { MainFormSection } from '@/components/item/MainFormSection/MainFormSection'
......@@ -15,6 +14,7 @@ import { useToast } from '@/elements/Toast/useToast'
import { validate } from '@/lib/sshoc/validate'
import { useAuth } from '@/modules/auth/AuthContext'
import { Form } from '@/modules/form/Form'
import { getSingularItemCategoryLabel } from '@/utils/getSingularItemCategoryLabel'
export type ItemFormValues = PublicationCore
......@@ -31,8 +31,7 @@ export interface ItemFormProps<T> {
export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
const { id, category, initialValues } = props
const categories = useGetItemCategories()
const categoryLabel = categories.data?.[category] ?? category
const categoryLabel = getSingularItemCategoryLabel(category)
const useItemMutation = useUpdatePublication
......
import { useRouter } from 'next/router'
import { useQueryClient } from 'react-query'
import type { ToolCore, ToolDto } from '@/api/sshoc'
import { useCreateTool, useGetItemCategories } from '@/api/sshoc'
import { useCreateTool } from '@/api/sshoc'
import type { ItemCategory } from '@/api/sshoc/types'
import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection'
import { MainFormSection } from '@/components/item/MainFormSection/MainFormSection'
import { PropertiesFormSection } from '@/components/item/PropertiesFormSection/PropertiesFormSection'
......@@ -14,6 +13,7 @@ import { useToast } from '@/elements/Toast/useToast'
import { validate } from '@/lib/sshoc/validate'
import { useAuth } from '@/modules/auth/AuthContext'
import { Form } from '@/modules/form/Form'
import { getSingularItemCategoryLabel } from '@/utils/getSingularItemCategoryLabel'
export type ItemFormValues = ToolCore
......@@ -28,8 +28,7 @@ export interface ItemFormProps<T> {
export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
const { category, initialValues } = props
const categories = useGetItemCategories()
const categoryLabel = categories.data?.[category] ?? category
const categoryLabel = getSingularItemCategoryLabel(category)
const useItemMutation = useCreateTool
......
import { useRouter } from 'next/router'
import { useQueryClient } from 'react-query'
import type { ToolCore, ToolDto } from '@/api/sshoc'
import { useUpdateTool, useGetItemCategories } from '@/api/sshoc'
import { useUpdateTool } from '@/api/sshoc'
import type { ItemCategory } from '@/api/sshoc/types'
import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection'
import { MainFormSection } from '@/components/item/MainFormSection/MainFormSection'
import { PropertiesFormSection } from '@/components/item/PropertiesFormSection/PropertiesFormSection'
......@@ -14,6 +13,7 @@ import { useToast } from '@/elements/Toast/useToast'
import { validate } from '@/lib/sshoc/validate'
import { useAuth } from '@/modules/auth/AuthContext'
import { Form } from '@/modules/form/Form'
import { getSingularItemCategoryLabel } from '@/utils/getSingularItemCategoryLabel'
export type ItemFormValues = ToolCore
......@@ -30,8 +30,7 @@ export interface ItemFormProps<T> {
export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
const { id, category, initialValues } = props
const categories = useGetItemCategories()
const categoryLabel = categories.data?.[category] ?? category
const categoryLabel = getSingularItemCategoryLabel(category)
const useItemMutation = useUpdateTool
......
import { useRouter } from 'next/router'
import { useQueryClient } from 'react-query'
import type { TrainingMaterialCore, TrainingMaterialDto } from '@/api/sshoc'
import { useCreateTrainingMaterial, useGetItemCategories } from '@/api/sshoc'
import { useCreateTrainingMaterial } from '@/api/sshoc'
import type { ItemCategory } from '@/api/sshoc/types'
import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection'
import { MainFormSection } from '@/components/item/MainFormSection/MainFormSection'
import { PropertiesFormSection } from '@/components/item/PropertiesFormSection/PropertiesFormSection'
......@@ -14,6 +13,7 @@ import { useToast } from '@/elements/Toast/useToast'
import { validate } from '@/lib/sshoc/validate'
import { useAuth } from '@/modules/auth/AuthContext'
import { Form } from '@/modules/form/Form'
import { getSingularItemCategoryLabel } from '@/utils/getSingularItemCategoryLabel'
export type ItemFormValues = TrainingMaterialCore
......@@ -28,8 +28,7 @@ export interface ItemFormProps<T> {
export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
const { category, initialValues } = props
const categories = useGetItemCategories()
const categoryLabel = categories.data?.[category] ?? category
const categoryLabel = getSingularItemCategoryLabel(category)
const useItemMutation = useCreateTrainingMaterial
......
import { useRouter } from 'next/router'
import { useQueryClient } from 'react-query'
import type { TrainingMaterialCore, TrainingMaterialDto } from '@/api/sshoc'
import { useUpdateTrainingMaterial, useGetItemCategories } from '@/api/sshoc'
import { useUpdateTrainingMaterial } from '@/api/sshoc'
import type { ItemCategory } from '@/api/sshoc/types'
import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection'
import { MainFormSection } from '@/components/item/MainFormSection/MainFormSection'
import { PropertiesFormSection } from '@/components/item/PropertiesFormSection/PropertiesFormSection'
......@@ -14,6 +13,7 @@ import { useToast } from '@/elements/Toast/useToast'
import { validate } from '@/lib/sshoc/validate'
import { useAuth } from '@/modules/auth/AuthContext'
import { Form } from '@/modules/form/Form'
import { getSingularItemCategoryLabel } from '@/utils/getSingularItemCategoryLabel'
export type ItemFormValues = TrainingMaterialCore
......@@ -30,8 +30,7 @@ export interface ItemFormProps<T> {
export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
const { id, category, initialValues } = props
const categories = useGetItemCategories()
const categoryLabel = categories.data?.[category] ?? category
const categoryLabel = getSingularItemCategoryLabel(category)
const useItemMutation = useUpdateTrainingMaterial
......
import { useRouter } from 'next/router'
import { useQueryClient } from 'react-query'
import type { WorkflowCore, WorkflowDto } from '@/api/sshoc'
import { useCreateWorkflow, useGetItemCategories } from '@/api/sshoc'
import { useCreateWorkflow } from '@/api/sshoc'
import type { ItemCategory } from '@/api/sshoc/types'
import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection'
import { MainFormSection } from '@/components/item/MainFormSection/MainFormSection'
import { PropertiesFormSection } from '@/components/item/PropertiesFormSection/PropertiesFormSection'
......@@ -14,6 +13,7 @@ import { useToast } from '@/elements/Toast/useToast'
import { validate } from '@/lib/sshoc/validate'
import { useAuth } from '@/modules/auth/AuthContext'
import { Form } from '@/modules/form/Form'
import { getSingularItemCategoryLabel } from '@/utils/getSingularItemCategoryLabel'
export type ItemFormValues = WorkflowCore
......@@ -28,8 +28,7 @@ export interface ItemFormProps<T> {
export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
const { category, initialValues } = props
const categories = useGetItemCategories()
const categoryLabel = categories.data?.[category] ?? category
const categoryLabel = getSingularItemCategoryLabel(category)
const useItemMutation = useCreateWorkflow
......
import { useRouter } from 'next/router'
import { useQueryClient } from 'react-query'
import type { WorkflowCore, WorkflowDto } from '@/api/sshoc'
import { useUpdateWorkflow, useGetItemCategories } from '@/api/sshoc'
import { useUpdateWorkflow } from '@/api/sshoc'
import type { ItemCategory } from '@/api/sshoc/types'
import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection'
import { MainFormSection } from '@/components/item/MainFormSection/MainFormSection'
import { PropertiesFormSection } from '@/components/item/PropertiesFormSection/PropertiesFormSection'
......@@ -14,6 +13,7 @@ import { useToast } from '@/elements/Toast/useToast'
import { validate } from '@/lib/sshoc/validate'
import { useAuth } from '@/modules/auth/AuthContext'
import { Form } from '@/modules/form/Form'
import { getSingularItemCategoryLabel } from '@/utils/getSingularItemCategoryLabel'
export type ItemFormValues = WorkflowCore
......@@ -30,8 +30,7 @@ export interface ItemFormProps<T> {
export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
const { id, category, initialValues } = props
const categories = useGetItemCategories()
const categoryLabel = categories.data?.[category] ?? category
const categoryLabel = getSingularItemCategoryLabel(category)
const useItemMutation = useUpdateWorkflow
......
......@@ -481,9 +481,7 @@ function CreateItemsMenu() {
<Link href={{ pathname: `/${category}/create` }}>
<a className="transition-colors duration-150 hover:text-secondary-500">
Create{' '}
{getSingularItemCategoryLabel(
category as Exclude<ItemCategory, 'step'>,
)}
{getSingularItemCategoryLabel(category as ItemCategory)}
</a>
</Link>
</li>
......
import type { ItemCategory as ItemCategoryWithStep } from '@/api/sshoc/types'
type ItemCategory = Exclude<ItemCategoryWithStep, 'step'>
import type { ItemCategory } from '@/api/sshoc/types'
/**
* Returns item category in singular.
......@@ -11,6 +9,7 @@ export function getSingularItemCategoryLabel(category: ItemCategory): string {
const labels = {
dataset: 'Dataset',
publication: 'Publication',
step: 'Step',
'tool-or-service': 'Tool or service',
'training-material': 'Training material',
workflow: 'Workflow',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment