Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 18 additions & 2 deletions frontend-next-migration/src/entities/Clan/types/clan.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@ export type IClan = {
phrase: string;
labels: Array[];
positionLeaderboard?: number;

roles: IClanRole[];
goal: string;
clanLogo: string;
battlePoints: number;
language: string;
points: number;
ageRange: string;
};

export type IClanRole = {
_id: string;
name: string;
clanRoleType: string;
rights?: Record<string, boolean>;
};

export type IClanPosition = {
Expand All @@ -37,11 +52,12 @@ export type ICreateClanResponse = {
export type IJoin = {
clan_id: string;
player_id: string;
join_message: string;
};

export type IClanCreateDto = Pick<IClan, 'name' | 'tag' | 'phrase' | 'labels' | 'isOpen'>;

export type IClanUpdateDto = Pick<IClan, '_id' | 'name' | 'tag' | 'phrase' | 'labels' | 'isOpen'>;

export type IJoinDto = Pick<IJoin, 'clan_id' | 'player_id' | 'join_message'>;
export type IJoinDto = Pick<IJoin, 'clan_id' | 'player_id'>;

export type IClanRoleDto = Pick<IClanRole, '_id' | 'name' | 'clanRoleType'>;
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@ describe('useJoinClan', () => {
const { result } = renderHook(() => useJoinClan());

await act(async () => {
await result.current.handleJoin('clan_id', 'player_id', 'join_message');
await result.current.handleJoin('clan_id', 'player_id');
});

expect(mockJoinClan).toHaveBeenCalledWith({
clan_id: 'clan_id',
player_id: 'player_id',
join_message: 'join_message',
});
expect(toast.success).toHaveBeenCalledWith('toast_join_success');
});
Expand All @@ -48,13 +47,12 @@ describe('useJoinClan', () => {
const { result } = renderHook(() => useJoinClan());

await act(async () => {
await result.current.handleJoin('clan_id', 'player_id', 'join_message');
await result.current.handleJoin('clan_id', 'player_id');
});

expect(mockJoinClan).toHaveBeenCalledWith({
clan_id: 'clan_id',
player_id: 'player_id',
join_message: 'join_message',
});
expect(toast.error).toHaveBeenCalledWith(`"${errorMessage}"`);
});
Expand All @@ -66,7 +64,7 @@ describe('useJoinClan', () => {
const { result } = renderHook(() => useJoinClan());

await act(async () => {
await result.current.handleJoin('clan_id', 'player_id', 'join_message', onSuccessMock);
await result.current.handleJoin('clan_id', 'player_id', onSuccessMock);
});

expect(onSuccessMock).toHaveBeenCalled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,8 @@ const useJoinClan = () => {
const [joinClan] = useJoinClanMutation();

// todo good function should not use too much params, think if you could group some or all params to object group(s)
const handleJoin = async (
clan_id: string,
player_id: string,
join_message: string,
onSuccess?: () => void,
) => {
const result = await joinClan({ clan_id, player_id, join_message });
const handleJoin = async (clan_id: string, player_id: string, onSuccess?: () => void) => {
const result = await joinClan({ clan_id, player_id });
// @ts-ignore todo figure out ts
if (result?.error) {
// @ts-ignore todo figure out ts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ const ClanInfo = (props: Props) => {
className={cls.JoinClanBtn}
theme={ButtonTheme.Graffiti}
size={ButtonSize.L}
onClick={() => handleJoin(clanData._id, playerId ?? '', 'join')}
onClick={() => handleJoin(clanData._id, playerId ?? '')}
>
{joinClanBtn}
</Button>
Expand Down