Restore TrustCenter reference hooks in console
Keep GraphQL-aligned TrustCenterReferenceGraph naming, drop the unused domain redirect route, and tighten related compliance page UI review nits around magic-link navigation and links. Signed-off-by: Bryan Frimin <bryan@probo.com>
This commit is contained in:
@@ -36,9 +36,9 @@ import { z } from "zod";
|
||||
|
||||
import type { CompliancePageReferenceListItemFragment$data } from "#/__generated__/core/CompliancePageReferenceListItemFragment.graphql";
|
||||
import {
|
||||
useCreateCompliancePageReferenceMutation,
|
||||
useUpdateCompliancePageReferenceMutation,
|
||||
} from "#/hooks/graph/CompliancePageReferenceGraph";
|
||||
useCreateTrustCenterReferenceMutation,
|
||||
useUpdateTrustCenterReferenceMutation,
|
||||
} from "#/hooks/graph/TrustCenterReferenceGraph";
|
||||
import { useFormWithSchema } from "#/hooks/useFormWithSchema";
|
||||
|
||||
const referenceSchema = z.object({
|
||||
@@ -65,8 +65,8 @@ export const CompliancePageReferenceDialog = forwardRef<CompliancePageReferenceD
|
||||
const [editReference, setEditReference] = useState<CompliancePageReferenceListItemFragment$data | null>(null);
|
||||
const [uploadedFile, setUploadedFile] = useState<File | null>(null);
|
||||
|
||||
const [createReference, isCreating] = useCreateCompliancePageReferenceMutation();
|
||||
const [updateReference, isUpdating] = useUpdateCompliancePageReferenceMutation();
|
||||
const [createReference, isCreating] = useCreateTrustCenterReferenceMutation();
|
||||
const [updateReference, isUpdating] = useUpdateTrustCenterReferenceMutation();
|
||||
|
||||
const { register, handleSubmit, formState: { errors }, reset } = useFormWithSchema(
|
||||
referenceSchema,
|
||||
|
||||
@@ -30,8 +30,8 @@ import {
|
||||
useDialogRef,
|
||||
} from "@probo/ui";
|
||||
|
||||
import type { CompliancePageReferenceGraphDeleteMutation } from "#/__generated__/core/CompliancePageReferenceGraphDeleteMutation.graphql";
|
||||
import { deleteCompliancePageReferenceMutation } from "#/hooks/graph/CompliancePageReferenceGraph";
|
||||
import type { TrustCenterReferenceGraphDeleteMutation } from "#/__generated__/core/TrustCenterReferenceGraphDeleteMutation.graphql";
|
||||
import { deleteTrustCenterReferenceMutation } from "#/hooks/graph/TrustCenterReferenceGraph";
|
||||
import { useMutation } from "#/lib/relay/useMutation";
|
||||
|
||||
type Props = {
|
||||
@@ -52,8 +52,8 @@ export function DeleteCompliancePageReferenceDialog({
|
||||
const { __ } = useTranslate();
|
||||
const ref = useDialogRef();
|
||||
|
||||
const [mutate, isDeleting] = useMutation<CompliancePageReferenceGraphDeleteMutation>(
|
||||
deleteCompliancePageReferenceMutation,
|
||||
const [mutate, isDeleting] = useMutation<TrustCenterReferenceGraphDeleteMutation>(
|
||||
deleteTrustCenterReferenceMutation,
|
||||
{
|
||||
successMessage: __("Reference deleted successfully"),
|
||||
errorToast: __("Failed to delete reference"),
|
||||
|
||||
@@ -14,14 +14,14 @@
|
||||
|
||||
import { graphql } from "react-relay";
|
||||
|
||||
import type { CompliancePageReferenceGraphCreateMutation } from "#/__generated__/core/CompliancePageReferenceGraphCreateMutation.graphql";
|
||||
import type { CompliancePageReferenceGraphDeleteMutation } from "#/__generated__/core/CompliancePageReferenceGraphDeleteMutation.graphql";
|
||||
import type { CompliancePageReferenceGraphUpdateMutation } from "#/__generated__/core/CompliancePageReferenceGraphUpdateMutation.graphql";
|
||||
import type { CompliancePageReferenceGraphUpdateRankMutation } from "#/__generated__/core/CompliancePageReferenceGraphUpdateRankMutation.graphql";
|
||||
import type { TrustCenterReferenceGraphCreateMutation } from "#/__generated__/core/TrustCenterReferenceGraphCreateMutation.graphql";
|
||||
import type { TrustCenterReferenceGraphDeleteMutation } from "#/__generated__/core/TrustCenterReferenceGraphDeleteMutation.graphql";
|
||||
import type { TrustCenterReferenceGraphUpdateMutation } from "#/__generated__/core/TrustCenterReferenceGraphUpdateMutation.graphql";
|
||||
import type { TrustCenterReferenceGraphUpdateRankMutation } from "#/__generated__/core/TrustCenterReferenceGraphUpdateRankMutation.graphql";
|
||||
import { useMutation } from "#/lib/relay/useMutation";
|
||||
|
||||
export const createCompliancePageReferenceMutation = graphql`
|
||||
mutation CompliancePageReferenceGraphCreateMutation(
|
||||
export const createTrustCenterReferenceMutation = graphql`
|
||||
mutation TrustCenterReferenceGraphCreateMutation(
|
||||
$input: CreateTrustCenterReferenceInput!
|
||||
$connections: [ID!]!
|
||||
) {
|
||||
@@ -47,8 +47,8 @@ export const createCompliancePageReferenceMutation = graphql`
|
||||
}
|
||||
`;
|
||||
|
||||
export const updateCompliancePageReferenceMutation = graphql`
|
||||
mutation CompliancePageReferenceGraphUpdateMutation(
|
||||
export const updateTrustCenterReferenceMutation = graphql`
|
||||
mutation TrustCenterReferenceGraphUpdateMutation(
|
||||
$input: UpdateTrustCenterReferenceInput!
|
||||
) {
|
||||
updateTrustCenterReference(input: $input) {
|
||||
@@ -70,8 +70,8 @@ export const updateCompliancePageReferenceMutation = graphql`
|
||||
}
|
||||
`;
|
||||
|
||||
export const deleteCompliancePageReferenceMutation = graphql`
|
||||
mutation CompliancePageReferenceGraphDeleteMutation(
|
||||
export const deleteTrustCenterReferenceMutation = graphql`
|
||||
mutation TrustCenterReferenceGraphDeleteMutation(
|
||||
$input: DeleteTrustCenterReferenceInput!
|
||||
$connections: [ID!]!
|
||||
) {
|
||||
@@ -81,9 +81,9 @@ export const deleteCompliancePageReferenceMutation = graphql`
|
||||
}
|
||||
`;
|
||||
|
||||
export function useCreateCompliancePageReferenceMutation() {
|
||||
return useMutation<CompliancePageReferenceGraphCreateMutation>(
|
||||
createCompliancePageReferenceMutation,
|
||||
export function useCreateTrustCenterReferenceMutation() {
|
||||
return useMutation<TrustCenterReferenceGraphCreateMutation>(
|
||||
createTrustCenterReferenceMutation,
|
||||
{
|
||||
successMessage: "Reference created successfully",
|
||||
errorToast: "Failed to create reference",
|
||||
@@ -91,9 +91,9 @@ export function useCreateCompliancePageReferenceMutation() {
|
||||
);
|
||||
}
|
||||
|
||||
export function useUpdateCompliancePageReferenceMutation() {
|
||||
return useMutation<CompliancePageReferenceGraphUpdateMutation>(
|
||||
updateCompliancePageReferenceMutation,
|
||||
export function useUpdateTrustCenterReferenceMutation() {
|
||||
return useMutation<TrustCenterReferenceGraphUpdateMutation>(
|
||||
updateTrustCenterReferenceMutation,
|
||||
{
|
||||
successMessage: "Reference updated successfully",
|
||||
errorToast: "Failed to update reference",
|
||||
@@ -101,8 +101,8 @@ export function useUpdateCompliancePageReferenceMutation() {
|
||||
);
|
||||
}
|
||||
|
||||
export const updateCompliancePageReferenceRankMutation = graphql`
|
||||
mutation CompliancePageReferenceGraphUpdateRankMutation(
|
||||
export const updateTrustCenterReferenceRankMutation = graphql`
|
||||
mutation TrustCenterReferenceGraphUpdateRankMutation(
|
||||
$input: UpdateTrustCenterReferenceInput!
|
||||
) {
|
||||
updateTrustCenterReference(input: $input) {
|
||||
@@ -114,9 +114,9 @@ export const updateCompliancePageReferenceRankMutation = graphql`
|
||||
}
|
||||
`;
|
||||
|
||||
export function useUpdateCompliancePageReferenceRankMutation() {
|
||||
return useMutation<CompliancePageReferenceGraphUpdateRankMutation>(
|
||||
updateCompliancePageReferenceRankMutation,
|
||||
export function useUpdateTrustCenterReferenceRankMutation() {
|
||||
return useMutation<TrustCenterReferenceGraphUpdateRankMutation>(
|
||||
updateTrustCenterReferenceRankMutation,
|
||||
{
|
||||
successMessage: "Order updated successfully",
|
||||
errorToast: "Failed to update order",
|
||||
@@ -124,9 +124,9 @@ export function useUpdateCompliancePageReferenceRankMutation() {
|
||||
);
|
||||
}
|
||||
|
||||
export function useDeleteCompliancePageReferenceMutation() {
|
||||
return useMutation<CompliancePageReferenceGraphDeleteMutation>(
|
||||
deleteCompliancePageReferenceMutation,
|
||||
export function useDeleteTrustCenterReferenceMutation() {
|
||||
return useMutation<TrustCenterReferenceGraphDeleteMutation>(
|
||||
deleteTrustCenterReferenceMutation,
|
||||
{
|
||||
successMessage: "Reference deleted successfully",
|
||||
errorToast: "Failed to delete reference",
|
||||
@@ -35,9 +35,9 @@ export default function MagicLinkAlreadyUsedPage() {
|
||||
</div>
|
||||
<Button
|
||||
className="w-full h-10"
|
||||
onClick={() => void navigate(-1)}
|
||||
onClick={() => void navigate("/auth/login")}
|
||||
>
|
||||
{__("Go back")}
|
||||
{__("Sign in")}
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -35,9 +35,9 @@ export default function MagicLinkExpiredPage() {
|
||||
</div>
|
||||
<Button
|
||||
className="w-full h-10"
|
||||
onClick={() => void navigate(-1)}
|
||||
onClick={() => void navigate("/auth/login")}
|
||||
>
|
||||
{__("Go back")}
|
||||
{__("Sign in")}
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -181,7 +181,7 @@ export const CompliancePageCustomLinkDialog = forwardRef<CompliancePageCustomLin
|
||||
error={errors.url?.message}
|
||||
/>
|
||||
<Field
|
||||
{...register("name")}
|
||||
{...register("name", { onChange: () => setNameAutoDetected(false) })}
|
||||
label={__("Name")}
|
||||
type="text"
|
||||
required
|
||||
|
||||
@@ -30,7 +30,7 @@ const compliancePageFragment = graphql`
|
||||
fragment CompliancePageCustomLinkList_compliancePageFragment on TrustCenter
|
||||
@refetchable(queryName: "CompliancePageCustomLinkList_compliancePageRefetchQuery")
|
||||
@argumentDefinitions(
|
||||
first: { type: Int, defaultValue: 100 }
|
||||
first: { type: Int, defaultValue: 500 }
|
||||
after: { type: CursorKey, defaultValue: null }
|
||||
order: { type: ComplianceCustomLinkOrder, defaultValue: { field: RANK, direction: ASC } }
|
||||
) {
|
||||
|
||||
@@ -62,18 +62,12 @@ export function CompliancePageDomainsSection(props: {
|
||||
|
||||
<div className="space-y-3">
|
||||
{defaultDomain && (
|
||||
<CompliancePageDomainCard
|
||||
fKey={defaultDomain}
|
||||
compliancePageId={compliancePageId}
|
||||
/>
|
||||
<CompliancePageDomainCard fKey={defaultDomain} />
|
||||
)}
|
||||
|
||||
{customDomain
|
||||
? (
|
||||
<CompliancePageDomainCard
|
||||
fKey={customDomain}
|
||||
compliancePageId={compliancePageId}
|
||||
/>
|
||||
<CompliancePageDomainCard fKey={customDomain} />
|
||||
)
|
||||
: organization.canCreateCustomDomain && (
|
||||
<div className="flex flex-col items-center justify-center gap-3 rounded-lg border border-dashed border-border-solid px-4 py-8">
|
||||
|
||||
@@ -46,9 +46,8 @@ const fragment = graphql`
|
||||
|
||||
export function CompliancePageDomainCard(props: {
|
||||
fKey: CompliancePageDomainCardFragment$key;
|
||||
compliancePageId: string;
|
||||
}) {
|
||||
const { fKey, compliancePageId } = props;
|
||||
const { fKey } = props;
|
||||
|
||||
const { __ } = useTranslate();
|
||||
|
||||
@@ -85,7 +84,6 @@ export function CompliancePageDomainCard(props: {
|
||||
<DeleteCompliancePageDomainDialog
|
||||
domain={domain.domain}
|
||||
customDomainId={domain.id}
|
||||
compliancePageId={compliancePageId}
|
||||
>
|
||||
<Button variant="danger">{__("Delete")}</Button>
|
||||
</DeleteCompliancePageDomainDialog>
|
||||
|
||||
@@ -46,7 +46,6 @@ const deleteCustomDomainMutation = graphql`
|
||||
type DeleteCompliancePageDomainDialogProps = PropsWithChildren<{
|
||||
domain: string;
|
||||
customDomainId: string;
|
||||
compliancePageId: string;
|
||||
}>;
|
||||
|
||||
export function DeleteCompliancePageDomainDialog(props: DeleteCompliancePageDomainDialogProps) {
|
||||
|
||||
@@ -42,7 +42,6 @@ const createCustomDomainMutation = graphql`
|
||||
customDomain {
|
||||
id
|
||||
domain
|
||||
managed
|
||||
sslStatus
|
||||
dnsRecords {
|
||||
type
|
||||
@@ -156,7 +155,7 @@ export function NewCompliancePageDomainDialog(props: PropsWithChildren<{ complia
|
||||
<strong>{__("Examples:")}</strong>
|
||||
{" "}
|
||||
compliance.example.com,
|
||||
compliance.example.com
|
||||
trust.example.com
|
||||
</p>
|
||||
</div>
|
||||
</DialogContent>
|
||||
|
||||
@@ -27,7 +27,7 @@ import { graphql } from "relay-runtime";
|
||||
import type { CompliancePageReferenceListFragment$key } from "#/__generated__/core/CompliancePageReferenceListFragment.graphql";
|
||||
import type { CompliancePageReferenceListItemFragment$data } from "#/__generated__/core/CompliancePageReferenceListItemFragment.graphql";
|
||||
import type { CompliancePageReferenceListQuery } from "#/__generated__/core/CompliancePageReferenceListQuery.graphql";
|
||||
import { useUpdateCompliancePageReferenceRankMutation } from "#/hooks/graph/CompliancePageReferenceGraph";
|
||||
import { useUpdateTrustCenterReferenceRankMutation } from "#/hooks/graph/TrustCenterReferenceGraph";
|
||||
|
||||
import { CompliancePageReferenceListItem } from "./CompliancePageReferenceListItem";
|
||||
|
||||
@@ -65,7 +65,7 @@ export function CompliancePageReferenceList(props: {
|
||||
CompliancePageReferenceListQuery,
|
||||
CompliancePageReferenceListFragment$key
|
||||
>(fragment, fragmentRef);
|
||||
const [updateRank] = useUpdateCompliancePageReferenceRankMutation();
|
||||
const [updateRank] = useUpdateTrustCenterReferenceRankMutation();
|
||||
|
||||
const [draggedIndex, setDraggedIndex] = useState<number | null>(null);
|
||||
const [dragOverIndex, setDragOverIndex] = useState<number | null>(null);
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
// SOFTWARE.
|
||||
|
||||
import { lazy } from "@probo/react-lazy";
|
||||
import { redirect } from "react-router";
|
||||
|
||||
import { LinkCardSkeleton } from "#/components/skeletons/LinkCardSkeleton";
|
||||
import { PageSkeleton } from "#/components/skeletons/PageSkeleton";
|
||||
@@ -35,12 +34,6 @@ export const compliancePageRoutes = [
|
||||
Fallback: LinkCardSkeleton,
|
||||
Component: lazy(() => import("#/pages/organizations/compliance-page/overview/CompliancePageOverviewPageLoader")),
|
||||
},
|
||||
{
|
||||
path: "domain",
|
||||
loader: () => {
|
||||
throw redirect("brand");
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "brand",
|
||||
Fallback: LinkCardSkeleton,
|
||||
|
||||
Reference in New Issue
Block a user