Skip to content

Commit 97ff1d7

Browse files
Change the default value of wildcard field (#470)
* Change the default value of wildcard field * Incorporate sonarqube suggestion
1 parent 0fcec51 commit 97ff1d7

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/app/components/pages/GameboardBuilder.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,20 @@ const GameboardBuilder = ({ user }: { user: RegisteredUserDTO }) => {
5151
const [gameboardURL, setGameboardURL] = useState<string>();
5252
const [questionOrder, setQuestionOrder] = useState<string[]>([]);
5353
const [selectedQuestions, setSelectedQuestions] = useState(new Map<string, ContentSummary>());
54-
const [wildcardId, setWildcardId] = useState<string | undefined>(undefined);
54+
const [wildcardId, setWildcardId] = useState<string | undefined>("random");
5555
const eventLog = useRef<object[]>([]).current; // Use ref to persist state across renders but not rerender on mutation
5656

5757
const cloneGameboard = useCallback(
5858
(gameboard: GameboardDTO) => {
5959
setGameboardTitle(gameboard.title ? `${gameboard.title} (Copy)` : "");
6060
setQuestionOrder(loadGameboardQuestionOrder(gameboard) || []);
6161
setSelectedQuestions(loadGameboardSelectedQuestions(gameboard) || new Map<string, ContentSummary>());
62-
setWildcardId((isStaff(user) && gameboard.wildCard && gameboard.wildCard.id) || undefined);
62+
// Duplicating from an existing board or creating from concepts should default to random wildcard.
63+
if (baseGameboardId || concepts) {
64+
setWildcardId("random");
65+
} else {
66+
setWildcardId((isStaff(user) && gameboard.wildCard?.id) || "random");
67+
}
6368
if (concepts && !baseGameboardId) {
6469
logEvent(eventLog, "GAMEBOARD_FROM_CONCEPT", { concepts: concepts });
6570
} else {
@@ -85,7 +90,7 @@ const GameboardBuilder = ({ user }: { user: RegisteredUserDTO }) => {
8590
setQuestionOrder([]);
8691
setGameboardURL(undefined);
8792
setSelectedQuestions(new Map<string, ContentSummary>());
88-
setWildcardId(undefined);
93+
setWildcardId("random");
8994
};
9095

9196
useEffect(() => {
@@ -184,7 +189,7 @@ const GameboardBuilder = ({ user }: { user: RegisteredUserDTO }) => {
184189
</Col>
185190
</Row>
186191

187-
{isStaff(user) && user.role !== "TEACHER" && (
192+
{isStaff(user) && (
188193
<Row className="mt-2">
189194
<Col>
190195
<Label htmlFor="gameboard-builder-tag-as">Tag as</Label>

0 commit comments

Comments
 (0)