Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ea2bef7
feat: user info
AmarTrebinjac Oct 8, 2025
b8c5ad8
feat: profile header
AmarTrebinjac Oct 9, 2025
b335b2b
feat: basic form
AmarTrebinjac Oct 9, 2025
0049191
feat: submit form
AmarTrebinjac Oct 9, 2025
d73f8ce
feat: all fields ready
AmarTrebinjac Oct 12, 2025
d8e0433
add button
AmarTrebinjac Oct 12, 2025
c552411
create hook form
AmarTrebinjac Oct 12, 2025
dee20fc
update button colors
AmarTrebinjac Oct 12, 2025
c3172ed
add location image
AmarTrebinjac Oct 13, 2025
93c89ab
update function names
AmarTrebinjac Oct 13, 2025
b239a45
use correct ids for location type
AmarTrebinjac Oct 13, 2025
5fedf1a
add edit button
AmarTrebinjac Oct 13, 2025
20d5e24
turn off autocomplete
AmarTrebinjac Oct 13, 2025
10a89b2
Merge remote-tracking branch 'origin/MI-1027-profile' into MI-1067
AmarTrebinjac Oct 13, 2025
2fe1b5e
update user stats
AmarTrebinjac Oct 13, 2025
53bc1d9
fix tests
AmarTrebinjac Oct 13, 2025
2f7a221
remove stats no longer displayed
AmarTrebinjac Oct 13, 2025
324881e
render only profileindex
AmarTrebinjac Oct 13, 2025
31cfc71
remove reputation changes
AmarTrebinjac Oct 14, 2025
03422ee
feedback
AmarTrebinjac Oct 14, 2025
203526b
Update packages/shared/src/graphql/users.ts
AmarTrebinjac Oct 14, 2025
9560d94
Update packages/webapp/pages/[userId]/index.tsx
AmarTrebinjac Oct 14, 2025
d174457
add profile actions
AmarTrebinjac Oct 14, 2025
ad530d8
dynamic import profile actions
AmarTrebinjac Oct 14, 2025
ff0e469
update form names
AmarTrebinjac Oct 15, 2025
3331ac4
add cover upload to endpoint
AmarTrebinjac Oct 15, 2025
70872b0
clear image properly
AmarTrebinjac Oct 15, 2025
63c8907
move debouncer
AmarTrebinjac Oct 15, 2025
daf6ba5
clear dependency
AmarTrebinjac Oct 15, 2025
d8636d0
refactor: code clean up
sshanzel Oct 16, 2025
acad10c
refactor: usage of existing hook
sshanzel Oct 16, 2025
34289ad
fix: empty loc
sshanzel Oct 16, 2025
4f4c6ff
feat: autofill profile cv upload (#5004)
sshanzel Oct 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 108 additions & 0 deletions packages/shared/src/components/fields/Autocomplete.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import { Popover, PopoverAnchor } from '@radix-ui/react-popover';
import React, { useRef, useState } from 'react';
import classNames from 'classnames';
import type { TextFieldProps } from './TextField';
import { TextField } from './TextField';
import { PopoverContent } from '../popover/Popover';
import { Typography } from '../typography/Typography';
import { GenericLoaderSpinner } from '../utilities/loaders';
import { IconSize } from '../Icon';

interface AutocompleteProps
extends Omit<TextFieldProps, 'inputId' | 'onChange' | 'onSelect'> {
name: string;
onChange: (value: string) => void;
onSelect: (value: string) => void;
selectedValue?: string;
options: Array<{ value: string; label: string }>;
isLoading?: boolean;
}

const Autocomplete = ({
name,
isLoading,
options,
onChange,
onSelect,
selectedValue,
defaultValue,
...restProps
}: AutocompleteProps) => {
const [input, setInput] = useState(defaultValue || '');
const [isOpen, setIsOpen] = useState(false);
const inputRef = useRef<HTMLInputElement | null>(null);
const handleChange = (val: string) => {
setInput(val);
onChange(val);
};
const handleSelect = (opt: { value: string; label: string }) => {
setInput(opt.label);
onSelect(opt.value);
setIsOpen(false);
inputRef.current?.focus();
};
const handleBlur = () => {
setIsOpen(false);
setInput(options.find((opt) => opt.value === selectedValue)?.label || '');
};

return (
<Popover open={isOpen}>
<PopoverAnchor asChild>
<TextField
inputRef={(ref) => {
inputRef.current = ref;
}}
inputId={name}
{...restProps}
onChange={(e) => {
handleChange(e.target.value);
setIsOpen(true);
}}
onFocus={() => setIsOpen(true)}
onBlur={handleBlur}
value={input}
autoComplete="off"
/>
</PopoverAnchor>
<PopoverContent
className="rounded-16 border border-border-subtlest-tertiary bg-background-popover p-4 data-[side=bottom]:mt-1 data-[side=top]:mb-1"
side="bottom"
align="start"
avoidCollisions
sameWidthAsAnchor
onOpenAutoFocus={(e) => e.preventDefault()} // keep focus in input
onCloseAutoFocus={(e) => e.preventDefault()} // avoid refocus jumps
>
{!isLoading ? (
<div className="flex w-full flex-col">
{options?.length > 0 ? (
options.map((opt) => (
<button
type="button"
className={classNames(
'text-left',
selectedValue === opt.value && 'font-bold',
)}
key={opt.value}
onMouseDown={(e) => {
e.preventDefault();
handleSelect(opt);
}}
>
{opt.label}
</button>
))
) : (
<Typography>No results</Typography>
)}
</div>
) : (
<GenericLoaderSpinner className="mx-auto" size={IconSize.Small} />
)}
</PopoverContent>
</Popover>
);
};

export default Autocomplete;
34 changes: 34 additions & 0 deletions packages/shared/src/components/fields/ControlledTextField.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Controller, useFormContext } from 'react-hook-form';
import React from 'react';
import type { TextFieldProps } from './TextField';
import { TextField } from './TextField';

