From 282c8f48686fa0e00328fe62013a1cfb89462455 Mon Sep 17 00:00:00 2001 From: Jeroen Branje Date: Tue, 20 Feb 2024 13:20:18 +0100 Subject: [PATCH 1/6] feat(envited.ascs.digital): Add public member profiles Signed-off-by: Jeroen Branje --- .../Atoms/Address/Address.stories.tsx | 23 +++++ .../src/components/Atoms/Address/Address.tsx | 81 ++++++++++++++++ .../Atoms/Address/Address.ui.test.tsx | 24 +++++ .../src/components/Atoms/Address/index.ts | 1 + .../ContactPerson/ContactPerson.stories.tsx | 18 ++++ .../Atoms/ContactPerson/ContactPerson.tsx | 50 ++++++++++ .../ContactPerson/ContactPerson.ui.test.tsx | 19 ++++ .../components/Atoms/ContactPerson/index.ts | 1 + .../MemberProfileCard.stories.tsx | 37 +++++++ .../MemberProfileCard/MemberProfileCard.tsx | 46 +++++++++ .../MemberProfileCard.ui.test.tsx | 39 ++++++++ .../Atoms/MemberProfileCard/index.ts | 1 + apps/design-system/src/index.ts | 3 + .../app/members/[slug]/page.tsx | 24 ++++- .../envited.ascs.digital/app/members/page.tsx | 18 ++++ .../common/database/queries/profiles.ts | 3 + .../common/database/queries/queries.ts | 3 +- .../common/database/schema.ts | 2 +- .../common/i18n/useI18n.ts | 2 + .../common/serverActions/index.ts | 2 +- .../common/serverActions/profiles/get.ts | 16 +--- .../common/serverActions/profiles/index.ts | 2 +- .../common/types/types.ts | 10 +- .../0009_overjoyed_blockbuster.sql | 25 +++-- .../development/meta/0009_snapshot.json | 2 +- .../drizzle/staging/0007_cheerful_thundra.sql | 25 +++-- .../modules/HeroHeader/HeroHeader.tsx | 5 +- .../modules/Member/Member.intl.ts | 12 +++ .../modules/Member/Member.tsx | 96 +++++++++++++++++++ .../modules/Member/index.ts | 5 + .../modules/Member/locales/de_DE.json | 8 ++ .../modules/Member/locales/en_GB.json | 8 ++ .../modules/Members/GridItem.tsx | 42 ++++++++ .../modules/Members/Members.tsx | 51 ++++++++++ .../modules/Members/index.ts | 1 + 35 files changed, 663 insertions(+), 42 deletions(-) create mode 100644 apps/design-system/src/components/Atoms/Address/Address.stories.tsx create mode 100644 apps/design-system/src/components/Atoms/Address/Address.tsx create mode 100644 apps/design-system/src/components/Atoms/Address/Address.ui.test.tsx create mode 100644 apps/design-system/src/components/Atoms/Address/index.ts create mode 100644 apps/design-system/src/components/Atoms/ContactPerson/ContactPerson.stories.tsx create mode 100644 apps/design-system/src/components/Atoms/ContactPerson/ContactPerson.tsx create mode 100644 apps/design-system/src/components/Atoms/ContactPerson/ContactPerson.ui.test.tsx create mode 100644 apps/design-system/src/components/Atoms/ContactPerson/index.ts create mode 100644 apps/design-system/src/components/Atoms/MemberProfileCard/MemberProfileCard.stories.tsx create mode 100644 apps/design-system/src/components/Atoms/MemberProfileCard/MemberProfileCard.tsx create mode 100644 apps/design-system/src/components/Atoms/MemberProfileCard/MemberProfileCard.ui.test.tsx create mode 100644 apps/design-system/src/components/Atoms/MemberProfileCard/index.ts create mode 100644 apps/envited.ascs.digital/app/members/page.tsx create mode 100644 apps/envited.ascs.digital/modules/Member/Member.intl.ts create mode 100644 apps/envited.ascs.digital/modules/Member/Member.tsx create mode 100644 apps/envited.ascs.digital/modules/Member/index.ts create mode 100644 apps/envited.ascs.digital/modules/Member/locales/de_DE.json create mode 100644 apps/envited.ascs.digital/modules/Member/locales/en_GB.json create mode 100644 apps/envited.ascs.digital/modules/Members/GridItem.tsx create mode 100644 apps/envited.ascs.digital/modules/Members/Members.tsx create mode 100644 apps/envited.ascs.digital/modules/Members/index.ts diff --git a/apps/design-system/src/components/Atoms/Address/Address.stories.tsx b/apps/design-system/src/components/Atoms/Address/Address.stories.tsx new file mode 100644 index 00000000..d64351be --- /dev/null +++ b/apps/design-system/src/components/Atoms/Address/Address.stories.tsx @@ -0,0 +1,23 @@ +import { Meta, Story } from '@storybook/react' + +import Address from './Address' + +export default { + component: Address, + title: 'Components/Address', +} as Meta + +const Template: Story = ({ street, city, postalCode, country, phone, email }) => ( +
+) + +export const AddressStory = Template.bind({}) + +AddressStory.args = { + street: 'Main street 1', + city: 'Munich', + postalCode: '1234', + country: 'Germany', + phone: '+1234567', + email: 'info@envited.market', +} diff --git a/apps/design-system/src/components/Atoms/Address/Address.tsx b/apps/design-system/src/components/Atoms/Address/Address.tsx new file mode 100644 index 00000000..2ab6069d --- /dev/null +++ b/apps/design-system/src/components/Atoms/Address/Address.tsx @@ -0,0 +1,81 @@ +import { BuildingOffice2Icon, EnvelopeIcon, LinkIcon, PhoneIcon } from '@heroicons/react/24/outline' +import React, { FC } from 'react' + +interface AddressProps { + street: string + city: string + postalCode: string + country: string + website?: string + phone?: string + email?: string +} + +const Address: FC = ({ + street, + city, + postalCode, + country, + website = null, + phone = null, + email = null, +}) => { + return ( +
+
+
+ Address +
+
+ {street} +
+ {city}, {postalCode} +
+ {country} +
+
+ {website && ( +
+
+ Website +
+
+ + {website} + +
+
+ )} + {phone && ( +
+
+ Telephone +
+
+ + {phone} + +
+
+ )} + {email && ( +
+
+ Email +
+
+ + {email} + +
+
+ )} +
+ ) +} + +export default Address diff --git a/apps/design-system/src/components/Atoms/Address/Address.ui.test.tsx b/apps/design-system/src/components/Atoms/Address/Address.ui.test.tsx new file mode 100644 index 00000000..3d98bf05 --- /dev/null +++ b/apps/design-system/src/components/Atoms/Address/Address.ui.test.tsx @@ -0,0 +1,24 @@ +import { render, screen } from '@testing-library/react' + +import Address from './Address' + +describe('compoments/Atoms/Address', () => { + it('should render Address', () => { + // when ... rendering component + const street = 'STREET' + const city = 'CITY' + const postalCode = 'POSTAL_CODE' + const country = 'COUNTRY' + const phone = '+123456789' + const email = 'EMAIL_ADDRESS' + + render( +
, + ) + + const AddressElement = screen.getByText(street) + + // then ... should render as expected + expect(AddressElement).toBeInTheDocument() + }) +}) diff --git a/apps/design-system/src/components/Atoms/Address/index.ts b/apps/design-system/src/components/Atoms/Address/index.ts new file mode 100644 index 00000000..8916507a --- /dev/null +++ b/apps/design-system/src/components/Atoms/Address/index.ts @@ -0,0 +1 @@ +export { default as Address } from './Address' diff --git a/apps/design-system/src/components/Atoms/ContactPerson/ContactPerson.stories.tsx b/apps/design-system/src/components/Atoms/ContactPerson/ContactPerson.stories.tsx new file mode 100644 index 00000000..e8af7597 --- /dev/null +++ b/apps/design-system/src/components/Atoms/ContactPerson/ContactPerson.stories.tsx @@ -0,0 +1,18 @@ +import { Meta, Story } from '@storybook/react' + +import ContactPerson from './ContactPerson' + +export default { + component: ContactPerson, + title: 'Components/ContactPerson', +} as Meta + +const Template: Story = ({ name, phone, email }) => + +export const ContactPersonStory = Template.bind({}) + +ContactPersonStory.args = { + name: 'Name', + phone: '+1234567', + email: 'info@envited.market', +} diff --git a/apps/design-system/src/components/Atoms/ContactPerson/ContactPerson.tsx b/apps/design-system/src/components/Atoms/ContactPerson/ContactPerson.tsx new file mode 100644 index 00000000..6b0c04fa --- /dev/null +++ b/apps/design-system/src/components/Atoms/ContactPerson/ContactPerson.tsx @@ -0,0 +1,50 @@ +import { EnvelopeIcon, PhoneIcon, UserIcon } from '@heroicons/react/24/outline' +import React, { FC } from 'react' + +interface ContactPersonProps { + name: string + phone?: string + email?: string +} + +const ContactPerson: FC = ({ name, phone = null, email = null }) => { + return ( +
+
+
+ Address +
+
{name}
+
+ {phone && ( +
+
+ Telephone +
+
+ + {phone} + +
+
+ )} + {email && ( +
+
+ Email +
+
+ + {email} + +
+
+ )} +
+ ) +} + +export default ContactPerson diff --git a/apps/design-system/src/components/Atoms/ContactPerson/ContactPerson.ui.test.tsx b/apps/design-system/src/components/Atoms/ContactPerson/ContactPerson.ui.test.tsx new file mode 100644 index 00000000..548cf662 --- /dev/null +++ b/apps/design-system/src/components/Atoms/ContactPerson/ContactPerson.ui.test.tsx @@ -0,0 +1,19 @@ +import { render, screen } from '@testing-library/react' + +import ContactPerson from './ContactPerson' + +describe('compoments/Atoms/ContactPerson', () => { + it('should render Contact Person details', () => { + // when ... rendering component + const name = 'NAME' + const phone = 'PHONE_NUMBER' + const email = 'EMAIL_ADDRESS' + + render() + + const AddressElement = screen.getByText(name) + + // then ... should render as expected + expect(AddressElement).toBeInTheDocument() + }) +}) diff --git a/apps/design-system/src/components/Atoms/ContactPerson/index.ts b/apps/design-system/src/components/Atoms/ContactPerson/index.ts new file mode 100644 index 00000000..ed871bd8 --- /dev/null +++ b/apps/design-system/src/components/Atoms/ContactPerson/index.ts @@ -0,0 +1 @@ +export { default as ContactPerson } from './ContactPerson' diff --git a/apps/design-system/src/components/Atoms/MemberProfileCard/MemberProfileCard.stories.tsx b/apps/design-system/src/components/Atoms/MemberProfileCard/MemberProfileCard.stories.tsx new file mode 100644 index 00000000..7079e286 --- /dev/null +++ b/apps/design-system/src/components/Atoms/MemberProfileCard/MemberProfileCard.stories.tsx @@ -0,0 +1,37 @@ +import { Meta, Story } from '@storybook/react' + +import Pill from '../Pill/Pill' +import MemberProfileCard from './MemberProfileCard' + +export default { + component: MemberProfileCard, + title: 'Components/MemberProfileCard', +} as Meta + +const Template: Story = ({ title, logoUri, street, city, postalCode, country }) => ( + + OEM + Supplier + + } + /> +) + +export const MemberProfileCardStory = Template.bind({}) + +MemberProfileCardStory.args = { + title: 'The golden idea ', + logoUri: 'https://source.unsplash.com/random', + street: 'Main street 1', + city: 'Munich', + postalCode: '1234', + country: 'Germany', +} diff --git a/apps/design-system/src/components/Atoms/MemberProfileCard/MemberProfileCard.tsx b/apps/design-system/src/components/Atoms/MemberProfileCard/MemberProfileCard.tsx new file mode 100644 index 00000000..24ff2001 --- /dev/null +++ b/apps/design-system/src/components/Atoms/MemberProfileCard/MemberProfileCard.tsx @@ -0,0 +1,46 @@ +import React, { FC, ReactElement } from 'react' + +import { Address } from '../Address' + +interface MemberProfileCardProps { + title: string + logoUri: string + street: string + city: string + postalCode: string + country: string + businessCategories: ReactElement +} + +const MemberProfileCard: FC = ({ + title, + logoUri, + street, + city, + postalCode, + country, + businessCategories, +}) => { + return ( +
+
+ {title} +
+
+
+

{title}

+
+
+
+ {businessCategories && ( +
+

Business Categories

+
{businessCategories}
+
+ )} +
+
+ ) +} + +export default MemberProfileCard diff --git a/apps/design-system/src/components/Atoms/MemberProfileCard/MemberProfileCard.ui.test.tsx b/apps/design-system/src/components/Atoms/MemberProfileCard/MemberProfileCard.ui.test.tsx new file mode 100644 index 00000000..a4c1e941 --- /dev/null +++ b/apps/design-system/src/components/Atoms/MemberProfileCard/MemberProfileCard.ui.test.tsx @@ -0,0 +1,39 @@ +import { render, screen } from '@testing-library/react' +import React from 'react' + +import Pill from '../Pill/Pill' +import MemberProfileCard from './MemberProfileCard' + +describe('compoments/Atoms/MemberProfileCard', () => { + it('should render a Member Card with the title', () => { + // when ... rendering component + const title = 'TITLE' + const logoUri = 'https://source.unsplash.com/random' + const street = 'STREET' + const city = 'CITY' + const postalCode = 'POSTAL_CODE' + const country = 'COUNTRY' + + render( + + OEM + Supplier + + } + />, + ) + + const CardElement = screen.getByText(title) + + // then ... should render as expected + expect(CardElement).toBeInTheDocument() + }) +}) diff --git a/apps/design-system/src/components/Atoms/MemberProfileCard/index.ts b/apps/design-system/src/components/Atoms/MemberProfileCard/index.ts new file mode 100644 index 00000000..81e222fc --- /dev/null +++ b/apps/design-system/src/components/Atoms/MemberProfileCard/index.ts @@ -0,0 +1 @@ +export { default as MemberProfileCard } from './MemberProfileCard' diff --git a/apps/design-system/src/index.ts b/apps/design-system/src/index.ts index 5179257f..c75dddcd 100644 --- a/apps/design-system/src/index.ts +++ b/apps/design-system/src/index.ts @@ -1,11 +1,14 @@ +export { Address } from './components/Atoms/Address' export { Button } from './components/Atoms/Button' export { Card } from './components/Atoms/Card' +export { ContactPerson } from './components/Atoms/ContactPerson' export { Date } from './components/Atoms/Date' export { Checkbox, Checkboxes, TextField, TextareaField } from './components/Atoms/Form' export { Grid, GridRow } from './components/Atoms/Grid' export { Heading } from './components/Atoms/Heading' export { HeadingWithTooltip } from './components/Atoms/HeadingWithTooltip' export { LoadingIndicator } from './components/Atoms/LoadingIndicator' +export { MemberProfileCard } from './components/Atoms/MemberProfileCard' export { Nav, NavItem } from './components/Atoms/Nav' export { Pill } from './components/Atoms/Pill' export { Table, TableBody, TableCell, TableFooter, TableHeader, TableRow } from './components/Atoms/Table' diff --git a/apps/envited.ascs.digital/app/members/[slug]/page.tsx b/apps/envited.ascs.digital/app/members/[slug]/page.tsx index 366c8286..54780121 100644 --- a/apps/envited.ascs.digital/app/members/[slug]/page.tsx +++ b/apps/envited.ascs.digital/app/members/[slug]/page.tsx @@ -1,5 +1,8 @@ +import { prop, propOr } from 'ramda' + import { getProfile } from '../../../common/serverActions' import { Header } from '../../../modules/Header' +import { Member } from '../../../modules/Member' export default async function Index({ params: { slug } }: { params: { slug: string } }) { const profile = await getProfile(slug) @@ -7,7 +10,26 @@ export default async function Index({ params: { slug } }: { params: { slug: stri return ( <>
-
{JSON.stringify(profile)}
+
+
+ +
+
) } diff --git a/apps/envited.ascs.digital/app/members/page.tsx b/apps/envited.ascs.digital/app/members/page.tsx new file mode 100644 index 00000000..3d48ff46 --- /dev/null +++ b/apps/envited.ascs.digital/app/members/page.tsx @@ -0,0 +1,18 @@ +import { getPublishedProfiles } from '../../common/serverActions' +import { Header } from '../../modules/Header' +import { Members } from '../../modules/Members' + +export default async function Index() { + const profiles = await getPublishedProfiles() + + return ( + <> +
+
+
+ +
+
+ + ) +} diff --git a/apps/envited.ascs.digital/common/database/queries/profiles.ts b/apps/envited.ascs.digital/common/database/queries/profiles.ts index 1c449a66..3e8dc444 100644 --- a/apps/envited.ascs.digital/common/database/queries/profiles.ts +++ b/apps/envited.ascs.digital/common/database/queries/profiles.ts @@ -21,3 +21,6 @@ export const maybeUpdatePublishedState = (db: DatabaseConnection) => async (data export const getProfileBySlug = (db: DatabaseConnection) => async (slug: string) => db.select().from(profile).where(eq(profile.slug, slug)) + +export const getPublishedProfiles = (db: DatabaseConnection) => async () => + db.select().from(profile).where(eq(profile.isPublished, true)) diff --git a/apps/envited.ascs.digital/common/database/queries/queries.ts b/apps/envited.ascs.digital/common/database/queries/queries.ts index 962d4fad..11917b3b 100644 --- a/apps/envited.ascs.digital/common/database/queries/queries.ts +++ b/apps/envited.ascs.digital/common/database/queries/queries.ts @@ -6,7 +6,7 @@ import { connectDb } from '../database' import * as schema from '../schema' import { getBusinessCategories } from './businessCategories' import { fetchTables } from './common' -import { getProfileBySlug, maybeUpdatePublishedState, update as updateProfile } from './profiles' +import { getProfileBySlug, getPublishedProfiles, maybeUpdatePublishedState, update as updateProfile } from './profiles' import { deleteUserById, getUserById, @@ -27,6 +27,7 @@ const queries = { updateProfile, maybeUpdatePublishedState, getProfileBySlug, + getPublishedProfiles, getUserByIssuerId, } diff --git a/apps/envited.ascs.digital/common/database/schema.ts b/apps/envited.ascs.digital/common/database/schema.ts index 4e71f565..b2b08372 100644 --- a/apps/envited.ascs.digital/common/database/schema.ts +++ b/apps/envited.ascs.digital/common/database/schema.ts @@ -156,7 +156,7 @@ export const profilesToBusinessCategories = pgTable('profilesToBusinessCategorie }) export const profilesToBusinessCategoriesRelations = relations(profilesToBusinessCategories, ({ one }) => ({ - companyCategory: one(businessCategory, { + businessCategory: one(businessCategory, { fields: [profilesToBusinessCategories.businessCategoryId], references: [businessCategory.id], }), diff --git a/apps/envited.ascs.digital/common/i18n/useI18n.ts b/apps/envited.ascs.digital/common/i18n/useI18n.ts index a83eb962..47e0fce7 100644 --- a/apps/envited.ascs.digital/common/i18n/useI18n.ts +++ b/apps/envited.ascs.digital/common/i18n/useI18n.ts @@ -2,6 +2,7 @@ import { compose, mergeDeepRight, pathOr, propOr, reduce } from 'ramda' import { HeaderTranslation } from '../../modules/Header' import { HeroHeaderTranslation } from '../../modules/HeroHeader' +import { MemberTranslation } from '../../modules/Member' import { ProfileTranslation } from '../../modules/Profile' import { UsersTranslation } from '../../modules/Users' import { Locale, TranslationsMap } from './types' @@ -12,6 +13,7 @@ const mergeTranslations = reduce(mergeDeepRight, { [Locale.en_GB]: {}, [Locale.d const translationObject = mergeTranslations([ HeaderTranslation, HeroHeaderTranslation, + MemberTranslation, ProfileTranslation, UsersTranslation, ]) as TranslationsMap diff --git a/apps/envited.ascs.digital/common/serverActions/index.ts b/apps/envited.ascs.digital/common/serverActions/index.ts index 341b2234..397ad198 100644 --- a/apps/envited.ascs.digital/common/serverActions/index.ts +++ b/apps/envited.ascs.digital/common/serverActions/index.ts @@ -1,3 +1,3 @@ export { getBusinessCategories } from './businessCategories' -export { updateProfile, getProfile } from './profiles' +export { updateProfile, getProfile, getPublishedProfiles } from './profiles' export { getUserById, getUsersByIssuerId, insertUser } from './users' diff --git a/apps/envited.ascs.digital/common/serverActions/profiles/get.ts b/apps/envited.ascs.digital/common/serverActions/profiles/get.ts index b643016f..84be1f54 100644 --- a/apps/envited.ascs.digital/common/serverActions/profiles/get.ts +++ b/apps/envited.ascs.digital/common/serverActions/profiles/get.ts @@ -49,24 +49,18 @@ export const _get = export const get = _get({ db, getServerSession, log }) -export const _getBusinessCategories = - ({ db, getServerSession, log }: { db: Database; getServerSession: () => Promise; log: Log }) => +export const _getPublishedProfiles = + ({ db, log }: { db: Database; log: Log }) => async () => { try { - const session = await getServerSession() - - if (isNil(session)) { - throw unauthorizedError({ resource: 'profiles' }) - } - const connection = await db() - const categories = await connection.getBusinessCategories() + const profiles = await connection.getPublishedProfiles() - return categories + return profiles } catch (error: unknown) { log.error(formatError(error)) throw internalServerErrorError() } } -export const getBusinessCategories = _getBusinessCategories({ db, getServerSession, log }) +export const getPublishedProfiles = _getPublishedProfiles({ db, log }) diff --git a/apps/envited.ascs.digital/common/serverActions/profiles/index.ts b/apps/envited.ascs.digital/common/serverActions/profiles/index.ts index 1e43ba75..535ceb22 100644 --- a/apps/envited.ascs.digital/common/serverActions/profiles/index.ts +++ b/apps/envited.ascs.digital/common/serverActions/profiles/index.ts @@ -1,2 +1,2 @@ export { update as updateProfile } from './update' -export { get as getProfile, getBusinessCategories } from './get' +export { get as getProfile, getPublishedProfiles } from './get' diff --git a/apps/envited.ascs.digital/common/types/types.ts b/apps/envited.ascs.digital/common/types/types.ts index 933dc5e2..bb728bd9 100644 --- a/apps/envited.ascs.digital/common/types/types.ts +++ b/apps/envited.ascs.digital/common/types/types.ts @@ -84,15 +84,17 @@ export interface Profile { postalCode: string | null addressLocality: string | null addressCountry: string | null - firstName?: string | null - lastName?: string | null - phone?: string | null - email?: string | null website?: string | null offerings?: unknown | null isPublished?: boolean | null createdAt?: Date | null updatedAt?: Date | null + salesName?: string | null + salesPhone?: string | null + salesEmail?: string | null + principalName?: string | null + principalPhone?: string | null + principalEmail?: string | null } export interface Session { diff --git a/apps/envited.ascs.digital/drizzle/development/0009_overjoyed_blockbuster.sql b/apps/envited.ascs.digital/drizzle/development/0009_overjoyed_blockbuster.sql index e7792243..d6b44abf 100644 --- a/apps/envited.ascs.digital/drizzle/development/0009_overjoyed_blockbuster.sql +++ b/apps/envited.ascs.digital/drizzle/development/0009_overjoyed_blockbuster.sql @@ -1,12 +1,20 @@ -ALTER TABLE "companyCategory" RENAME TO "businessCategory";--> statement-breakpoint -ALTER TABLE "profilesToCompanyCategories" RENAME TO "profilesToBusinessCategories";--> statement-breakpoint -ALTER TABLE "profilesToBusinessCategories" RENAME COLUMN "company_category_id" TO "business_category_id";--> statement-breakpoint -ALTER TABLE "businessCategory" DROP CONSTRAINT "companyCategory_id_unique";--> statement-breakpoint -ALTER TABLE "businessCategory" DROP CONSTRAINT "companyCategory_name_unique";--> statement-breakpoint -ALTER TABLE "profilesToBusinessCategories" DROP CONSTRAINT "profilesToCompanyCategories_profile_id_profile_id_fk"; +CREATE TABLE IF NOT EXISTS "businessCategory" ( + "id" text PRIMARY KEY NOT NULL, + "name" text, + "description" text, + "created_at" timestamp, + "updated_at" timestamp, + CONSTRAINT "businessCategory_id_unique" UNIQUE("id"), + CONSTRAINT "businessCategory_name_unique" UNIQUE("name") +); --> statement-breakpoint -ALTER TABLE "profilesToBusinessCategories" DROP CONSTRAINT "profilesToCompanyCategories_company_category_id_companyCategory_id_fk"; +CREATE TABLE IF NOT EXISTS "profilesToBusinessCategories" ( + "profile_id" uuid NOT NULL, + "business_category_id" text NOT NULL +); --> statement-breakpoint +DROP TABLE "companyCategory" CASCADE;--> statement-breakpoint +DROP TABLE "profilesToCompanyCategories" CASCADE;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "profilesToBusinessCategories" ADD CONSTRAINT "profilesToBusinessCategories_profile_id_profile_id_fk" FOREIGN KEY ("profile_id") REFERENCES "public"."profile"("id") ON DELETE no action ON UPDATE no action; EXCEPTION @@ -18,6 +26,3 @@ DO $$ BEGIN EXCEPTION WHEN duplicate_object THEN null; END $$; ---> statement-breakpoint -ALTER TABLE "businessCategory" ADD CONSTRAINT "businessCategory_id_unique" UNIQUE("id");--> statement-breakpoint -ALTER TABLE "businessCategory" ADD CONSTRAINT "businessCategory_name_unique" UNIQUE("name"); \ No newline at end of file diff --git a/apps/envited.ascs.digital/drizzle/development/meta/0009_snapshot.json b/apps/envited.ascs.digital/drizzle/development/meta/0009_snapshot.json index 1a1b08d3..56b0fbf2 100644 --- a/apps/envited.ascs.digital/drizzle/development/meta/0009_snapshot.json +++ b/apps/envited.ascs.digital/drizzle/development/meta/0009_snapshot.json @@ -1,5 +1,5 @@ { - "id": "86109d50-05ea-4a5a-a824-fa73e3aa075a", + "id": "ce044679-56bc-440c-9681-39abb67edd6f", "prevId": "5bc1029f-3da8-4d61-84b1-70356c60f4f7", "version": "5", "dialect": "pg", diff --git a/apps/envited.ascs.digital/drizzle/staging/0007_cheerful_thundra.sql b/apps/envited.ascs.digital/drizzle/staging/0007_cheerful_thundra.sql index e7792243..d6b44abf 100644 --- a/apps/envited.ascs.digital/drizzle/staging/0007_cheerful_thundra.sql +++ b/apps/envited.ascs.digital/drizzle/staging/0007_cheerful_thundra.sql @@ -1,12 +1,20 @@ -ALTER TABLE "companyCategory" RENAME TO "businessCategory";--> statement-breakpoint -ALTER TABLE "profilesToCompanyCategories" RENAME TO "profilesToBusinessCategories";--> statement-breakpoint -ALTER TABLE "profilesToBusinessCategories" RENAME COLUMN "company_category_id" TO "business_category_id";--> statement-breakpoint -ALTER TABLE "businessCategory" DROP CONSTRAINT "companyCategory_id_unique";--> statement-breakpoint -ALTER TABLE "businessCategory" DROP CONSTRAINT "companyCategory_name_unique";--> statement-breakpoint -ALTER TABLE "profilesToBusinessCategories" DROP CONSTRAINT "profilesToCompanyCategories_profile_id_profile_id_fk"; +CREATE TABLE IF NOT EXISTS "businessCategory" ( + "id" text PRIMARY KEY NOT NULL, + "name" text, + "description" text, + "created_at" timestamp, + "updated_at" timestamp, + CONSTRAINT "businessCategory_id_unique" UNIQUE("id"), + CONSTRAINT "businessCategory_name_unique" UNIQUE("name") +); --> statement-breakpoint -ALTER TABLE "profilesToBusinessCategories" DROP CONSTRAINT "profilesToCompanyCategories_company_category_id_companyCategory_id_fk"; +CREATE TABLE IF NOT EXISTS "profilesToBusinessCategories" ( + "profile_id" uuid NOT NULL, + "business_category_id" text NOT NULL +); --> statement-breakpoint +DROP TABLE "companyCategory" CASCADE;--> statement-breakpoint +DROP TABLE "profilesToCompanyCategories" CASCADE;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "profilesToBusinessCategories" ADD CONSTRAINT "profilesToBusinessCategories_profile_id_profile_id_fk" FOREIGN KEY ("profile_id") REFERENCES "public"."profile"("id") ON DELETE no action ON UPDATE no action; EXCEPTION @@ -18,6 +26,3 @@ DO $$ BEGIN EXCEPTION WHEN duplicate_object THEN null; END $$; ---> statement-breakpoint -ALTER TABLE "businessCategory" ADD CONSTRAINT "businessCategory_id_unique" UNIQUE("id");--> statement-breakpoint -ALTER TABLE "businessCategory" ADD CONSTRAINT "businessCategory_name_unique" UNIQUE("name"); \ No newline at end of file diff --git a/apps/envited.ascs.digital/modules/HeroHeader/HeroHeader.tsx b/apps/envited.ascs.digital/modules/HeroHeader/HeroHeader.tsx index 42c99d5b..899e5ef4 100644 --- a/apps/envited.ascs.digital/modules/HeroHeader/HeroHeader.tsx +++ b/apps/envited.ascs.digital/modules/HeroHeader/HeroHeader.tsx @@ -9,6 +9,7 @@ import { INVALID_USER_CREDENTIAL, MEMBER_CREDENTIAL, USER_CREDENTIAL } from '../ import { useTranslation } from '../../common/i18n' import { useNotification } from '../../common/notifications' import { insertUser, updateProfile } from '../../common/serverActions' +import Link from 'next/link' export const HeroHeader: FC = () => { const { t } = useTranslation('HeroHeader') @@ -94,7 +95,9 @@ export const HeroHeader: FC = () => {
-
+
+ See list of registered members +

{message}

diff --git a/apps/envited.ascs.digital/modules/Member/Member.intl.ts b/apps/envited.ascs.digital/modules/Member/Member.intl.ts new file mode 100644 index 00000000..334988e3 --- /dev/null +++ b/apps/envited.ascs.digital/modules/Member/Member.intl.ts @@ -0,0 +1,12 @@ +import { Locale, TranslationsMap } from '../../common/i18n/types' +import de from './locales/de_DE.json' +import en from './locales/en_GB.json' + +export const translations: TranslationsMap = { + [Locale.en_GB]: { + Member: en, + }, + [Locale.de_DE]: { + Member: de, + }, +} diff --git a/apps/envited.ascs.digital/modules/Member/Member.tsx b/apps/envited.ascs.digital/modules/Member/Member.tsx new file mode 100644 index 00000000..7bd1074d --- /dev/null +++ b/apps/envited.ascs.digital/modules/Member/Member.tsx @@ -0,0 +1,96 @@ +'use client' + +import { Address, Card, ContactPerson, Heading, Pill } from '@envited-marketplace/design-system' +import Image from 'next/image' +import { isNil, map } from 'ramda' +import React, { FC } from 'react' + +import { useTranslation } from '../../common/i18n' + +interface MemberProps { + name: string + description: string + logo: string + website: string + streetAddress: string + addressCountry: string + addressLocality: string + postalCode: string + salesEmail: string | null + salesName: string | null + salesPhone: string | null + principalEmail: string | null + principalName: string | null + principalPhone: string | null +} + +export const Member: FC = ({ + name, + description, + logo, + website, + streetAddress, + addressCountry, + addressLocality, + postalCode, + salesEmail, + salesName, + salesPhone, + principalEmail, + principalName, + principalPhone, +}) => { + const { t } = useTranslation('Member') + + return ( +
+
+ + {t('[Heading] member profile')} + {name} +
+ {t('[Heading] business categories')} +
+ {map((categorie: string) => {categorie})(['OEM', 'Supplier'])} +
+
+
+ {t('[Heading] about us')} +
{description}
+
+
+
+
+ + {!isNil(logo) && {name}} + {t('[Heading] address')} +
+
+
+
+ {principalName && principalEmail && principalPhone && ( + + {t('[Heading] principal contact')} +
+ +
+
+ )} + {salesName && salesEmail && salesPhone && ( + + {t('[Heading] sales contact')} +
+ +
+
+ )} +
+
+ ) +} diff --git a/apps/envited.ascs.digital/modules/Member/index.ts b/apps/envited.ascs.digital/modules/Member/index.ts new file mode 100644 index 00000000..2a4835a6 --- /dev/null +++ b/apps/envited.ascs.digital/modules/Member/index.ts @@ -0,0 +1,5 @@ +import { translations } from './Member.intl' + +export { Member } from './Member' + +export { translations as MemberTranslation } diff --git a/apps/envited.ascs.digital/modules/Member/locales/de_DE.json b/apps/envited.ascs.digital/modules/Member/locales/de_DE.json new file mode 100644 index 00000000..0eedf3f3 --- /dev/null +++ b/apps/envited.ascs.digital/modules/Member/locales/de_DE.json @@ -0,0 +1,8 @@ +{ + "[Heading] member profile": "Member profile", + "[Heading] business categories": "Business categories", + "[Heading] about us": "About us", + "[Heading] address": "Address", + "[Heading] principal contact": "Principal contact", + "[Heading] sales contact": "Sales contact" +} diff --git a/apps/envited.ascs.digital/modules/Member/locales/en_GB.json b/apps/envited.ascs.digital/modules/Member/locales/en_GB.json new file mode 100644 index 00000000..0eedf3f3 --- /dev/null +++ b/apps/envited.ascs.digital/modules/Member/locales/en_GB.json @@ -0,0 +1,8 @@ +{ + "[Heading] member profile": "Member profile", + "[Heading] business categories": "Business categories", + "[Heading] about us": "About us", + "[Heading] address": "Address", + "[Heading] principal contact": "Principal contact", + "[Heading] sales contact": "Sales contact" +} diff --git a/apps/envited.ascs.digital/modules/Members/GridItem.tsx b/apps/envited.ascs.digital/modules/Members/GridItem.tsx new file mode 100644 index 00000000..dd4f8e53 --- /dev/null +++ b/apps/envited.ascs.digital/modules/Members/GridItem.tsx @@ -0,0 +1,42 @@ +'use client' + +import { MemberProfileCard, Pill } from '@envited-marketplace/design-system' +import Link from 'next/link' +import { map } from 'ramda' +import React, { FC } from 'react' + +interface ItemProps { + name: string + slug: string + logo: string + street: string + city: string + postalCode: string + country: string + businessCategories?: string[] +} + +export const GridItem: FC = ({ + name, + slug, + logo, + street, + city, + postalCode, + country, + businessCategories = [], +}) => { + return ( + + {map((category: string) => {category})(businessCategories)}} + /> + + ) +} diff --git a/apps/envited.ascs.digital/modules/Members/Members.tsx b/apps/envited.ascs.digital/modules/Members/Members.tsx new file mode 100644 index 00000000..190aacbe --- /dev/null +++ b/apps/envited.ascs.digital/modules/Members/Members.tsx @@ -0,0 +1,51 @@ +'use client' + +import { GridRow } from '@envited-marketplace/design-system' +import { map } from 'ramda' +import React, { FC } from 'react' + +import { GridItem } from './GridItem' + +interface MembersProps { + members: [] +} + +export const Members: FC = ({ members }) => { + return ( + + {map( + ({ + name, + slug, + logo, + streetAddress, + addressLocality, + postalCode, + addressCountry, + }: { + name: string + slug: string + logo: string + streetAddress: string + addressLocality: string + postalCode: string + addressCountry: string + }) => { + return ( + + ) + }, + )(members)} + + ) +} diff --git a/apps/envited.ascs.digital/modules/Members/index.ts b/apps/envited.ascs.digital/modules/Members/index.ts new file mode 100644 index 00000000..eb655d19 --- /dev/null +++ b/apps/envited.ascs.digital/modules/Members/index.ts @@ -0,0 +1 @@ +export { Members } from './Members' From 3cd28ef39b8b0e0cfc6684adfc4c5afb6df5fa33 Mon Sep 17 00:00:00 2001 From: Jeroen Branje Date: Tue, 20 Feb 2024 13:21:11 +0100 Subject: [PATCH 2/6] refactor: code prettier Signed-off-by: Jeroen Branje --- apps/envited.ascs.digital/modules/HeroHeader/HeroHeader.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/envited.ascs.digital/modules/HeroHeader/HeroHeader.tsx b/apps/envited.ascs.digital/modules/HeroHeader/HeroHeader.tsx index 899e5ef4..93b85b04 100644 --- a/apps/envited.ascs.digital/modules/HeroHeader/HeroHeader.tsx +++ b/apps/envited.ascs.digital/modules/HeroHeader/HeroHeader.tsx @@ -1,6 +1,7 @@ 'use client' import { Button, Grid, GridRow } from '@envited-marketplace/design-system' +import Link from 'next/link' import { useSearchParams } from 'next/navigation' import React, { FC, useState } from 'react' @@ -9,7 +10,6 @@ import { INVALID_USER_CREDENTIAL, MEMBER_CREDENTIAL, USER_CREDENTIAL } from '../ import { useTranslation } from '../../common/i18n' import { useNotification } from '../../common/notifications' import { insertUser, updateProfile } from '../../common/serverActions' -import Link from 'next/link' export const HeroHeader: FC = () => { const { t } = useTranslation('HeroHeader') From 2f52ff7ad41f81c513dda4869f35169c1bfb5ee7 Mon Sep 17 00:00:00 2001 From: Jeroen Branje Date: Tue, 20 Feb 2024 13:27:35 +0100 Subject: [PATCH 3/6] refactor(envited.ascs.digital): remove next/image because of external logo url Signed-off-by: Jeroen Branje --- apps/envited.ascs.digital/modules/Member/Member.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/envited.ascs.digital/modules/Member/Member.tsx b/apps/envited.ascs.digital/modules/Member/Member.tsx index 7bd1074d..0ce7e8d1 100644 --- a/apps/envited.ascs.digital/modules/Member/Member.tsx +++ b/apps/envited.ascs.digital/modules/Member/Member.tsx @@ -1,7 +1,6 @@ 'use client' import { Address, Card, ContactPerson, Heading, Pill } from '@envited-marketplace/design-system' -import Image from 'next/image' import { isNil, map } from 'ramda' import React, { FC } from 'react' @@ -62,7 +61,7 @@ export const Member: FC = ({
- {!isNil(logo) && {name}} + {!isNil(logo) && {name}} {t('[Heading] address')}
Date: Tue, 20 Feb 2024 13:32:32 +0100 Subject: [PATCH 4/6] refactor(design-system): fix ui test Signed-off-by: Jeroen Branje --- .../src/components/Atoms/Address/Address.ui.test.tsx | 2 +- apps/envited.ascs.digital/modules/HeroHeader/HeroHeader.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/design-system/src/components/Atoms/Address/Address.ui.test.tsx b/apps/design-system/src/components/Atoms/Address/Address.ui.test.tsx index 3d98bf05..6a5bdb06 100644 --- a/apps/design-system/src/components/Atoms/Address/Address.ui.test.tsx +++ b/apps/design-system/src/components/Atoms/Address/Address.ui.test.tsx @@ -16,7 +16,7 @@ describe('compoments/Atoms/Address', () => {
, ) - const AddressElement = screen.getByText(street) + const AddressElement = screen.getByText(phone) // then ... should render as expected expect(AddressElement).toBeInTheDocument() diff --git a/apps/envited.ascs.digital/modules/HeroHeader/HeroHeader.tsx b/apps/envited.ascs.digital/modules/HeroHeader/HeroHeader.tsx index 93b85b04..e89fbbd6 100644 --- a/apps/envited.ascs.digital/modules/HeroHeader/HeroHeader.tsx +++ b/apps/envited.ascs.digital/modules/HeroHeader/HeroHeader.tsx @@ -96,7 +96,7 @@ export const HeroHeader: FC = () => {
- See list of registered members + See list of registered members
From 175b5ee5f3be7290feb0482f017a42ef54ec507a Mon Sep 17 00:00:00 2001 From: Jeroen Branje Date: Tue, 20 Feb 2024 13:33:05 +0100 Subject: [PATCH 5/6] refactor: code prettier Signed-off-by: Jeroen Branje --- apps/envited.ascs.digital/modules/HeroHeader/HeroHeader.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/envited.ascs.digital/modules/HeroHeader/HeroHeader.tsx b/apps/envited.ascs.digital/modules/HeroHeader/HeroHeader.tsx index e89fbbd6..11668d05 100644 --- a/apps/envited.ascs.digital/modules/HeroHeader/HeroHeader.tsx +++ b/apps/envited.ascs.digital/modules/HeroHeader/HeroHeader.tsx @@ -96,7 +96,9 @@ export const HeroHeader: FC = () => {
- See list of registered members + + See list of registered members +
From 6a04aebfc8243e48303362e3a64ff8d349218600 Mon Sep 17 00:00:00 2001 From: Jeroen Branje Date: Tue, 20 Feb 2024 16:03:52 +0100 Subject: [PATCH 6/6] refactor(design-system): Move atoms to molecules Signed-off-by: Jeroen Branje --- .../Address/Address.stories.tsx | 2 +- .../{Atoms => Molecules}/Address/Address.tsx | 0 .../Address/Address.ui.test.tsx | 2 +- .../{Atoms => Molecules}/Address/index.ts | 0 .../MemberProfileCard.stories.tsx | 4 +- .../MemberProfileCard/MemberProfileCard.tsx | 0 .../MemberProfileCard.ui.test.tsx | 4 +- .../MemberProfileCard/index.ts | 0 apps/design-system/src/index.ts | 4 +- .../app/members/[slug]/page.tsx | 19 +---- .../modules/Member/Member.tsx | 76 ++++++++----------- 11 files changed, 41 insertions(+), 70 deletions(-) rename apps/design-system/src/components/{Atoms => Molecules}/Address/Address.stories.tsx (94%) rename apps/design-system/src/components/{Atoms => Molecules}/Address/Address.tsx (100%) rename apps/design-system/src/components/{Atoms => Molecules}/Address/Address.ui.test.tsx (92%) rename apps/design-system/src/components/{Atoms => Molecules}/Address/index.ts (100%) rename apps/design-system/src/components/{Atoms => Molecules}/MemberProfileCard/MemberProfileCard.stories.tsx (90%) rename apps/design-system/src/components/{Atoms => Molecules}/MemberProfileCard/MemberProfileCard.tsx (100%) rename apps/design-system/src/components/{Atoms => Molecules}/MemberProfileCard/MemberProfileCard.ui.test.tsx (90%) rename apps/design-system/src/components/{Atoms => Molecules}/MemberProfileCard/index.ts (100%) diff --git a/apps/design-system/src/components/Atoms/Address/Address.stories.tsx b/apps/design-system/src/components/Molecules/Address/Address.stories.tsx similarity index 94% rename from apps/design-system/src/components/Atoms/Address/Address.stories.tsx rename to apps/design-system/src/components/Molecules/Address/Address.stories.tsx index d64351be..940e70cd 100644 --- a/apps/design-system/src/components/Atoms/Address/Address.stories.tsx +++ b/apps/design-system/src/components/Molecules/Address/Address.stories.tsx @@ -4,7 +4,7 @@ import Address from './Address' export default { component: Address, - title: 'Components/Address', + title: 'Molecules/Address', } as Meta const Template: Story = ({ street, city, postalCode, country, phone, email }) => ( diff --git a/apps/design-system/src/components/Atoms/Address/Address.tsx b/apps/design-system/src/components/Molecules/Address/Address.tsx similarity index 100% rename from apps/design-system/src/components/Atoms/Address/Address.tsx rename to apps/design-system/src/components/Molecules/Address/Address.tsx diff --git a/apps/design-system/src/components/Atoms/Address/Address.ui.test.tsx b/apps/design-system/src/components/Molecules/Address/Address.ui.test.tsx similarity index 92% rename from apps/design-system/src/components/Atoms/Address/Address.ui.test.tsx rename to apps/design-system/src/components/Molecules/Address/Address.ui.test.tsx index 6a5bdb06..42fae1ab 100644 --- a/apps/design-system/src/components/Atoms/Address/Address.ui.test.tsx +++ b/apps/design-system/src/components/Molecules/Address/Address.ui.test.tsx @@ -2,7 +2,7 @@ import { render, screen } from '@testing-library/react' import Address from './Address' -describe('compoments/Atoms/Address', () => { +describe('compoments/Molecules/Address', () => { it('should render Address', () => { // when ... rendering component const street = 'STREET' diff --git a/apps/design-system/src/components/Atoms/Address/index.ts b/apps/design-system/src/components/Molecules/Address/index.ts similarity index 100% rename from apps/design-system/src/components/Atoms/Address/index.ts rename to apps/design-system/src/components/Molecules/Address/index.ts diff --git a/apps/design-system/src/components/Atoms/MemberProfileCard/MemberProfileCard.stories.tsx b/apps/design-system/src/components/Molecules/MemberProfileCard/MemberProfileCard.stories.tsx similarity index 90% rename from apps/design-system/src/components/Atoms/MemberProfileCard/MemberProfileCard.stories.tsx rename to apps/design-system/src/components/Molecules/MemberProfileCard/MemberProfileCard.stories.tsx index 7079e286..b4bf6007 100644 --- a/apps/design-system/src/components/Atoms/MemberProfileCard/MemberProfileCard.stories.tsx +++ b/apps/design-system/src/components/Molecules/MemberProfileCard/MemberProfileCard.stories.tsx @@ -1,11 +1,11 @@ import { Meta, Story } from '@storybook/react' -import Pill from '../Pill/Pill' +import Pill from '../../Atoms/Pill/Pill' import MemberProfileCard from './MemberProfileCard' export default { component: MemberProfileCard, - title: 'Components/MemberProfileCard', + title: 'Molecules/MemberProfileCard', } as Meta const Template: Story = ({ title, logoUri, street, city, postalCode, country }) => ( diff --git a/apps/design-system/src/components/Atoms/MemberProfileCard/MemberProfileCard.tsx b/apps/design-system/src/components/Molecules/MemberProfileCard/MemberProfileCard.tsx similarity index 100% rename from apps/design-system/src/components/Atoms/MemberProfileCard/MemberProfileCard.tsx rename to apps/design-system/src/components/Molecules/MemberProfileCard/MemberProfileCard.tsx diff --git a/apps/design-system/src/components/Atoms/MemberProfileCard/MemberProfileCard.ui.test.tsx b/apps/design-system/src/components/Molecules/MemberProfileCard/MemberProfileCard.ui.test.tsx similarity index 90% rename from apps/design-system/src/components/Atoms/MemberProfileCard/MemberProfileCard.ui.test.tsx rename to apps/design-system/src/components/Molecules/MemberProfileCard/MemberProfileCard.ui.test.tsx index a4c1e941..8293c360 100644 --- a/apps/design-system/src/components/Atoms/MemberProfileCard/MemberProfileCard.ui.test.tsx +++ b/apps/design-system/src/components/Molecules/MemberProfileCard/MemberProfileCard.ui.test.tsx @@ -1,10 +1,10 @@ import { render, screen } from '@testing-library/react' import React from 'react' -import Pill from '../Pill/Pill' +import Pill from '../../Atoms/Pill/Pill' import MemberProfileCard from './MemberProfileCard' -describe('compoments/Atoms/MemberProfileCard', () => { +describe('compoments/Molecules/MemberProfileCard', () => { it('should render a Member Card with the title', () => { // when ... rendering component const title = 'TITLE' diff --git a/apps/design-system/src/components/Atoms/MemberProfileCard/index.ts b/apps/design-system/src/components/Molecules/MemberProfileCard/index.ts similarity index 100% rename from apps/design-system/src/components/Atoms/MemberProfileCard/index.ts rename to apps/design-system/src/components/Molecules/MemberProfileCard/index.ts diff --git a/apps/design-system/src/index.ts b/apps/design-system/src/index.ts index c75dddcd..710c7824 100644 --- a/apps/design-system/src/index.ts +++ b/apps/design-system/src/index.ts @@ -1,4 +1,4 @@ -export { Address } from './components/Atoms/Address' +export { Address } from './components/Molecules/Address' export { Button } from './components/Atoms/Button' export { Card } from './components/Atoms/Card' export { ContactPerson } from './components/Atoms/ContactPerson' @@ -8,7 +8,7 @@ export { Grid, GridRow } from './components/Atoms/Grid' export { Heading } from './components/Atoms/Heading' export { HeadingWithTooltip } from './components/Atoms/HeadingWithTooltip' export { LoadingIndicator } from './components/Atoms/LoadingIndicator' -export { MemberProfileCard } from './components/Atoms/MemberProfileCard' +export { MemberProfileCard } from './components/Molecules/MemberProfileCard' export { Nav, NavItem } from './components/Atoms/Nav' export { Pill } from './components/Atoms/Pill' export { Table, TableBody, TableCell, TableFooter, TableHeader, TableRow } from './components/Atoms/Table' diff --git a/apps/envited.ascs.digital/app/members/[slug]/page.tsx b/apps/envited.ascs.digital/app/members/[slug]/page.tsx index 54780121..eae4618d 100644 --- a/apps/envited.ascs.digital/app/members/[slug]/page.tsx +++ b/apps/envited.ascs.digital/app/members/[slug]/page.tsx @@ -1,5 +1,3 @@ -import { prop, propOr } from 'ramda' - import { getProfile } from '../../../common/serverActions' import { Header } from '../../../modules/Header' import { Member } from '../../../modules/Member' @@ -12,22 +10,7 @@ export default async function Index({ params: { slug } }: { params: { slug: stri
- +
diff --git a/apps/envited.ascs.digital/modules/Member/Member.tsx b/apps/envited.ascs.digital/modules/Member/Member.tsx index 0ce7e8d1..f2d2600a 100644 --- a/apps/envited.ascs.digital/modules/Member/Member.tsx +++ b/apps/envited.ascs.digital/modules/Member/Member.tsx @@ -1,44 +1,16 @@ 'use client' import { Address, Card, ContactPerson, Heading, Pill } from '@envited-marketplace/design-system' -import { isNil, map } from 'ramda' +import { has, isNil, map, propOr } from 'ramda' import React, { FC } from 'react' import { useTranslation } from '../../common/i18n' +import { Profile } from '../../common/types' interface MemberProps { - name: string - description: string - logo: string - website: string - streetAddress: string - addressCountry: string - addressLocality: string - postalCode: string - salesEmail: string | null - salesName: string | null - salesPhone: string | null - principalEmail: string | null - principalName: string | null - principalPhone: string | null + member: Profile } - -export const Member: FC = ({ - name, - description, - logo, - website, - streetAddress, - addressCountry, - addressLocality, - postalCode, - salesEmail, - salesName, - salesPhone, - principalEmail, - principalName, - principalPhone, -}) => { +export const Member: FC = ({ member }) => { const { t } = useTranslation('Member') return ( @@ -46,7 +18,7 @@ export const Member: FC = ({
{t('[Heading] member profile')} - {name} + {propOr('', 'name')(member)}
{t('[Heading] business categories')}
@@ -55,37 +27,53 @@ export const Member: FC = ({
{t('[Heading] about us')} -
{description}
+
{propOr('', 'description')(member)}
- {!isNil(logo) && {name}} + {!isNil(propOr('', 'logo')(member)) && ( + {propOr('', + )} {t('[Heading] address')}
- {principalName && principalEmail && principalPhone && ( + {has('principalName')(member) && has('principalEmail')(member) && has('principalPhone')(member) && ( {t('[Heading] principal contact')}
- +
)} - {salesName && salesEmail && salesPhone && ( + {has('salesName')(member) && has('salesEmail')(member) && has('salesPhone')(member) && ( {t('[Heading] sales contact')}
- +
)}