Skip to content

naprawa przypisania menedżerów liniowych + możliwość wyboru menedżera#51

Merged
mtrznadel24 merged 4 commits into
developfrom
IP-104-Naprawa-przypisania-menedzera-liniowego-w-panelu-admina
May 11, 2026
Merged

naprawa przypisania menedżerów liniowych + możliwość wyboru menedżera#51
mtrznadel24 merged 4 commits into
developfrom
IP-104-Naprawa-przypisania-menedzera-liniowego-w-panelu-admina

Conversation

@FAZ110

@FAZ110 FAZ110 commented May 10, 2026

Copy link
Copy Markdown
Owner

na szybko troche ale działa, w bazie się dobrze zapisuje, jak coś jest nie tak to się poprawi

… przez admina podczas tworzenia konta pracownika
AdminAssignableRole role
AdminAssignableRole role,

UUID supervisorId

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tutaj reguła walidacji by się przydała, tak jak wyżej

public ResponseEntity<List<SimpleUserResponse>> searchUsers(@RequestParam("search") String search) {
public ResponseEntity<List<SimpleUserResponse>> searchUsers(
@RequestParam("search") String search,
@RequestParam(required = false) UserRole userRole

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nie możemy korzystać tutaj z typu UserRole bo to jest typ bazodanowy z naszej encji użytkownika, najlepiej jakbyś dodał nowy typ w stylu UserSearchableRole i tam skopiował te wartości w stylu LINEAR, COMMON etc po prostu wszystko co uważasz za zasadne do wyszukiwania. Na którymś późniejszym etapie należy zrobić po prostu mapowanie tego na UserRole

},

searchUsers: async (searchTerm: string): Promise<SimpleUserResponse[]> => {
searchUsers: async (searchTerm: string, userRole?: string): Promise<SimpleUserResponse[]> => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tutaj na pewno typ danych się nie zgadza, userRole nie może być stringiem, trzeba utworzyć jakiś nowy typ zgodny zapewne z moim wcześniejszym komentarzem, tzn UserSearchableRole

export const useSearchLinearManagers = (searchTerm: string) => {
return useQuery({
queryKey: usersKeys.search(`LINEAR_MANAGER:${searchTerm}`).queryKey,
queryFn: () => userManagementService.searchUsers(searchTerm, 'LINEAR_MANAGER'),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'LINEAR_MANAGER' to jest zhardcodowane, trzeba się tego pozbyć

};

const onSubmit = handleSubmit((data) => {
if (data.role === 'COMMON' && !data.supervisorId) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'COMMON' to ma znowu związek z brakiem odpowiedniego typu danych

watchedRole,
onManagerSelect,
managerError,
}: InviteUserModalViewProps) => (

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tutaj się pojawia zbyt dużo propsów, skorzystaj z useFormContext, żeby pozbyć się przekazywania tego. Najlepiej jakbyś w ogóle skorzystał z tego co dostarcza ta biblioteka tzn FormProvider bo tam jest wbudowana obsługa błędów itp. bardzo dużo rzeczy których nie trzeba samemu pisać np. mozna uniknąć tego:
const [managerError, setManagerError] = useState<string | undefined>();

{errors.role && <span className="text-red-500 text-xs">{errors.role.message}</span>}
</div>

{watchedRole === 'COMMON' && (

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'COMMON' do zmiany na AdminAssignableRole.COMMON

@rrogalski rrogalski left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jedna rzecz razi w oczy, poza tym wygląda w porządku

) {
if (userRole != null) {
return ResponseEntity.ok(userService.searchUsersByRole(search, userRole));
return ResponseEntity.ok(userService.searchUsersByRole(search, UserRole.valueOf(userRole.name())));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UserRole.valueOf(userRole.name()) to jest bardzo chamskie rozwiązanie bo zadziała na podstawie porównywania stringów czyli zmapuje poprawnie tylko jeśli tekst będzie się zgadzać, lepiej do takich rzeczy robić switcha

switch(userRole):
COMMON -> UserRole.COMMON

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dobra sory, zaraz poprawie

@mtrznadel24 mtrznadel24 merged commit c75c218 into develop May 11, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants