Skip to content

Commit

Permalink
move view website button next to save button
Browse files Browse the repository at this point in the history
  • Loading branch information
chipanyanwu committed Dec 6, 2024
1 parent 6037b31 commit db92a74
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 27 deletions.
42 changes: 28 additions & 14 deletions src/components/Home/DonorDashboard/OrganizationCard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
Box,
Card,
CardContent,
CardActions,
Expand Down Expand Up @@ -83,15 +84,36 @@ const OrganizationCard = ({ organization }: OrganizationCardProps) => {
);

// Extracted component for header actions
const HeaderActions = () =>
user && (
const HeaderActions = () => (
<Box
sx={{
display: 'flex',
flexDirection: { xs: 'column', sm: 'column', md: 'column', lg: 'row' },
alignItems: 'flex-end',
gap: '0.25rem',
mt: 1,
}}
>
{user && (
<Button
size='small'
sx={{ width: 'fit-content' }}
color={isSaved ? 'secondary' : 'primary'}
onClick={() => handleAction('save')}
>
{isSaved ? 'Unsave' : 'Save'}
</Button>
)}
<Button
color={isSaved ? 'secondary' : 'primary'}
onClick={() => handleAction('save')}
size='small'
sx={{ width: 'fit-content' }}
href={organization.website}
target='_blank'
>
{isSaved ? 'Unsave' : 'Save'}
Visit Website
</Button>
);
</Box>
);

// Extracted component for needs section
const NeedsSection = () =>
Expand Down Expand Up @@ -137,14 +159,6 @@ const OrganizationCard = ({ organization }: OrganizationCardProps) => {
>
{organization.description}
</Typography>
<Button
size='small'
href={organization.website}
target='_blank'
sx={{ mt: 1 }}
>
Visit Website
</Button>
</CardContent>
<CardActions>
{hasNeeds && (
Expand Down
44 changes: 31 additions & 13 deletions src/components/Saved/SavedCard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
Box,
Card,
CardContent,
CardHeader,
Expand All @@ -25,13 +26,37 @@ const SavedOrganizationCard: React.FC<{
title={organization.name}
subheader={organization.location}
action={
<Button
variant='text'
color='error'
onClick={onRemove}
<Box
sx={{
display: 'flex',
flexDirection: {
xs: 'column',
sm: 'column',
md: 'column',
lg: 'row',
},
alignItems: 'flex-end',
gap: '0.25rem',
mt: 1,
}}
>
Remove
</Button>
<Button
size='small'
variant='text'
color='error'
onClick={onRemove}
>
Remove
</Button>
<Button
size='small'
sx={{ width: 'fit-content' }}
href={organization.website}
target='_blank'
>
Visit Website
</Button>
</Box>
}
/>
<CardContent>
Expand All @@ -41,13 +66,6 @@ const SavedOrganizationCard: React.FC<{
>
{organization.description}
</Typography>
<Button
size='small'
href={organization.website}
target='_blank'
>
Visit Website
</Button>
</CardContent>
</Card>
);
Expand Down

0 comments on commit db92a74

Please sign in to comment.