Skip to content

Commit 664bc8e

Browse files
committed
Refactor ProfileDetails component to utilize type prop for conditional rendering of user details and tab management
1 parent 002363b commit 664bc8e

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

app/[locale]/(user)/publishers/components/ProfileDetails.tsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ import UseCases from './UseCases';
99

1010
interface ProfileDetailsProps {
1111
data: any;
12+
type: 'organization' | 'Publisher';
1213
}
1314

14-
const ProfileDetails: React.FC<ProfileDetailsProps> = ({ data }) => {
15+
const ProfileDetails: React.FC<ProfileDetailsProps> = ({ data, type }) => {
1516
const socialMedia = [
1617
{
1718
icon: Icons.twitter,
@@ -27,7 +28,7 @@ const ProfileDetails: React.FC<ProfileDetailsProps> = ({ data }) => {
2728
},
2829
].filter((item) => item.link?.trim());
2930

30-
const [type, setType] = useState<'usecases' | 'datasets'>('usecases');
31+
const [tabType, setTabType] = useState<'usecases' | 'datasets'>('usecases');
3132

3233
type PublisherType = 'usecases' | 'datasets';
3334
const publisherButtons: { key: PublisherType; label: string }[] = [
@@ -41,11 +42,16 @@ const ProfileDetails: React.FC<ProfileDetailsProps> = ({ data }) => {
4142
<div className="flex items-center gap-1 ">
4243
<Icon source={Icons.calendar} color="warning" />
4344
<Text variant="bodySm">
44-
Joined on: {formatDate(data?.dateJoined)}
45+
Joined on:{' '}
46+
{type === 'organization'
47+
? formatDate(data?.created)
48+
: formatDate(data?.dateJoined)}
4549
</Text>
4650
</div>
4751
<div>
48-
<Text variant="bodySm">{data?.bio}</Text>
52+
<Text variant="bodySm">
53+
{type === 'organization' ? data?.description : data?.bio}
54+
</Text>
4955
</div>
5056
<div className=" flex items-center gap-3">
5157
{socialMedia?.map((item: any, index: any) => (
@@ -66,10 +72,10 @@ const ProfileDetails: React.FC<ProfileDetailsProps> = ({ data }) => {
6672
{publisherButtons.map((btn) => (
6773
<Button
6874
key={btn.key}
69-
onClick={() => setType(btn.key)}
75+
onClick={() => setTabType(btn.key)}
7076
className={cn(
7177
' w-72 rounded-full py-3',
72-
type === btn.key
78+
tabType === btn.key
7379
? 'bg-tertiaryAccent'
7480
: 'border-1 border-solid border-tertiaryAccent bg-surfaceDefault'
7581
)}
@@ -82,8 +88,8 @@ const ProfileDetails: React.FC<ProfileDetailsProps> = ({ data }) => {
8288
</div>
8389
</ButtonGroup>
8490
</div>
85-
{type === 'usecases' && <UseCases />}
86-
{type === 'datasets' && <Datasets />}
91+
{tabType === 'usecases' && <UseCases type={type} />}
92+
{tabType === 'datasets' && <Datasets type={type} />}
8793
</div>
8894
);
8995
};

0 commit comments

Comments
 (0)