Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/further improve match creation ux #139

Merged
merged 36 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
9594ece
style: fix broken match header
LinusBolls Nov 22, 2024
e56916e
fix: some refetching not working
LinusBolls Nov 22, 2024
bc28905
fix: match view not displaying data
LinusBolls Nov 22, 2024
9f4d1f7
fix: empty match
LinusBolls Nov 23, 2024
5d38889
style: player match item
LinusBolls Nov 23, 2024
ee6ddf2
debug: log failed requests in debug logs
LinusBolls Nov 23, 2024
1d3bcb4
fix: misleading websocket state indicator
LinusBolls Nov 25, 2024
3d0d196
fix: reconnect websocket on close
LinusBolls Nov 25, 2024
6b049b0
fix: web socket status in debug logs
LinusBolls Nov 25, 2024
509b7b8
style: fix groups button getting cut off
LinusBolls Nov 25, 2024
5a2fe95
fix: hide broken rules screen behind feature flag
LinusBolls Nov 25, 2024
df089bc
chore: modal to assign player points
LinusBolls Nov 25, 2024
fd62a2f
fix: overflowing player list not scrollable
LinusBolls Nov 25, 2024
985eafd
style: fix layout shift in match vs header
LinusBolls Nov 25, 2024
a27eea8
feat: prevent new players with the same name as existing players from…
LinusBolls Nov 25, 2024
3ba7f13
feat: add haptic feedback to input errors
LinusBolls Nov 25, 2024
8ba0245
feat: success toast for creating a player
LinusBolls Nov 25, 2024
67b622f
Merge remote-tracking branch 'origin' into debug/websocket-disconnect
LinusBolls Nov 25, 2024
ec038de
Merge remote-tracking branch 'origin' into debug/websocket-disconnect
LinusBolls Nov 25, 2024
7791c1f
Merge branch 'staging' into feat/improve-match-creation-ux
LinusBolls Nov 26, 2024
8787470
chore: minor mobile app version bump
LinusBolls Nov 26, 2024
4ed58cf
style: display player initials on avatar while profile picture hasnt …
LinusBolls Nov 26, 2024
ef6ba85
chore: screen in case no finish move has been defined for a match
LinusBolls Nov 26, 2024
39b26c2
Merge branch 'feat/improve-match-creation-ux' of https://github.com/l…
LinusBolls Nov 26, 2024
1357fd1
Merge branch 'staging' into feat/improve-match-creation-ux
LinusBolls Nov 26, 2024
9f4a2a2
feat: prevent creating two players with the same name during group cr…
LinusBolls Nov 26, 2024
e703e11
fix: modal re-opening after dismissing (really bad fix that doesnt wo…
LinusBolls Nov 26, 2024
dd97f60
feat: functional flow for assigning finish move
LinusBolls Nov 26, 2024
1fa6b04
fix: scuffed dirty hacky fix for modal dismissal
LinusBolls Nov 27, 2024
4bc8882
feat: enable new match creation flow
LinusBolls Nov 27, 2024
a777c05
feat: further increase match creation ux
LinusBolls Nov 28, 2024
2ddb9a0
fix: player page styling
LinusBolls Nov 28, 2024
a43ee38
fix: remove highest and lowest indicator from player stats from produ…
LinusBolls Dec 5, 2024
d22b547
Merge branch 'staging' into feat/further-improve-match-creation-ux
LinusBolls Dec 5, 2024
f87d1db
style: branding assets
LinusBolls Dec 5, 2024
2f221eb
fix: remove lint errors
LinusBolls Dec 5, 2024
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
21 changes: 20 additions & 1 deletion .github/workflows/api-staging-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,17 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- id: "setup-qemu"
- id: "setup-qemu"
name: Set up QEMU
uses: docker/setup-qemu-action@v3
- id: "docker-buildx-setup"
- id: "docker-buildx-setup"
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- id: "auth"
name: "Authenticate to Google Cloud"
uses: "google-github-actions/auth@v2"
- id: "auth"
name: "Authenticate to Google Cloud"
uses: "google-github-actions/auth@v2"
Expand All @@ -36,13 +41,18 @@ jobs:
token_format: access_token
workload_identity_provider: "projects/5685154754/locations/global/workloadIdentityPools/cd-beerpong/providers/github-actions"
service_account: "cd-beerpong@beer-pong-441815.iam.gserviceaccount.com"
- id: "login-gar"
workload_identity_provider: "projects/5685154754/locations/global/workloadIdentityPools/cd-beerpong/providers/github-actions"
service_account: "cd-beerpong@beer-pong-441815.iam.gserviceaccount.com"
- id: "login-gar"
name: "Login to GAR"
uses: docker/login-action@v3
with:
registry: europe-west10-docker.pkg.dev/beer-pong-441815/api-beerpong
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}
- id: "build-and-push"
name: "Build and Push docker Image"
- id: "build-and-push"
name: "Build and Push docker Image"
uses: docker/build-push-action@v6
Expand All @@ -66,6 +76,9 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- id: "auth"
name: "Authenticate to Google Cloud"
uses: "google-github-actions/auth@v2"
- id: "auth"
name: "Authenticate to Google Cloud"
uses: "google-github-actions/auth@v2"
Expand All @@ -74,13 +87,19 @@ jobs:
token_format: access_token
workload_identity_provider: "projects/5685154754/locations/global/workloadIdentityPools/cd-beerpong/providers/github-actions"
service_account: "cd-beerpong@beer-pong-441815.iam.gserviceaccount.com"
- id: "deploy"
uses: "google-github-actions/deploy-cloudrun@v2"
workload_identity_provider: "projects/5685154754/locations/global/workloadIdentityPools/cd-beerpong/providers/github-actions"
service_account: "cd-beerpong@beer-pong-441815.iam.gserviceaccount.com"
- id: "deploy"
uses: "google-github-actions/deploy-cloudrun@v2"
with:
service: "api-springboot-staging"
image: "europe-west10-docker.pkg.dev/beer-pong-441815/api-beerpong/api-staging:${{ github.sha }}"
service: "api-springboot-staging"
image: "europe-west10-docker.pkg.dev/beer-pong-441815/api-beerpong/api-staging:${{ github.sha }}"
region: europe-west10
flags: "--port=8080 --add-cloudsql-instances=beer-pong-441815:europe-west10:api-beerpong-pg --no-cpu-throttling --min-instances 0 --max-instances 1 --allow-unauthenticated"
flags: "--port=8080 --add-cloudsql-instances=beer-pong-441815:europe-west10:beerpong-staging-db --no-cpu-throttling --min-instances 0 --max-instances 1 --allow-unauthenticated"
env_vars: |
POSTGRES_USER=postgres
POSTGRES_URL=jdbc:postgresql:///beerpong-staging?cloudSqlInstance=beer-pong-441815:europe-west10:api-beerpong-pg&socketFactory=com.google.cloud.sql.postgres.SocketFactory
Expand Down
2 changes: 0 additions & 2 deletions mobile-app/api/calls/groupHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ export const useUpdateGroupWallpaperMutation = () => {
mutationFn: async (body) => {
const { byteArray, mimeType, ...rest } = body;

(await api).fetchData({ id: '' });

const res = await (
await api
)
Expand Down
2 changes: 0 additions & 2 deletions mobile-app/api/calls/playerHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ export const useUpdatePlayerAvatarMutation = () => {
mutationFn: async (body) => {
const { byteArray, mimeType, ...rest } = body;

(await api).fetchData({ id: '' });

const res = await (
await api
)
Expand Down
28 changes: 12 additions & 16 deletions mobile-app/app/(tabs)/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,18 @@ export default function TabLayout() {
...groupHeader,
}}
/>
{env.isDev && (
<Tabs.Screen
name="rules"
options={{
title: 'Rules',
tabBarIcon: ({ color }) => (
<Icon
color={color}
size={32}
name="format-section"
/>
),
...groupHeader,
}}
/>
)}
<Tabs.Screen
name="rules"
options={{
title: 'Rules',
tabBarIcon: ({ color }) => (
<Icon color={color} size={32} name="format-section" />
),
...groupHeader,
// hide tab in production
href: env.isDev ? undefined : null,
}}
/>
<Tabs.Screen
name="settings"
options={{
Expand Down
1 change: 1 addition & 0 deletions mobile-app/app/(tabs)/newMatch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default function Screen() {

async function onSubmit() {
nav.navigate('newMatchPoints');
nav.navigate('assignPointsToPlayerModal', { pageIdx: 0 });
}

return (
Expand Down
5 changes: 5 additions & 0 deletions mobile-app/app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ function Everything() {
<Stack.Screen name="createNewPlayer" options={modalStyles} />

<Stack.Screen name="editRankPlayersBy" options={modalStyles} />

<Stack.Screen
name="assignPointsToPlayerModal"
options={modalStyles}
/>
</Stack>
);
}
Expand Down
95 changes: 95 additions & 0 deletions mobile-app/app/assignPointsToPlayerModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import { useLocalSearchParams } from 'expo-router';
import React, { useState } from 'react';

import { usePlayersQuery } from '@/api/calls/playerHooks';
import { useMoves } from '@/api/calls/ruleHooks';
import { useGroup } from '@/api/calls/seasonHooks';
import { TeamMember } from '@/api/utils/matchDtoToMatch';
import AssignPointsToPlayerModal from '@/components/AssignPointsToPlayerModal';
import { useMatchDraftStore } from '@/zustand/matchDraftStore';

import { useNavigation } from './navigation/useNavigation';

export default function Page() {
const { pageIdx: initialPageIdx } = useLocalSearchParams<{
pageIdx: string;
}>();

const nav = useNavigation();

const [pageIdx, setPageIdx] = useState(parseInt(initialPageIdx));

const matchDraft = useMatchDraftStore();

const { groupId, seasonId } = useGroup();

const movesQuery = useMoves(groupId, seasonId);

const allowedMoves = movesQuery.data?.data ?? [];

const playersQuery = usePlayersQuery(groupId, seasonId);

const profiles = playersQuery.data?.data ?? [];

const players = matchDraft.actions.getPlayers();

const teamMembers = players.map<TeamMember>((i) => {
const profile = profiles.find((j) => i.playerId === j.id);

if (!profile?.profile?.name) {
throw new Error('failed to get profile for team member');
}

return {
id: i.playerId,
team: i.team,
avatarUrl: profile.profile.avatarAsset?.url,
name: profile.profile.name || 'Unknown',
points: i.moves.reduce(
(sum, j) =>
sum +
j.count *
(allowedMoves.find((k) => k.id === j.moveId)
?.pointsForScorer ?? 0),
0
),
change: 0.12,
moves: allowedMoves.map((j) => {
return {
id: j.id!,
count: i.moves.find((k) => k.moveId === j.id)?.count ?? 0,
title: j.name || 'Unknown',
points: j.pointsForScorer!,
pointsForTeam: j.pointsForTeam!,
isFinish: j.finishingMove!,
};
}),
};
});

const match = {
blueCups: players
.filter((i) => i.team === 'blue')
.map((i) => i.moves)
.flat()
.reduce((sum, i) => sum + i.count, 0),
redCups: players
.filter((i) => i.team === 'red')
.map((i) => i.moves)
.flat()
.reduce((sum, i) => sum + i.count, 0),
redTeam: teamMembers.filter((i) => i.team === 'red'),
blueTeam: teamMembers.filter((i) => i.team === 'blue'),
};

return (
<AssignPointsToPlayerModal
onClose={nav.goBack}
pageIdx={pageIdx}
setPageIdx={setPageIdx}
match={match}
isVisible={pageIdx != null}
setMoveCount={matchDraft.actions.setMoveCount}
/>
);
}
2 changes: 2 additions & 0 deletions mobile-app/app/navigation/useNavigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export type RootStackParamList = {
'static/aboutPremium': undefined;
'static/aboutUs': undefined;
debugLog: undefined;

assignPointsToPlayerModal: { pageIdx: number };
};
export type StackNavigation = NavigationProp<RootStackParamList>;

Expand Down
78 changes: 19 additions & 59 deletions mobile-app/app/newMatchPoints.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import { useGroup } from '@/api/calls/seasonHooks';
import { TeamMember } from '@/api/utils/matchDtoToMatch';
import { useNavigation } from '@/app/navigation/useNavigation';
import AssignFinishModeModal from '@/components/AssignFinishMoveModal';

Check warning on line 9 in mobile-app/app/newMatchPoints.tsx

View workflow job for this annotation

GitHub Actions / Lint Code

'AssignFinishModeModal' is defined but never used
import AssignPointsToPlayerModal from '@/components/AssignPointsToPlayerModal';

Check warning on line 10 in mobile-app/app/newMatchPoints.tsx

View workflow job for this annotation

GitHub Actions / Lint Code

'AssignPointsToPlayerModal' is defined but never used
import CreateMatchAssignPoints from '@/components/screens/CreateMatchAssignPoints';
import { Feature } from '@/constants/Features';

Check warning on line 12 in mobile-app/app/newMatchPoints.tsx

View workflow job for this annotation

GitHub Actions / Lint Code

'Feature' is defined but never used
import { showErrorToast } from '@/toast';
import { ConsoleLogger } from '@/utils/logging';
import { useMatchDraftStore } from '@/zustand/matchDraftStore';
Expand Down Expand Up @@ -84,8 +84,10 @@
async function onSubmit() {
if (!groupId || !seasonId) return;

if (Feature.POINTS_ASSIGNMENT_MODAL.isEnabled && !isValidGame) {
setShowFinishMoveModal(true);
if (!isValidGame) {
nav.navigate('assignPointsToPlayerModal', {
pageIdx: teamMembers.length,
});

return;
}
Expand All @@ -105,62 +107,20 @@
}

return (
<>
{Feature.POINTS_ASSIGNMENT_MODAL.isEnabled && (
<AssignPointsToPlayerModal
onClose={() => setPlayerIdx(null)}
playerIdx={playerIdx}
setPlayerIdx={setPlayerIdx}
match={{
blueCups: players
.filter((i) => i.team === 'blue')
.map((i) => i.moves)
.flat()
.reduce((sum, i) => sum + i.count, 0),
redCups: players
.filter((i) => i.team === 'red')
.map((i) => i.moves)
.flat()
.reduce((sum, i) => sum + i.count, 0),
redTeam: teamMembers.filter((i) => i.team === 'red'),
blueTeam: teamMembers.filter((i) => i.team === 'blue'),
}}
editable
isVisible={playerIdx != null}
setMoveCount={matchDraft.actions.setMoveCount}
/>
)}
<AssignFinishModeModal
onSubmit={(playerId, moveId) =>
matchDraft.actions.setMoveCount(playerId, moveId, 1)
}
onClose={() => setShowFinishMoveModal(false)}
isVisible={showFinishMoveModal}
match={{
blueCups: players
.filter((i) => i.team === 'blue')
.map((i) => i.moves)
.flat()
.reduce((sum, i) => sum + i.count, 0),
redCups: players
.filter((i) => i.team === 'red')
.map((i) => i.moves)
.flat()
.reduce((sum, i) => sum + i.count, 0),
redTeam: teamMembers.filter((i) => i.team === 'red'),
blueTeam: teamMembers.filter((i) => i.team === 'blue'),
}}
/>
<CreateMatchAssignPoints
players={teamMembers}
setMoveCount={matchDraft.actions.setMoveCount}
onSubmit={onSubmit}
onPlayerPress={(player) =>
setPlayerIdx(
teamMembers.findIndex((i) => i.id === player.id)
)
}
/>
</>
<CreateMatchAssignPoints
players={teamMembers}
setMoveCount={matchDraft.actions.setMoveCount}
onSubmit={onSubmit}
onCancel={() => {
matchDraft.actions.clear();
nav.goBack();
}}
onPlayerPress={(player) =>
// setPageIdx(teamMembers.findIndex((i) => i.id === player.id))
nav.navigate('assignPointsToPlayerModal', {
pageIdx: teamMembers.findIndex((i) => i.id === player.id),
})
}
/>
);
}
Binary file modified mobile-app/assets/images/adaptive-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified mobile-app/assets/images/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed mobile-app/assets/images/partial-react-logo.png
Binary file not shown.
Binary file removed mobile-app/assets/images/react-logo.png
Binary file not shown.
Binary file removed mobile-app/assets/images/react-logo@2x.png
Binary file not shown.
Binary file removed mobile-app/assets/images/react-logo@3x.png
Binary file not shown.
Binary file modified mobile-app/assets/images/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 61 additions & 0 deletions mobile-app/components/AssignPointsToPlayerModal/FinishMovePage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { ScrollView, View } from 'react-native';

import { PerformedMove, TeamMember } from '@/api/utils/matchDtoToMatch';

import Select from '../Select';
import Text from '../Text';

export default function FinishMovePage({
finisher,
onSetFinishMove,
}: {
finisher?: TeamMember | null;
onSetFinishMove: (move: PerformedMove) => void;
}) {
return (
<View style={{ flex: 1, width: '100%' }}>
<View
style={{
alignItems: 'center',

flex: 1,
}}
>
<Text color="primary" variant="h3">
{finisher
? `How did ${finisher.name} score the final cup?`
: 'Error'}
</Text>
<ScrollView
style={{
width: '100%',
}}
contentContainerStyle={{
paddingHorizontal: 16,
paddingTop: 96,
paddingBottom: 32,
}}
>
<Select
items={(finisher?.moves ?? [])
.filter((i) => i.isFinish)
.map((i) => ({
value: i.id,
title: i.title,
}))}
value={
finisher?.moves.find(
(i) => i.isFinish && i.count > 0
)?.id
}
onChange={(move) =>
onSetFinishMove(
finisher?.moves.find((i) => i.id === move)!
)
}
/>
</ScrollView>
</View>
</View>
);
}
Loading
Loading