type ControlledTextFieldProps = Pick<
TextFieldProps,
'name' | 'label' | 'leftIcon' | 'placeholder' | 'hint'
>;

const ControlledTextField = ({
name,
hint,
...restProps
}: ControlledTextFieldProps) => {
const { control } = useFormContext();

return (
<Controller
control={control}
name={name}
render={({ field, fieldState }) => (
<TextField
inputId={field.name}
{...restProps}
{...field}
valid={!fieldState.error}
hint={fieldState.error ? fieldState.error.message : hint}
/>
)}
/>
);
};
export default ControlledTextField;
28 changes: 28 additions & 0 deletions packages/shared/src/components/fields/ControlledTextarea.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react';
import { Controller, useFormContext } from 'react-hook-form';
import Textarea from './Textarea';
import type { BaseFieldProps } from './BaseFieldContainer';

const ControlledTextarea = ({
name,
...restProps
}: Pick<BaseFieldProps<HTMLTextAreaElement>, 'name' | 'label'>) => {
const { control } = useFormContext();

return (
<Controller
control={control}
name={name}
render={({ field, fieldState }) => (
<Textarea
inputId={field.name}
{...restProps}
{...field}
valid={!fieldState.error}
/>
)}
/>
);
};

export default ControlledTextarea;
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from 'react';
import { Controller, useFormContext } from 'react-hook-form';
import MarkdownInput from '.';

const ControlledMarkdownInput = ({
name,
rules,
...props
}: {
name: string;
rules?: Record<string, unknown>;
} & React.ComponentProps<typeof MarkdownInput>) => {
const { control, setValue } = useFormContext();
return (
<Controller
name={name}
control={control}
rules={rules}
render={({ field }) => (
<MarkdownInput
{...props}
{...field}
initialContent={field.value}
onValueUpdate={(value) => setValue(name, value)}
/>
)}
/>
);
};

export default ControlledMarkdownInput;
71 changes: 71 additions & 0 deletions packages/shared/src/components/fields/Select.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { Controller, useFormContext } from 'react-hook-form';
import React from 'react';
import { ArrowIcon } from '../icons';
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuOptions,
DropdownMenuTrigger,
} from '../dropdown/DropdownMenu';
import type { ButtonProps, IconType } from '../buttons/Button';
import { Button, ButtonVariant } from '../buttons/Button';
import type { MenuItemProps } from '../dropdown/common';

type SelectProps = {
name: string;
options: { value: string; label: string }[];
placeholder?: string;
icon?: IconType;
buttonProps?: ButtonProps<'button'>;
};

const Select = ({
name,
options,
placeholder,
icon,
buttonProps,
}: SelectProps) => {
const { control, setValue } = useFormContext();

const menuItems: MenuItemProps[] = options.map((opt) => {
return {
label: opt.label,
action: () => setValue(name, opt.value),
};
});

return (
<Controller
name={name}
control={control}
render={({ field }) => (
<>
<input type="hidden" {...field} />
<DropdownMenu>
<DropdownMenuTrigger className="w-full" asChild>
<Button
icon={icon}
variant={ButtonVariant.Float}
{...buttonProps}
>
{options.find((opt) => opt.value === field.value)?.label ||
placeholder}
<ArrowIcon className="ml-auto rotate-180" secondary />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent
align="start"
sideOffset={10}
className="flex w-[var(--radix-popper-anchor-width)] flex-col gap-1 overflow-y-auto overflow-x-hidden !p-0"
>
<DropdownMenuOptions options={menuItems} />
</DropdownMenuContent>
</DropdownMenu>
</>
)}
/>
);
};

export default Select;
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import React from 'react';
import { CameraIcon, ClearIcon } from '../icons';
import { IconSize } from '../Icon';
import { Button, ButtonSize, ButtonVariant } from '../buttons/Button';
import { fallbackImages } from '../../lib/config';
import { useControlledImageUpload } from '../../hooks/useControlledImageUpload';

interface ControlledAvatarUploadProps {
name: string;
currentImageName: string;
fileSizeLimitMB?: number;
}

const ControlledAvatarUpload = ({
name,
currentImageName,
fileSizeLimitMB = 1,
}: ControlledAvatarUploadProps) => {
const {
displayImage,
inputRef,
onFileChange,
onDragOver,
onDrop,
onUploadClick,
onRemove,
acceptedTypes,
} = useControlledImageUpload({
name,
fileSizeLimitMB,
currentImageName,
fallbackImage: fallbackImages.avatar,
});

return (
<div
className="group relative size-[120px]"
onDragOver={onDragOver}
onDrop={onDrop}
>
<div className="relative size-full overflow-hidden rounded-26">
<img
src={displayImage}
alt="Profile avatar"
className="size-full object-cover"
data-testid="image_avatar_file"
/>
</div>
<div className="cursor:pointer absolute top-0 flex h-full w-full items-center justify-center gap-2 rounded-26">
<Button
type="button"
className="bg-shadow-shadow3"
variant={ButtonVariant.Float}
size={ButtonSize.Small}
icon={<CameraIcon size={IconSize.Medium} />}
onClick={onUploadClick}
/>
<Button
type="button"
className="bg-shadow-shadow3"
variant={ButtonVariant.Float}
size={ButtonSize.Small}
icon={<ClearIcon size={IconSize.Medium} />}
onClick={onRemove}
/>
</div>
<input
ref={inputRef}
type="file"
accept={acceptedTypes}
className="hidden"
onChange={onFileChange}
/>
</div>
);
};

export default ControlledAvatarUpload;
Loading