Skip to content

Commit

Permalink
refactor: move minor components to uti
Browse files Browse the repository at this point in the history
  • Loading branch information
wiktoriasalamon committed Jul 10, 2024
1 parent a3957ea commit 5d95aa7
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 36 deletions.
41 changes: 5 additions & 36 deletions frontend/src/components/pages/ProfileSetting/ProfileSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ import { DeleteIcon } from '@app/static/icons/DeleteIcon';
import { Avatar } from '@app/components/common/Avatar';
import { useProfileSettings } from './ProfileSetting.hooks';
import { CropImageModal } from './modules/CropImageModal';
import { ReactNode } from 'react';
import { DeleteImageModal } from './modules/DeleteImageModal';
import { Typography } from '@app/components/common/Typography';
import { Breadcrumbs } from '@app/components/modules/Breadcrumbs';
import { routes } from '@app/constants';
import {
LadderDataItem,
NotificationCheckbox,
PersonalDetailsDataItem,
} from '@app/components/pages/ProfileSetting/utils';

export const ProfileSettings: React.FC<ProfileSettingsProps> = ({ data }) => {
const { firstName, lastName, email, ladders, photo } = data;
Expand All @@ -28,41 +32,6 @@ export const ProfileSettings: React.FC<ProfileSettingsProps> = ({ data }) => {
handleSaveCroppedImage,
} = useProfileSettings();

const NotificationCheckbox: React.FC<{ icon: ReactNode }> = ({ icon }) => (
<div className="flex flex-col items-center">
<div className="mb-6 text-navy-500">{icon}</div>
<div className="flex h-6 items-center">
<input type="checkbox" className="border-gray-300 h-4 w-4 rounded text-blue-800 focus:ring-blue-800" />
</div>
</div>
);

const PersonalDetailsDataItem: React.FC<{ title: string; value: string | number }> = ({ title, value }) => (
<div className="border-b border-navy-200 px-4 py-6 sm:col-span-2 sm:px-0">
<dt>
<Typography variant="body-m/medium">{title}</Typography>
</dt>
<dd>
<Typography variant="body-m/regular" className="mt-1 text-navy-600 sm:mt-2">
{value}
</Typography>
</dd>
</div>
);

const LadderDataItem: React.FC<{ title: string; value: string | number }> = ({ title, value }) => (
<div>
<dt>
<Typography variant="body-m/medium">{title}</Typography>
</dt>
<dd>
<Typography variant="body-m/regular" className="mt-1 text-navy-600 sm:mt-2">
{value}
</Typography>
</dd>
</div>
);

return (
<div>
<Breadcrumbs
Expand Down
37 changes: 37 additions & 0 deletions frontend/src/components/pages/ProfileSetting/utils.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { ReactNode } from 'react';
import { Typography } from '@app/components/common/Typography';

export const NotificationCheckbox: React.FC<{ icon: ReactNode }> = ({ icon }) => (
<div className="flex flex-col items-center">
<div className="mb-6 text-navy-500">{icon}</div>
<div className="flex h-6 items-center">
<input type="checkbox" className="border-gray-300 h-4 w-4 rounded text-blue-800 focus:ring-blue-800" />
</div>
</div>
);

export const PersonalDetailsDataItem: React.FC<{ title: string; value: string | number }> = ({ title, value }) => (
<div className="border-b border-navy-200 px-4 py-6 sm:col-span-2 sm:px-0">
<dt>
<Typography variant="body-m/medium">{title}</Typography>
</dt>
<dd>
<Typography variant="body-m/regular" className="mt-1 text-navy-600 sm:mt-2">
{value}
</Typography>
</dd>
</div>
);

export const LadderDataItem: React.FC<{ title: string; value: string | number }> = ({ title, value }) => (
<div>
<dt>
<Typography variant="body-m/medium">{title}</Typography>
</dt>
<dd>
<Typography variant="body-m/regular" className="mt-1 text-navy-600 sm:mt-2">
{value}
</Typography>
</dd>
</div>
);

0 comments on commit 5d95aa7

Please sign in to comment.