Skip to content

Commit

Permalink
Merge pull request #888 from Vidit-Kushwaha/fix/my-design
Browse files Browse the repository at this point in the history
fix(my-design): Update heading for Other Published Design to Other Public Design
  • Loading branch information
amitamrutiya authored Feb 2, 2025
2 parents ad3d1a4 + 02afab1 commit 89ebe64
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/custom/CatalogDetail/RelatedDesigns.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CatalogCardDesignLogo } from '../CustomCatalog';
import CustomCatalogCard, { Pattern } from '../CustomCatalog/CustomCard';
import { formatToTitleCase } from './helper';
import { getHeadingText } from './helper';
import { AdditionalContainer, ContentHeading, DesignCardContainer } from './style';
import { UserProfile } from './types';

Expand Down Expand Up @@ -41,8 +41,7 @@ const RelatedDesigns: React.FC<RelatedDesignsProps> = ({
<AdditionalContainer>
<ContentHeading>
<h2 style={{ margin: '0', textTransform: 'uppercase' }}>
Other published design by {formatToTitleCase(userProfile?.first_name ?? '')}{' '}
{fetchingOrgError ? '' : `under ${organizationName}`}
{getHeadingText({ type, userProfile, organizationName, fetchingOrgError })}
</h2>
</ContentHeading>
<DesignCardContainer>
Expand Down
22 changes: 22 additions & 0 deletions src/custom/CatalogDetail/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,25 @@ export const formatDate = (date: Date) => {
const formattedDate = new Date(date).toLocaleDateString('en-US', options);
return formattedDate;
};

interface HeadingProps {
type: string;
userProfile?: {
first_name?: string;
};
organizationName?: string;
fetchingOrgError: boolean;
}

export const getHeadingText = ({
type,
userProfile,
organizationName,
fetchingOrgError
}: HeadingProps): string => {
const designType = type.toLowerCase() === 'my-designs' ? 'public' : 'published';
const firstName = formatToTitleCase(userProfile?.first_name ?? '');
const orgText = fetchingOrgError ? '' : `under ${organizationName}`;

return `Other ${designType} design by ${firstName} ${orgText}`;
};

0 comments on commit 89ebe64

Please sign in to comment.