From ed19e4fc7c65df529a18810030a8ef3dbae13243 Mon Sep 17 00:00:00 2001 From: Nicholas Chiang Date: Sun, 23 Jul 2023 18:31:32 -0600 Subject: [PATCH] feat: add designer section to show page This patch adds a designer description to our Prisma schema and uses it to add the designer section to the show page. This patch also includes the corresponding updates to my import scripts. Closes: NC-626 Closes: NC-640 --- app/routes/shows.$showId/designers.tsx | 54 ++++++++++++++++++ app/routes/shows.$showId/route.tsx | 7 ++- app/routes/shows.$showId/where-to-buy.tsx | 2 +- .../migration.sql | 2 + prisma/schema.prisma | 3 + scripts/node/save/shows/hermes.ts | 55 +++++++++++++++++-- scripts/node/save/shows/isabel-marant.ts | 29 ++++++++++ 7 files changed, 145 insertions(+), 7 deletions(-) create mode 100644 app/routes/shows.$showId/designers.tsx create mode 100644 prisma/migrations/20230724000908_add_user_descriptions/migration.sql diff --git a/app/routes/shows.$showId/designers.tsx b/app/routes/shows.$showId/designers.tsx new file mode 100644 index 00000000..8c3597f8 --- /dev/null +++ b/app/routes/shows.$showId/designers.tsx @@ -0,0 +1,54 @@ +import { useLoaderData } from '@remix-run/react' + +import { Avatar } from 'components/avatar' +import { Empty } from 'components/empty' +import { ExternalLink } from 'components/external-link' + +import { type loader } from './route' +import { Section } from './section' + +export function Designers() { + const show = useLoaderData() + const designers = show.collections.flatMap((c) => c.designers) + return ( +
+ {designers.length === 0 && ( + + No designers have claimed this show yet. Please check back later. + + )} + {designers.length > 0 && ( +
    + {designers.map((designer) => ( +
  • + +

    + {designer.name} + {designer.url != null && ( + + )} +

    + {designer.description != null && ( +
    + )} + {designer.description == null && ( + + No designer description to show yet. Please check back later. + + )} +
  • + ))} +
+ )} +
+ ) +} diff --git a/app/routes/shows.$showId/route.tsx b/app/routes/shows.$showId/route.tsx index 9edc83a5..adc42416 100644 --- a/app/routes/shows.$showId/route.tsx +++ b/app/routes/shows.$showId/route.tsx @@ -8,6 +8,7 @@ import { cn } from 'utils/cn' import { ConsumerReviews } from './consumer-reviews' import { CriticReviews } from './critic-reviews' +import { Designers } from './designers' import { RateAndReview, getReview } from './rate-and-review' import { ScoresHeader, getScores } from './scores-header' import { ShowInfo } from './show-info' @@ -36,7 +37,10 @@ export async function loader({ request, params }: LoaderArgs) { season: true, brands: true, collections: { - include: { links: { include: { brand: true, retailer: true } } }, + include: { + links: { include: { brand: true, retailer: true } }, + designers: true, + }, }, reviews: { include: { author: true, publication: true }, @@ -89,6 +93,7 @@ function About({ className }: { className: string }) {
+ diff --git a/app/routes/shows.$showId/where-to-buy.tsx b/app/routes/shows.$showId/where-to-buy.tsx index 56081eb5..163e1695 100644 --- a/app/routes/shows.$showId/where-to-buy.tsx +++ b/app/routes/shows.$showId/where-to-buy.tsx @@ -11,7 +11,7 @@ import { Section } from './section' export function WhereToBuy() { const show = useLoaderData() - const links = show.collections.map((collection) => collection.links).flat() + const links = show.collections.flatMap((collection) => collection.links) const brands = show.brands.filter((brand) => brand.url) return (
diff --git a/prisma/migrations/20230724000908_add_user_descriptions/migration.sql b/prisma/migrations/20230724000908_add_user_descriptions/migration.sql new file mode 100644 index 00000000..6af97640 --- /dev/null +++ b/prisma/migrations/20230724000908_add_user_descriptions/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "User" ADD COLUMN "description" TEXT; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 667fc67f..64e9fec8 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -18,6 +18,9 @@ model User { // @todo there may be multiple users with the same name... name String @unique + // The user's description (e.g. a designer biography). + description String? + // The user's publicly visible username, as designated by the user. username String? @unique diff --git a/scripts/node/save/shows/hermes.ts b/scripts/node/save/shows/hermes.ts index 3d81a781..492e3414 100644 --- a/scripts/node/save/shows/hermes.ts +++ b/scripts/node/save/shows/hermes.ts @@ -32,6 +32,48 @@ const looks = Array(NUM_LOOKS) } return look }) +const designer: Prisma.UserCreateInput = { + name: 'Véronique Nichanian', + url: 'https://fr.wikipedia.org/wiki/V%C3%A9ronique_Nichanian', + avatar: 'https://static.nicholas.engineering/designers/veronique-nichanian/avatar.jpg', + description: ` +

Véronique Nichanian was born on May 3, 1954 in Boulogne-Billancourt.

+

+ In 1976, she graduated from the Ecole de la Chambre Syndicale de la Couture + Parisienne. She started as + Nino Cerruti's assistant for men's fashion. At 22, she left to take care of the + Cerruti + license in Japan. Twelve years later, she was co-responsible for the Cerruti + men's collections. +

+

+ Since 1988, she has been artistic director of menswear at + Hermès. The former boss of Hermès, Jean-Louis Dumas welcomed her with these words: + “Run it like your small business. You have carte blanche”. She is the one who + dresses the demanding Jean-Louis Dumas. +

+

+ From her very first collection, she was awarded the prize for young designer. + She has no ambition to open her own house. “It wouldn't change my expression. + And I don't have an ego problem.” +

+`, +} const vogue: Prisma.PublicationCreateInput = { name: 'Vogue', avatar: 'https://www.vogue.com/verso/static/vogue/assets/us/logo.svg', @@ -59,11 +101,11 @@ const fashionotography: Prisma.PublicationCreateInput = { name: 'Fashionotography', } // Scores assigned by gpt-3.5-turbo via the ChatGPT and the following prompt: -// Assign a sentiment score (on a five-star scale) to the following review. Air -// on the side of a lower score (very few reviews should ever receive or come -// close to receiving a 5/5). Often, if a review is simply neutral or is vague -// in its compliments, it should be assigned a 1/5 or 2/5. If a review seems -// energetically positive, assign a 3/5. Only if a review is resoundingly +// Assign a sentiment score (on a five-star scale) to the following review. Air +// on the side of a lower score (very few reviews should ever receive or come +// close to receiving a 5/5). Often, if a review is simply neutral or is vague +// in its compliments, it should be assigned a 1/5 or 2/5. If a review seems +// energetically positive, assign a 3/5. Only if a review is resoundingly // enthusiastically positive should you assign a 4/5. Never assign a 5/5. const reviews: Prisma.ReviewCreateWithoutShowInput[] = [ { @@ -534,6 +576,9 @@ const collection: Prisma.CollectionCreateInput = { create: season, }, }, + designers: { + connectOrCreate: { where: { name: designer.name }, create: designer }, + }, links: { connectOrCreate: { where: { url: link.url }, create: link } }, } export const show: Prisma.ShowCreateInput = { diff --git a/scripts/node/save/shows/isabel-marant.ts b/scripts/node/save/shows/isabel-marant.ts index df78d0d9..41e1dafd 100644 --- a/scripts/node/save/shows/isabel-marant.ts +++ b/scripts/node/save/shows/isabel-marant.ts @@ -32,6 +32,32 @@ const looks = Array(NUM_LOOKS) } return look }) +const designer: Prisma.UserCreateInput = { + name: 'Isabel Marant', + url: 'https://en.wikipedia.org/wiki/Isabel_Marant', + avatar: + 'https://static.nicholas.engineering/designers/isabel-marant/avatar.jpg', + description: ` +

+ Isabel Marant (born 12 April 1967) is a French fashion designer, owner of the + eponymous fashion brand. +

+

+ She won the Award de la Mode (1997), the Whirlpool Award for best female + designer (1998), Fashion Designer of the Year at British Glamour's Women of + the Year Awards (2012). She was named Contemporary Designer of the Year at the + Elle Style Awards in 2014. +

+

+ Her collaboration with H&M in 2013 was so successful that company's website + crashed under the demand and the collection was sold out within 45 minutes. +

+

+ Celebrities wearing Marant's designs include Alexa Chung, Katie Holmes, + Victoria Beckham, Kate Moss, Sienna Miller, Kate Bosworth, and Rachel Weisz. +

+`, +} const vogue: Prisma.PublicationCreateInput = { name: 'Vogue', avatar: 'https://www.vogue.com/verso/static/vogue/assets/us/logo.svg', @@ -203,6 +229,9 @@ const collection: Prisma.CollectionCreateInput = { create: season, }, }, + designers: { + connectOrCreate: { where: { name: designer.name }, create: designer }, + }, } export const show: Prisma.ShowCreateInput = { name: 'Isabel Marant Fall-Winter 2023',