Skip to content

Commit 90c6a4b

Browse files
committed
Move values into configuration, stop checking # of slots
Try and bring ACNW and ACUS together through: 1. Configuration values 2. Added configuration settings: Copyright holder in footer - config.copyright (string) Used to set range on min and max player in creating games - config.playerMin (positive integer) - config.playerMax (positive integer) - config.minPlayersFloor (positive integer) - config.minPlayersCeiling (positive integer) - config.maxPlayersFloor (positive integer) - config.maxPlayersCeiling (positive integer) Used by ACUS on its hotel page to allow people to book in its block of rooms: - config.hotelBookingCode (string) - config.hotelBookingUrl (string) - config.hotelBookingLastdate (date) Resolves: #155, #158, #160, #161 See also: #159
1 parent b892e59 commit 90c6a4b

File tree

6 files changed

+32
-35
lines changed

6 files changed

+32
-35
lines changed

packages/amber/components/Footer.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ export const Footer: React.FC = (_props) => {
5555
const commitDate = DateTime.fromISO(gitHash.date)
5656
const id = open ? 'simple-popover' : undefined
5757
const configuration = useConfiguration()
58-
const acus = configuration.numberOfSlots === 8
59-
const acnw = !acus
60-
const copyrightUrl = acnw ? 'amberconnw.org' : 'ambercon.com'
58+
const copyrightUrl = configuration.copyright
6159
return (
6260
<Box
6361
component='footer'

packages/amber/views/GameSignup/GameChoiceSelector.tsx

+3-16
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,11 @@ import { Game, GameChoice, GameEntry, Maybe } from '../../client'
88
import { Perms, useAuth } from '../../components/Auth'
99
import { Configuration, useConfiguration } from '../../utils'
1010

11-
export const isNoGame = (configuration: Configuration, id: number) => {
12-
const acus = configuration.numberOfSlots === 8
13-
if (acus) {
14-
return id >= 596 && id <= 603
15-
} else {
16-
return id <= 7
17-
}
18-
}
11+
// first N game ids are the No Game in Slot N entries ... :(
12+
export const isNoGame = (configuration: Configuration, id: number) => id <= configuration.numberOfSlots
1913

2014
// 144 is the magic number of the Any Game entry :(
21-
export const isAnyGame = (configuration: Configuration, id: number) => {
22-
const acus = configuration.numberOfSlots === 8
23-
if (acus) {
24-
return id === 604
25-
} else {
26-
return id === 144
27-
}
28-
}
15+
export const isAnyGame = (configuration: Configuration, id: number) => id === 144
2916

3017
const useStyles = makeStyles()((_theme: Theme) => ({
3118
spacer: {

packages/amber/views/Games/GamesDialog.tsx

+13-14
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,9 @@ const getDefaultValues = (configuration: Configuration): GameDialogFormValues =>
8888
type: '',
8989
setting: '',
9090
charInstructions: '',
91-
playerMin: configuration.virtual ? 2 : configuration.numberOfSlots === 8 ? 3 : 4,
92-
playerMax: configuration.virtual ? 7 : configuration.numberOfSlots === 8 ? 6 : 10,
91+
playerMin: configuration.playerMin,
92+
playerMax: configuration.playerMax,
93+
9394
playerPreference: '',
9495
returningPlayers: '',
9596
playersContactGm: false,
@@ -143,12 +144,6 @@ export const GamesDialog: React.FC<GamesDialogProps> = ({ open, onClose, initial
143144
const handleClose = useDisableBackdropClick(onClose)
144145
const estimatedLengthOptions = useMemo(() => getEstimatedLengthOptions(configuration), [configuration])
145146

146-
const slim = configuration.numberOfSlots === 8
147-
const minPlayersFloor = slim ? 1 : 1
148-
const minPlayersCeiling = slim ? 3 : 10
149-
const maxPlayersFloor = slim ? 4 : 1
150-
const maxPlayersCeiling = slim ? 20 : 150
151-
152147
const onSubmit = async (values: GameDialogFormValues, _actions: FormikHelpers<GameDialogFormValues>) => {
153148
await createOrUpdateGame(values)
154149
}
@@ -284,7 +279,7 @@ export const GamesDialog: React.FC<GamesDialogProps> = ({ open, onClose, initial
284279
<GridItem xs={12} md={12}>
285280
<TextField name='description' label='Game Description' margin='normal' fullWidth multiline required />
286281
</GridItem>
287-
{!slim && (
282+
{configuration.abbr === 'acnw' && (
288283
<GridItem container spacing={2} xs={12} md={12} style={{ paddingRight: 0 }}>
289284
<GridItem xs={12} md={6}>
290285
<SelectField
@@ -304,7 +299,7 @@ export const GamesDialog: React.FC<GamesDialogProps> = ({ open, onClose, initial
304299
<GridItem xs={12} md={12}>
305300
<CheckboxWithLabel label='Is the game Teen Friendly?' name='teenFriendly' />
306301
</GridItem>
307-
{!slim && (
302+
{configuration.abbr === 'acnw' && (
308303
<>
309304
<GridItem xs={12} md={12}>
310305
<TextField
@@ -338,7 +333,9 @@ export const GamesDialog: React.FC<GamesDialogProps> = ({ open, onClose, initial
338333
fullWidth
339334
type='number'
340335
required
341-
InputProps={{ inputProps: { min: minPlayersFloor, max: minPlayersCeiling } }}
336+
InputProps={{
337+
inputProps: { min: configuration.minPlayersFloor, max: configuration.minPlayersCeiling },
338+
}}
342339
/>
343340
</GridItem>
344341
<GridItem xs={12} md={6} style={{ paddingRight: 0 }}>
@@ -349,7 +346,9 @@ export const GamesDialog: React.FC<GamesDialogProps> = ({ open, onClose, initial
349346
fullWidth
350347
type='number'
351348
required
352-
InputProps={{ inputProps: { min: maxPlayersFloor, max: maxPlayersCeiling } }}
349+
InputProps={{
350+
inputProps: { min: configuration.maxPlayersFloor, max: configuration.maxPlayersCeiling },
351+
}}
353352
/>
354353
</GridItem>
355354
</GridItem>
@@ -383,7 +382,7 @@ export const GamesDialog: React.FC<GamesDialogProps> = ({ open, onClose, initial
383382
inputProps={{ autoCapitalize: 'none' }}
384383
/>
385384
</GridItem>
386-
{!slim && (
385+
{configuration.abbr === 'acnw' && (
387386
<GridItem xs={12} md={12}>
388387
<p>
389388
You are welcome to start and end the game at any time (within reason), but if the game overlaps two
@@ -435,7 +434,7 @@ export const GamesDialog: React.FC<GamesDialogProps> = ({ open, onClose, initial
435434
game, and schedule players to your game, please let us know:
436435
</Typography>
437436
</GridItem>
438-
{!slim && (
437+
{configuration.abbr === 'acnw' && (
439438
<GridItem xs={12} md={12}>
440439
<TextField name='slotConflicts' label='Slot Conflicts' margin='normal' fullWidth multiline />
441440
</GridItem>

packages/amber/views/GmPage/GmPage.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ const VirtualGmBlurb = () => {
128128
const GmBlurb = () => {
129129
const { classes } = useStyles()
130130
const configuration = useConfiguration()
131-
const acus = configuration.numberOfSlots === 8
131+
const acus = configuration.abbr === 'acus'
132132
const acnw = !acus
133133
return (
134134
<>

packages/amber/views/Payment/Payment.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const Payment: React.FC = () => {
3434
// console.log('Payment', { paymentIntent })
3535

3636
const configuration = useConfiguration()
37-
const acus = configuration.numberOfSlots === 8
37+
const acus = configuration.abbr === 'acus'
3838
const acnw = !acus
3939

4040
return (

packages/api/src/utils/configuration.ts

+13
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export const configurationSchema = z.object({
3434
title: z.string(),
3535
name: z.string(),
3636
abbr: z.string(),
37+
copyright: z.string(),
3738
contactEmail: z.string(),
3839
gameEmail: z.string(),
3940
webEmail: z.string(),
@@ -68,12 +69,24 @@ export const configurationSchema = z.object({
6869
deposit: toNumber(),
6970
virtual: toBoolean(),
7071
numberOfSlots: toNumber(),
72+
73+
playerMin: toNumber(),
74+
playerMax: toNumber(),
75+
minPlayersFloor: toNumber(),
76+
minPlayersCeiling: toNumber(),
77+
maxPlayersFloor: toNumber(),
78+
maxPlayersCeiling: toNumber(),
79+
7180
oregonHotelTax: z.string(),
7281
virtualCost: z.string(),
7382
moreThanDoubleOccupancySurcharge: z.string(),
7483
gameRoomCredit: z.string(),
7584
useUsAttendanceOptions: toBoolean(),
7685

86+
hotelBookingCode: z.string(),
87+
hotelBookingUrl: z.string(),
88+
hotelBookingLastdate: toDateTime(),
89+
7790
startDates: z.record(toNumber(), conventionInfoSchema),
7891
})
7992

0 commit comments

Comments
 (0)