Commit 9f100984 authored by Stefan Probst's avatar Stefan Probst
Browse files

fix: use category labels

parent 8624c359
import { useRouter } from 'next/router'
import { useQueryClient } from 'react-query'
import { DatasetCore, DatasetDto, useCreateDataset } from '@/api/sshoc'
import type { DatasetCore, DatasetDto } from '@/api/sshoc'
import { useCreateDataset, useGetItemCategories } from '@/api/sshoc'
import type { ItemCategory } from '@/api/sshoc/types'
import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection'
......@@ -29,6 +28,9 @@ 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 useItemMutation = useCreateDataset
const toast = useToast()
......@@ -37,7 +39,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
const queryClient = useQueryClient()
const create = useItemMutation({
onSuccess(data: DatasetDto) {
toast.success(`Successfully updated ${category}.`)
toast.success(`Successfully created ${categoryLabel}.`)
queryClient.invalidateQueries({
queryKey: ['itemSearch'],
......@@ -52,7 +54,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
router.push({ pathname: `/${data.category}/${data.persistentId}` })
},
onError() {
toast.error(`Failed to update ${category}.`)
toast.error(`Failed to create ${categoryLabel}.`)
},
})
......
import { useRouter } from 'next/router'
import { useQueryClient } from 'react-query'
import type { DatasetCore, DatasetDto } from '@/api/sshoc'
import { useUpdateDataset } from '@/api/sshoc'
import { useGetItemCategories, useUpdateDataset } from '@/api/sshoc'
import type { ItemCategory } from '@/api/sshoc/types'
import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection'
......@@ -31,6 +30,9 @@ 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 useItemMutation = useUpdateDataset
const toast = useToast()
......@@ -39,7 +41,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
const queryClient = useQueryClient()
const create = useItemMutation({
onSuccess(data: DatasetDto) {
toast.success(`Successfully updated ${category}.`)
toast.success(`Successfully updated ${categoryLabel}.`)
queryClient.invalidateQueries({
queryKey: ['itemSearch'],
......@@ -54,7 +56,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
router.push({ pathname: `/${data.category}/${data.persistentId}` })
},
onError() {
toast.error(`Failed to update ${category}.`)
toast.error(`Failed to update ${categoryLabel}.`)
},
})
......
import { useRouter } from 'next/router'
import { useQueryClient } from 'react-query'
import type { PublicationCore, PublicationDto } from '@/api/sshoc'
import { useCreatePublication } from '@/api/sshoc'
import { useGetItemCategories, useCreatePublication } from '@/api/sshoc'
import type { ItemCategory } from '@/api/sshoc/types'
import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection'
......@@ -29,6 +28,9 @@ 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 useItemMutation = useCreatePublication
const toast = useToast()
......@@ -37,7 +39,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
const queryClient = useQueryClient()
const create = useItemMutation({
onSuccess(data: PublicationDto) {
toast.success(`Successfully updated ${category}.`)
toast.success(`Successfully created ${categoryLabel}.`)
queryClient.invalidateQueries({
queryKey: ['itemSearch'],
......@@ -52,7 +54,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
router.push({ pathname: `/${data.category}/${data.persistentId}` })
},
onError() {
toast.error(`Failed to update ${category}.`)
toast.error(`Failed to create ${categoryLabel}.`)
},
})
......
import { useRouter } from 'next/router'
import { useQueryClient } from 'react-query'
import type { PublicationCore, PublicationDto } from '@/api/sshoc'
import { useUpdatePublication } from '@/api/sshoc'
import { useUpdatePublication, useGetItemCategories } from '@/api/sshoc'
import type { ItemCategory } from '@/api/sshoc/types'
import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection'
......@@ -31,6 +30,9 @@ 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 useItemMutation = useUpdatePublication
const toast = useToast()
......@@ -39,7 +41,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
const queryClient = useQueryClient()
const create = useItemMutation({
onSuccess(data: PublicationDto) {
toast.success(`Successfully updated ${category}.`)
toast.success(`Successfully updated ${categoryLabel}.`)
queryClient.invalidateQueries({
queryKey: ['itemSearch'],
......@@ -54,7 +56,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
router.push({ pathname: `/${data.category}/${data.persistentId}` })
},
onError() {
toast.error(`Failed to update ${category}.`)
toast.error(`Failed to update ${categoryLabel}.`)
},
})
......
import { useRouter } from 'next/router'
import { useQueryClient } from 'react-query'
import type { ToolCore, ToolDto } from '@/api/sshoc'
import { useCreateTool } from '@/api/sshoc'
import { useCreateTool, useGetItemCategories } from '@/api/sshoc'
import type { ItemCategory } from '@/api/sshoc/types'
import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection'
......@@ -28,6 +27,9 @@ 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 useItemMutation = useCreateTool
const toast = useToast()
......@@ -36,7 +38,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
const queryClient = useQueryClient()
const create = useItemMutation({
onSuccess(data: ToolDto) {
toast.success(`Successfully updated ${category}.`)
toast.success(`Successfully created ${categoryLabel}.`)
queryClient.invalidateQueries({
queryKey: ['itemSearch'],
......@@ -51,7 +53,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
router.push({ pathname: `/${data.category}/${data.persistentId}` })
},
onError() {
toast.error(`Failed to update ${category}.`)
toast.error(`Failed to create ${categoryLabel}.`)
},
})
......
import { useRouter } from 'next/router'
import { useQueryClient } from 'react-query'
import type { ToolCore, ToolDto } from '@/api/sshoc'
import { useUpdateTool } from '@/api/sshoc'
import { useUpdateTool, useGetItemCategories } from '@/api/sshoc'
import type { ItemCategory } from '@/api/sshoc/types'
import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection'
......@@ -30,6 +29,9 @@ 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 useItemMutation = useUpdateTool
const toast = useToast()
......@@ -38,7 +40,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
const queryClient = useQueryClient()
const create = useItemMutation({
onSuccess(data: ToolDto) {
toast.success(`Successfully updated ${category}.`)
toast.success(`Successfully updated ${categoryLabel}.`)
queryClient.invalidateQueries({
queryKey: ['itemSearch'],
......@@ -53,7 +55,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
router.push({ pathname: `/${data.category}/${data.persistentId}` })
},
onError() {
toast.error(`Failed to update ${category}.`)
toast.error(`Failed to update ${categoryLabel}.`)
},
})
......
import { useRouter } from 'next/router'
import { useQueryClient } from 'react-query'
import type { TrainingMaterialCore, TrainingMaterialDto } from '@/api/sshoc'
import { useCreateTrainingMaterial } from '@/api/sshoc'
import { useCreateTrainingMaterial, useGetItemCategories } from '@/api/sshoc'
import type { ItemCategory } from '@/api/sshoc/types'
import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection'
......@@ -28,6 +27,9 @@ 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 useItemMutation = useCreateTrainingMaterial
const toast = useToast()
......@@ -36,7 +38,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
const queryClient = useQueryClient()
const create = useItemMutation({
onSuccess(data: TrainingMaterialDto) {
toast.success(`Successfully updated ${category}.`)
toast.success(`Successfully created ${categoryLabel}.`)
queryClient.invalidateQueries({
queryKey: ['itemSearch'],
......@@ -51,7 +53,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
router.push({ pathname: `/${data.category}/${data.persistentId}` })
},
onError() {
toast.error(`Failed to update ${category}.`)
toast.error(`Failed to create ${categoryLabel}.`)
},
})
......
import { useRouter } from 'next/router'
import { useQueryClient } from 'react-query'
import type { TrainingMaterialCore, TrainingMaterialDto } from '@/api/sshoc'
import { useUpdateTrainingMaterial } from '@/api/sshoc'
import { useUpdateTrainingMaterial, useGetItemCategories } from '@/api/sshoc'
import type { ItemCategory } from '@/api/sshoc/types'
import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection'
......@@ -30,6 +29,9 @@ 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 useItemMutation = useUpdateTrainingMaterial
const toast = useToast()
......@@ -38,7 +40,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
const queryClient = useQueryClient()
const create = useItemMutation({
onSuccess(data: TrainingMaterialDto) {
toast.success(`Successfully updated ${category}.`)
toast.success(`Successfully updated ${categoryLabel}.`)
queryClient.invalidateQueries({
queryKey: ['itemSearch'],
......@@ -53,7 +55,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
router.push({ pathname: `/${data.category}/${data.persistentId}` })
},
onError() {
toast.error(`Failed to update ${category}.`)
toast.error(`Failed to update ${categoryLabel}.`)
},
})
......
import { useRouter } from 'next/router'
import { useQueryClient } from 'react-query'
import type { WorkflowCore, WorkflowDto } from '@/api/sshoc'
import { useCreateWorkflow } from '@/api/sshoc'
import { useCreateWorkflow, useGetItemCategories } from '@/api/sshoc'
import type { ItemCategory } from '@/api/sshoc/types'
import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection'
......@@ -28,6 +27,9 @@ 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 useItemMutation = useCreateWorkflow
const toast = useToast()
......@@ -36,7 +38,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
const queryClient = useQueryClient()
const create = useItemMutation({
onSuccess(data: WorkflowDto) {
toast.success(`Successfully updated ${category}.`)
toast.success(`Successfully created ${categoryLabel}.`)
queryClient.invalidateQueries({
queryKey: ['itemSearch'],
......@@ -51,7 +53,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
router.push({ pathname: `/${data.category}/${data.persistentId}` })
},
onError() {
toast.error(`Failed to update ${category}.`)
toast.error(`Failed to create ${categoryLabel}.`)
},
})
......
import { useRouter } from 'next/router'
import { useQueryClient } from 'react-query'
import type { WorkflowCore, WorkflowDto } from '@/api/sshoc'
import { useUpdateWorkflow } from '@/api/sshoc'
import { useUpdateWorkflow, useGetItemCategories } from '@/api/sshoc'
import type { ItemCategory } from '@/api/sshoc/types'
import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection'
......@@ -30,6 +29,9 @@ 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 useItemMutation = useUpdateWorkflow
const toast = useToast()
......@@ -38,7 +40,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
const queryClient = useQueryClient()
const create = useItemMutation({
onSuccess(data: WorkflowDto) {
toast.success(`Successfully updated ${category}.`)
toast.success(`Successfully updated ${categoryLabel}.`)
queryClient.invalidateQueries({
queryKey: ['itemSearch'],
......@@ -53,7 +55,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
router.push({ pathname: `/${data.category}/${data.persistentId}` })
},
onError() {
toast.error(`Failed to update ${category}.`)
toast.error(`Failed to update ${categoryLabel}.`)
},
})
......
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