Skip to content

Commit

Permalink
pulled in other duplicate code
Browse files Browse the repository at this point in the history
  • Loading branch information
Cara-Barter committed Nov 1, 2024
1 parent 87d09be commit 275b01d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 48 deletions.
12 changes: 1 addition & 11 deletions src/components/MediaDetails/MediaDetailsAudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,7 @@ function MediaDetailsAudio({ file }) {
</div>
</div>
</div>
{MediaDetailsSettings({ file })}
{file?.description.length > 0 && (
<div>
<h3 className="font-medium text-charcoal">Description</h3>
<div className="mt-2 flex items-center justify-between">
<p className="text-sm text-charcoal-500 italic">
{file?.description}
</p>
</div>
</div>
)}
<MediaDetailsSettings file={file} />
</div>
)
}
Expand Down
64 changes: 38 additions & 26 deletions src/components/MediaDetails/MediaDetailsSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,45 @@ import { isDisplayablePropMedia } from 'common/utils/mediaHelpers'

function MediaDetailsSettings({ file }) {
return (
<div>
<h3 className="font-medium text-charcoal-900">Information</h3>
<dl className="mt-2 border-t border-b border-charcoal-100 divide-y divide-charcoal-100">
{file?.id &&
Object.keys(file).map((key) => {
if (isDisplayablePropMedia(key, file[key])) {
if (key === 'description') {
return null
<>
<div>
<h3 className="font-medium text-charcoal-900">Information</h3>
<dl className="mt-2 border-t border-b border-charcoal-100 divide-y divide-charcoal-100">
{file?.id &&
Object.keys(file).map((key) => {
if (isDisplayablePropMedia(key, file[key])) {
if (key === 'description') {
return null
}
return (
<div
key={key}
className="py-3 flex justify-between text-sm font-medium"
>
<dt className="text-charcoal-500 capitalize">
{key === 'mimeType' ? 'File Type' : key}
</dt>
<dd className="text-charcoal-900 truncate pl-8">
{file[key]}
</dd>
</div>
)
}
return (
<div
key={key}
className="py-3 flex justify-between text-sm font-medium"
>
<dt className="text-charcoal-500 capitalize">
{key === 'mimeType' ? 'File Type' : key}
</dt>
<dd className="text-charcoal-900 truncate pl-8">
{file[key]}
</dd>
</div>
)
}
return null
})}
</dl>
</div>
return null
})}
</dl>
</div>
{file?.description.length > 0 && (
<div>
<h3 className="font-medium text-charcoal">Description</h3>
<div className="mt-2 flex items-center justify-between">
<p className="text-sm text-charcoal-500 italic">
{file?.description}
</p>
</div>
</div>
)}
</>
)
}
// PROPTYPES
Expand Down
12 changes: 1 addition & 11 deletions src/components/MediaDetails/MediaDetailsVisual.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,7 @@ function MediaDetailsVisual({ file, docType }) {
</div>
</div>
</div>
{MediaDetailsSettings({ file })}
{file?.description.length > 0 && (
<div>
<h3 className="font-medium text-charcoal">Description</h3>
<div className="mt-2 flex items-center justify-between">
<p className="text-sm text-charcoal-500 italic">
{file?.description}
</p>
</div>
</div>
)}
<MediaDetailsSettings file={file} />
</div>
)
}
Expand Down

0 comments on commit 275b01d

Please sign in to comment.