-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9523694
commit d64b9d9
Showing
21 changed files
with
2,485 additions
and
4,742 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 0 additions & 53 deletions
53
src/app/[locale]/(private)/profile/components/contact-editor.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
140 changes: 140 additions & 0 deletions
140
src/app/[locale]/(private)/profile/components/editable-field.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
import React, { useState } from 'react'; | ||
import { Input } from '@/components/ui/input'; | ||
import { Button } from '@/components/ui/button'; | ||
import { Paragraph } from '@/components/typography/paragraph'; | ||
import { PencilBold, XBold } from '@/app/images'; | ||
import { Show } from '@/components/utils/show'; | ||
import { useTranslations } from 'next-intl'; | ||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip'; | ||
import { | ||
AlertDialog, | ||
AlertDialogAction, | ||
AlertDialogCancel, | ||
AlertDialogContent, | ||
AlertDialogDescription, | ||
AlertDialogFooter, | ||
AlertDialogHeader, | ||
AlertDialogTitle, | ||
AlertDialogTrigger, | ||
} from '@/components/ui/alert-dialog'; | ||
import { Heading6 } from '@/components/typography/headers'; | ||
|
||
interface EditableFieldProps { | ||
onSave: (newValue: string) => void; | ||
size?: 'small' | 'medium'; | ||
value?: string; | ||
onDelete?: () => void; | ||
label?: string; | ||
renderValue?: (value: string) => React.ReactNode; | ||
disableClearValue?: boolean; | ||
placeholder?: string; | ||
} | ||
|
||
export function EditableField({ | ||
onSave, | ||
value, | ||
size = 'medium', | ||
onDelete, | ||
label, | ||
renderValue, | ||
disableClearValue = false, | ||
placeholder, | ||
}: EditableFieldProps) { | ||
const t = useTranslations('private.profile'); | ||
const [isEditing, setIsEditing] = useState(!value); | ||
const [currentValue, setCurrentValue] = useState(value || ''); | ||
|
||
const handleSave = () => { | ||
onSave(currentValue); | ||
setIsEditing(false); | ||
}; | ||
|
||
const handleDelete = () => { | ||
if (onDelete) { | ||
onDelete(); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className="group flex flex-col items-start gap-4 xl:flex-row xl:items-center"> | ||
<Show when={!!label}> | ||
<Paragraph className="m-0 w-full min-w-[170px] max-w-[250px] font-semibold text-neutral-400"> | ||
{label}: | ||
</Paragraph> | ||
</Show> | ||
|
||
{isEditing ? ( | ||
<div className="flex w-full flex-wrap items-center gap-2 md:flex-nowrap"> | ||
<Input | ||
size={size} | ||
className="text-lg font-medium text-neutral-900" | ||
value={currentValue} | ||
onChange={(e) => setCurrentValue(e.target.value)} | ||
placeholder={placeholder} | ||
/> | ||
<Button size={size} onClick={handleSave}> | ||
{t('button.save')} | ||
</Button> | ||
</div> | ||
) : ( | ||
<div className="flex flex-wrap justify-between gap-4 md:flex-nowrap"> | ||
{renderValue ? renderValue(currentValue) : <Paragraph className="m-0 font-medium">{currentValue}</Paragraph>} | ||
<div className="flex gap-2 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100"> | ||
<TooltipProvider> | ||
<Tooltip> | ||
<TooltipTrigger> | ||
<Button | ||
variant="tertiary" | ||
className="size-6" | ||
icon={<PencilBold className="text-basic-blue" />} | ||
onClick={() => setIsEditing(true)} | ||
/> | ||
</TooltipTrigger> | ||
<TooltipContent> | ||
<p>{t('contact.edit-contact')}</p> | ||
</TooltipContent> | ||
</Tooltip> | ||
</TooltipProvider> | ||
|
||
{!disableClearValue && onDelete && ( | ||
<AlertDialog> | ||
<TooltipProvider> | ||
<Tooltip> | ||
<TooltipTrigger asChild> | ||
<AlertDialogTrigger asChild> | ||
<Button | ||
variant="tertiary" | ||
className="size-6" | ||
icon={<XBold className="text-status-danger-300" />} | ||
/> | ||
</AlertDialogTrigger> | ||
</TooltipTrigger> | ||
<TooltipContent> | ||
<p>{t('contact.delete-contact')}</p> | ||
</TooltipContent> | ||
</Tooltip> | ||
</TooltipProvider> | ||
<AlertDialogContent className="w-[400px]"> | ||
<AlertDialogHeader> | ||
<AlertDialogTitle> | ||
<Heading6>{t('contact.delete-dialog-title')}</Heading6> | ||
</AlertDialogTitle> | ||
<AlertDialogDescription className="text-base font-medium"> | ||
{t('contact.delete-dialog-description')} | ||
</AlertDialogDescription> | ||
</AlertDialogHeader> | ||
<AlertDialogFooter className="flex h-[44px] flex-col sm:flex-row sm:justify-between sm:space-x-2"> | ||
<AlertDialogCancel className="w-full">{t('contact.delete-dialog-cancel')}</AlertDialogCancel> | ||
<AlertDialogAction className="w-full" onClick={handleDelete}> | ||
{t('contact.delete-dialog-confirm')} | ||
</AlertDialogAction> | ||
</AlertDialogFooter> | ||
</AlertDialogContent> | ||
</AlertDialog> | ||
)} | ||
</div> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
} |
40 changes: 0 additions & 40 deletions
40
src/app/[locale]/(private)/profile/components/fullname-english.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/app/[locale]/(private)/profile/components/info-list.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Paragraph } from '@/components/typography/paragraph'; | ||
|
||
export type InfoItem = { | ||
label: string; | ||
value?: number | string; | ||
}; | ||
|
||
interface Props { | ||
items: InfoItem[]; | ||
} | ||
|
||
export function InfoList({ items }: Props) { | ||
return ( | ||
<div className="flex flex-col gap-4"> | ||
{items.map((item, index) => ( | ||
<div key={index} className="flex flex-col gap-3 md:flex-row md:gap-6"> | ||
<Paragraph className="m-0 w-[170px] font-semibold text-neutral-400">{item.label}:</Paragraph> | ||
<Paragraph className="m-0 font-medium">{item.value}</Paragraph> | ||
</div> | ||
))} | ||
</div> | ||
); | ||
} |
Oops, something went wrong.