Skip to content

Commit 89ebe64

Browse files
authored
Merge pull request #888 from Vidit-Kushwaha/fix/my-design
fix(my-design): Update heading for Other Published Design to Other Public Design
2 parents ad3d1a4 + 02afab1 commit 89ebe64

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

src/custom/CatalogDetail/RelatedDesigns.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { CatalogCardDesignLogo } from '../CustomCatalog';
22
import CustomCatalogCard, { Pattern } from '../CustomCatalog/CustomCard';
3-
import { formatToTitleCase } from './helper';
3+
import { getHeadingText } from './helper';
44
import { AdditionalContainer, ContentHeading, DesignCardContainer } from './style';
55
import { UserProfile } from './types';
66

@@ -41,8 +41,7 @@ const RelatedDesigns: React.FC<RelatedDesignsProps> = ({
4141
<AdditionalContainer>
4242
<ContentHeading>
4343
<h2 style={{ margin: '0', textTransform: 'uppercase' }}>
44-
Other published design by {formatToTitleCase(userProfile?.first_name ?? '')}{' '}
45-
{fetchingOrgError ? '' : `under ${organizationName}`}
44+
{getHeadingText({ type, userProfile, organizationName, fetchingOrgError })}
4645
</h2>
4746
</ContentHeading>
4847
<DesignCardContainer>

src/custom/CatalogDetail/helper.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,25 @@ export const formatDate = (date: Date) => {
6161
const formattedDate = new Date(date).toLocaleDateString('en-US', options);
6262
return formattedDate;
6363
};
64+
65+
interface HeadingProps {
66+
type: string;
67+
userProfile?: {
68+
first_name?: string;
69+
};
70+
organizationName?: string;
71+
fetchingOrgError: boolean;
72+
}
73+
74+
export const getHeadingText = ({
75+
type,
76+
userProfile,
77+
organizationName,
78+
fetchingOrgError
79+
}: HeadingProps): string => {
80+
const designType = type.toLowerCase() === 'my-designs' ? 'public' : 'published';
81+
const firstName = formatToTitleCase(userProfile?.first_name ?? '');
82+
const orgText = fetchingOrgError ? '' : `under ${organizationName}`;
83+
84+
return `Other ${designType} design by ${firstName} ${orgText}`;
85+
};

0 commit comments

Comments
 (0)