Close badge edit modal after successful POST

This commit is contained in:
Kalle
2022-07-09 15:36:28 +03:00
parent 8fd525b7b5
commit 83a66aa21a
3 changed files with 5 additions and 4 deletions

View File

@@ -9,6 +9,7 @@ import { UserCombobox } from "~/components/Combobox";
import { TrashIcon } from "~/components/icons/Trash";
import { z } from "zod";
import { actualNumber, noDuplicates, safeJSONParse, id } from "~/utils/zod";
import { redirect } from "@remix-run/node";
import type { ActionFunction } from "@remix-run/node";
import { requireUser, useUser } from "~/modules/auth";
import { parseRequestFormData, validate } from "~/utils/remix";
@@ -16,6 +17,7 @@ import { canEditBadgeManagers, canEditBadgeOwners } from "~/permissions";
import { assertUnreachable } from "~/utils/types";
import { db } from "~/db";
import type { User } from "~/db/types";
import { badgePage } from "~/utils/urls";
const editBadgeActionSchema = z.union([
z.object({
@@ -59,7 +61,7 @@ export const action: ActionFunction = async ({ request, params }) => {
}
}
return null;
return redirect(badgePage(badgeId));
};
export default function EditBadgePage() {

View File

@@ -15,6 +15,7 @@ export const STOP_IMPERSONATING_URL = "/auth/impersonate/stop";
export const userPage = (discordId: string) => `/u/${discordId}`;
export const impersonateUrl = (idToLogInAs: number) =>
`/auth/impersonate?id=${idToLogInAs}`;
export const badgePage = (badgeId: number) => `${BADGES_PAGE}/${badgeId}`;
export const badgeUrl = ({
code,

View File

@@ -26,8 +26,7 @@ describe("Plus suggestions page", () => {
cy.getCy("new-manager-combobox-input").clear().type("Sendou{enter}");
cy.contains("2 changes").click();
cy.reload();
cy.getCy("manager").contains("Sendou");
cy.contains("Managed by Sendou");
});
it("edits adds badge owner", function () {
@@ -41,7 +40,6 @@ describe("Plus suggestions page", () => {
cy.getCy("owner-count-input").last().type("1"); // new count = 11
cy.contains("1 change").click();
cy.contains("Cancel").click();
cy.contains("11");
});