Recipe views now using UserInfoView.

This commit is contained in:
Jesse Brault 2024-08-12 17:20:07 -05:00
parent d4686d0a39
commit b8787cd8f9
5 changed files with 12 additions and 15 deletions

View File

@ -36,7 +36,7 @@ const getRecipeInfos = async ({
updated: rawUpdated, updated: rawUpdated,
title, title,
ownerId, ownerId,
ownerUsername, owner,
isPublic, isPublic,
starCount, starCount,
mainImage: rawMainImage, mainImage: rawMainImage,
@ -46,7 +46,7 @@ const getRecipeInfos = async ({
updated: new Date(rawUpdated), updated: new Date(rawUpdated),
title, title,
ownerId, ownerId,
ownerUsername, owner,
isPublic, isPublic,
starCount, starCount,
mainImage: toImageView(rawMainImage), mainImage: toImageView(rawMainImage),

View File

@ -1,4 +1,5 @@
import ImageView, { RawImageView, toImageView } from './ImageView' import ImageView, { RawImageView, toImageView } from './ImageView'
import UserInfoView from './UserInfoView'
export interface RawFullRecipeView { export interface RawFullRecipeView {
id: number id: number
@ -7,8 +8,7 @@ export interface RawFullRecipeView {
slug: string slug: string
title: string title: string
text: string text: string
ownerId: number owner: UserInfoView
ownerUsername: string
starCount: number starCount: number
viewerCount: number viewerCount: number
mainImage: RawImageView mainImage: RawImageView
@ -22,8 +22,7 @@ interface FullRecipeView {
slug: string slug: string
title: string title: string
text: string text: string
ownerId: number owner: UserInfoView
ownerUsername: string
starCount: number starCount: number
viewerCount: number viewerCount: number
mainImage: ImageView mainImage: ImageView
@ -37,8 +36,7 @@ export const toFullRecipeView = ({
slug, slug,
title, title,
text, text,
ownerId, owner,
ownerUsername,
starCount, starCount,
viewerCount, viewerCount,
mainImage: rawMainImage, mainImage: rawMainImage,
@ -50,8 +48,7 @@ export const toFullRecipeView = ({
slug, slug,
title, title,
text, text,
ownerId, owner,
ownerUsername,
starCount, starCount,
viewerCount, viewerCount,
mainImage: toImageView(rawMainImage), mainImage: toImageView(rawMainImage),

View File

@ -1,11 +1,12 @@
import ImageView, { RawImageView } from './ImageView' import ImageView, { RawImageView } from './ImageView'
import UserInfoView from './UserInfoView'
export interface RawRecipeInfoView { export interface RawRecipeInfoView {
id: number id: number
updated: string updated: string
title: string title: string
ownerId: number ownerId: number
ownerUsername: string owner: UserInfoView
isPublic: boolean isPublic: boolean
starCount: number starCount: number
mainImage: RawImageView mainImage: RawImageView
@ -16,8 +17,7 @@ interface RecipeInfoView {
id: number id: number
updated: Date updated: Date
title: string title: string
ownerId: number owner: UserInfoView
ownerUsername: string
isPublic: boolean isPublic: boolean
starCount: number starCount: number
mainImage: ImageView mainImage: ImageView

View File

@ -19,7 +19,7 @@ const Recipe = ({ recipe, imgUrl }: RecipeProps) => {
<StarCount count={recipe.starCount} /> <StarCount count={recipe.starCount} />
</div> </div>
<div className={classes.infoRow}> <div className={classes.infoRow}>
<UserIconAndName username={recipe.ownerUsername} /> <UserIconAndName username={recipe.owner.username} />
<RecipeVisibilityIcon isPublic={recipe.isPublic} /> <RecipeVisibilityIcon isPublic={recipe.isPublic} />
</div> </div>
</div> </div>

View File

@ -76,7 +76,7 @@ const Recipes = () => {
<RecipeCard <RecipeCard
key={view.id} key={view.id}
title={view.title} title={view.title}
ownerUsername={view.ownerUsername} ownerUsername={view.owner.username}
slug={view.slug} slug={view.slug}
mainImageUrl={ mainImageUrl={
slugsAndImgUrls.find(({ data: slugAndImgUrl }) => { slugsAndImgUrls.find(({ data: slugAndImgUrl }) => {