-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a maximum limit of users who can RSVP
* Added default limit for the number of allowed RSVPs in the config. * Added check to prevent RSVP users from going over the allowed limit in the RSVP page. * Added the ability to edit RSVPLimit from the admin dashboard.
- Loading branch information
1 parent
2911823
commit 2750867
Showing
7 changed files
with
139 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
apps/web/src/components/admin/toggles/UpdateItemWithConfirmation.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { useState } from "react"; | ||
import { Input } from "@/components/shadcn/ui/input"; | ||
import { Button } from "@/components/shadcn/ui/button"; | ||
|
||
interface UpdateItemWithConfirmationBaseProps<T extends number | string> { | ||
defaultValue: T; | ||
enabled: boolean; | ||
onSubmit: (value: T) => void; | ||
} | ||
|
||
type UpdateItemWithConfirmationProps = | ||
| ({ type: "string" } & UpdateItemWithConfirmationBaseProps<string>) | ||
| ({ type: "number" } & UpdateItemWithConfirmationBaseProps<number>); | ||
|
||
export function UpdateItemWithConfirmation({ | ||
type, | ||
defaultValue, | ||
onSubmit, | ||
enabled, | ||
}: UpdateItemWithConfirmationProps) { | ||
const [valueUpdated, setValueUpdated] = useState(false); | ||
const [value, setValue] = useState(defaultValue.toString()); | ||
|
||
return ( | ||
<div className="flex items-center gap-2 max-h-8"> | ||
<Input | ||
className="sm:w-40 w-24 text-center text-md font-bold" | ||
value={value} | ||
disabled={!enabled} | ||
onChange={({ target: { value: updated } }) => { | ||
// Ignore the change if the value is a non numeric character. | ||
if (type === "number" && /[^0-9]/.test(updated)) { | ||
setValue(value); | ||
return; | ||
} | ||
|
||
setValue(updated); | ||
|
||
/* Avoid allowing the user to update the default value to itself. | ||
* Also disallow the user from sending a zero length input. */ | ||
setValueUpdated( | ||
updated !== defaultValue.toString() && updated.length !== 0 | ||
); | ||
}} | ||
/> | ||
<Button | ||
className="text-sm font-bold" | ||
type="button" | ||
variant="default" | ||
title="Apply Changes" | ||
disabled={!valueUpdated || !enabled} | ||
onClick={() => { | ||
if (type === "number") { | ||
onSubmit(parseInt(value)); | ||
} else { | ||
onSubmit(value); | ||
} | ||
|
||
setValueUpdated(false); | ||
}} | ||
> | ||
Apply | ||
</Button> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters