Added poetry display on userPage

This commit is contained in:
2023-07-31 15:03:56 +03:00
parent e7327945e3
commit 6724a97352
7 changed files with 208 additions and 1 deletions

View File

@ -0,0 +1,18 @@
import { API_URL } from '../../config'
import { PoetryResponse, Poetry } from './types'
const initialPoetry: Poetry = {
title: '',
text: '',
author: '',
}
const composePoetryURL = () => (
API_URL + '/poetry?'
)
const processPoetry = (data: PoetryResponse): Poetry => {
return data
}
export { initialPoetry, composePoetryURL, processPoetry }

View File

@ -0,0 +1,23 @@
import { isObject } from '../../utils/types'
type PoetryResponse = {
title: string,
text: string,
author: string,
}
const isPoetryResponse = (obj: unknown): obj is PoetryResponse => (
isObject(obj, {
'title': 'string',
'text': 'string',
'author': 'string',
})
)
type Poetry = PoetryResponse
const isPoetry = isPoetryResponse
export type { PoetryResponse, Poetry }
export { isPoetryResponse, isPoetry }