Skip to content

Commit e6c0fd1

Browse files
jajakobrschlaefli
andcommitted
refactor: redesign platform service structure (#39)
* refactoring action reducer * change match to switch statement in action reducer * fix _run scripts * rework actions reducer with immer * first step of rework * removing payload variable from period result reducer * tiny revisit of SegementReducer * fix result.facts passed to period start * prototype separate reducer fns suggestion * period reducer separate fns: adding payload types * Segment Reducer to separate fns * period result separate fns * segment result separate fns, some renaming of previous payload types * additional todos and clean up * move action types to platform and add todos * removing action types for input and ouput of reducer fns * isDirty todo, minor cleanup * remove ResultState for now * remove comment wrt userrole in demo-game * remove todo comment wrt roleAssigner * introduce settings/constants * period reducer: remove isDirty and return result directly * period reducer: remove isDirty and return result directly consolidate * segment reducer: remove isDirty and return result directly * period result reducer typed * adding brackets for type union * segment result reducer, remove isDirty and typed * segment result reducer, remove isDirty and typed, missed return type * moving mapper into if statement * update design system to 2.7.0 latest version * making roleAssigner work with undefined players * using OutputFacts platform type for user output types * replace state with facts and added all output types * rename result to resultFacts * rename reducers to services * move types from graphql to separate folder types * segment initializer clean input and output type * clean up input output types for services --------- Co-authored-by: Roland Schläfli <rolandschlaefli@gmail.com>
1 parent b7af34d commit e6c0fd1

29 files changed

+1730
-694
lines changed

_run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/sh
22
cd apps/demo-game
3-
podman-compose up
3+
docker compose up

apps/demo-game/_run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/bin/sh
2-
podman-compose up
2+
docker compose up

apps/demo-game/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
"@gbl-uzh/ui": "workspace:*",
1414
"@next-auth/prisma-adapter": "1.0.7",
1515
"@prisma/client": "5.14.0",
16-
"@uzh-bf/design-system": "1.8.0",
16+
"@uzh-bf/design-system": "2.7.0",
1717
"date-fns": "2.30.0",
1818
"formik": "2.4.3",
1919
"graphql": "16.8.0",
2020
"graphql-sse": "2.2.3",
2121
"graphql-yoga": "4.0.4",
2222
"i18next": "22.5.0",
23+
"immer": "10.1.1",
2324
"jsonwebtoken": "9.0.2",
2425
"next": "14.2.4",
2526
"next-auth": "4.23.1",
@@ -47,6 +48,7 @@
4748
"@tsconfig/node18": "18.2.1",
4849
"@tsconfig/recommended": "1.0.2",
4950
"@types/node": "^18.11.9",
51+
"@types/ramda": "^0.28.25",
5052
"@types/react": "^18.0.25",
5153
"@types/react-dom": "^18.0.0",
5254
"autoprefixer": "10.4.15",

apps/demo-game/src/components/RootLayout.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,15 @@ import { sourceSansPro } from '@lib/fonts'
33
import type { PropsWithChildren } from 'react'
44

55
export default function RootLayout({ children }: PropsWithChildren) {
6-
return <div className={sourceSansPro.variable}>{children}</div>
6+
return (
7+
<div className={sourceSansPro.variable}>
8+
{children}
9+
<style jsx global>{`
10+
:root {
11+
--source-sans-pro: ${sourceSansPro.variable};
12+
--theme-font-primary: ${sourceSansPro.variable};
13+
}
14+
`}</style>
15+
</div>
16+
)
717
}

apps/demo-game/src/graphql/index.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
1-
import { UserRole } from '@gbl-uzh/platform'
21
import {
32
generateBaseMutations,
43
generateBaseQueries,
54
generateBaseSubscriptions,
65
} from '@gbl-uzh/platform/dist/nexus'
7-
import * as reducers from '../reducers'
8-
import type { PeriodFacts, PeriodSegmentFacts } from './types'
6+
import type { PeriodFacts, PeriodSegmentFacts } from '../../src/types/Period'
7+
import * as services from '../services'
98
import {
109
PeriodFactsInput,
1110
PeriodFactsSchema,
1211
PeriodSegmentFactsInput,
1312
PeriodSegmentFactsSchema,
14-
} from './types'
13+
} from '../types'
1514
export * from '@gbl-uzh/platform/dist/nexus'
16-
export * from './types'
15+
export * from '../types'
1716

1817
export const Query = generateBaseQueries()
1918
export const Mutation = generateBaseMutations<PeriodFacts, PeriodSegmentFacts>({
20-
// TODO(JJ): Double-check with RS
21-
roleAssigner: (ix) => UserRole.PLAYER,
22-
reducers,
19+
services,
2320
schemas: {
2421
PeriodFactsSchema,
2522
PeriodSegmentFactsSchema,

apps/demo-game/src/pages/play/cockpit.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
PerformActionDocument,
66
ResultDocument,
77
} from 'src/graphql/generated/ops'
8-
import { ActionTypes } from 'src/reducers/ActionsReducer'
8+
import { ActionTypes } from 'src/services/ActionsReducer'
99

1010
function Cockpit() {
1111
const playerState = useQuery(ResultDocument, { fetchPolicy: 'cache-first' })

apps/demo-game/src/reducers/ActionsReducer.ts

Lines changed: 0 additions & 57 deletions
This file was deleted.

apps/demo-game/src/reducers/PeriodReducer.ts

Lines changed: 0 additions & 51 deletions
This file was deleted.

apps/demo-game/src/reducers/PeriodResultReducer.ts

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)