@@ -7,7 +7,7 @@ import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { useToast } from "@/hooks/use-toast";
|
||||
import { FileText } from "lucide-react";
|
||||
import { FileText, Calendar } from "lucide-react";
|
||||
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
|
||||
import PolicyEditor from "@/components/PolicyEditor";
|
||||
import type { CreatePolicyPageMutation } from "./__generated__/CreatePolicyPageMutation.graphql";
|
||||
@@ -24,6 +24,7 @@ const CreatePolicyMutation = graphql`
|
||||
name
|
||||
content
|
||||
status
|
||||
reviewDate
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,6 +37,7 @@ export default function CreatePolicyPage() {
|
||||
const [name, setName] = useState("");
|
||||
const [content, setContent] = useState("");
|
||||
const [status, setStatus] = useState<"DRAFT" | "ACTIVE">("DRAFT");
|
||||
const [reviewDate, setReviewDate] = useState("");
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
const { toast } = useToast();
|
||||
|
||||
@@ -53,11 +55,18 @@ export default function CreatePolicyPage() {
|
||||
e.preventDefault();
|
||||
setIsSubmitting(true);
|
||||
|
||||
// Convert reviewDate string to ISO format for the API
|
||||
let reviewDateValue = null;
|
||||
if (reviewDate) {
|
||||
reviewDateValue = new Date(reviewDate).toISOString();
|
||||
}
|
||||
|
||||
const input = {
|
||||
organizationId: organizationId!,
|
||||
name,
|
||||
content,
|
||||
status,
|
||||
reviewDate: reviewDateValue,
|
||||
};
|
||||
|
||||
commitMutation({
|
||||
@@ -174,6 +183,22 @@ export default function CreatePolicyPage() {
|
||||
</div>
|
||||
</RadioGroup>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label
|
||||
htmlFor="reviewDate"
|
||||
className="flex items-center gap-2"
|
||||
>
|
||||
<Calendar className="h-4 w-4" />
|
||||
Review Date
|
||||
</Label>
|
||||
<Input
|
||||
id="reviewDate"
|
||||
type="date"
|
||||
value={reviewDate}
|
||||
onChange={(e) => setReviewDate(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ const PolicyOverviewPageQuery = graphql`
|
||||
content
|
||||
createdAt
|
||||
updatedAt
|
||||
reviewDate
|
||||
status
|
||||
}
|
||||
}
|
||||
@@ -210,7 +211,11 @@ function PolicyOverviewPageContent({
|
||||
<FileText className="h-4 w-4" />
|
||||
<span className="text-sm">Review Due</span>
|
||||
</div>
|
||||
<p className="font-medium">2025-02-15</p>
|
||||
<p className="font-medium">
|
||||
{policy.reviewDate
|
||||
? formatDate(policy.reviewDate)
|
||||
: "Not set"}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
|
||||
@@ -13,7 +13,7 @@ import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { toast } from "@/hooks/use-toast";
|
||||
import { FileText } from "lucide-react";
|
||||
import { FileText, Calendar } from "lucide-react";
|
||||
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
|
||||
import { Suspense } from "react";
|
||||
import PolicyEditor from "@/components/PolicyEditor";
|
||||
@@ -29,6 +29,7 @@ const UpdatePolicyPageQuery = graphql`
|
||||
content
|
||||
status
|
||||
version
|
||||
reviewDate
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,6 +44,7 @@ const UpdatePolicyMutation = graphql`
|
||||
content
|
||||
status
|
||||
version
|
||||
reviewDate
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -65,6 +67,7 @@ function UpdatePolicyPageContent({
|
||||
const [name, setName] = useState(data.node.name);
|
||||
const [content, setContent] = useState(data.node.content || "");
|
||||
const [status, setStatus] = useState(data.node.status);
|
||||
const [reviewDate, setReviewDate] = useState(data.node.reviewDate || "");
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
|
||||
console.log(
|
||||
@@ -81,6 +84,12 @@ function UpdatePolicyPageContent({
|
||||
e.preventDefault();
|
||||
setIsSubmitting(true);
|
||||
|
||||
// Convert reviewDate string to ISO format for the API
|
||||
let reviewDateValue = null;
|
||||
if (reviewDate) {
|
||||
reviewDateValue = new Date(reviewDate).toISOString();
|
||||
}
|
||||
|
||||
commitMutation({
|
||||
variables: {
|
||||
input: {
|
||||
@@ -88,6 +97,7 @@ function UpdatePolicyPageContent({
|
||||
name,
|
||||
content,
|
||||
status,
|
||||
reviewDate: reviewDateValue,
|
||||
expectedVersion: data.node.version!,
|
||||
},
|
||||
},
|
||||
@@ -98,19 +108,16 @@ function UpdatePolicyPageContent({
|
||||
toast({
|
||||
title: "Error",
|
||||
description: "Failed to update policy. Please try again.",
|
||||
variant: "destructive",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
toast({
|
||||
title: "Success",
|
||||
description: "Policy updated successfully!",
|
||||
description: "Policy updated successfully.",
|
||||
});
|
||||
|
||||
navigate(
|
||||
`/organizations/${organizationId}/policies/${response.updatePolicy.policy.id}`
|
||||
);
|
||||
navigate(`/organizations/${organizationId}/policies/${policyId}`);
|
||||
},
|
||||
onError: (error) => {
|
||||
setIsSubmitting(false);
|
||||
@@ -118,7 +125,6 @@ function UpdatePolicyPageContent({
|
||||
toast({
|
||||
title: "Error",
|
||||
description: "Failed to update policy. Please try again.",
|
||||
variant: "destructive",
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -193,6 +199,22 @@ function UpdatePolicyPageContent({
|
||||
</div>
|
||||
</RadioGroup>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label
|
||||
htmlFor="reviewDate"
|
||||
className="flex items-center gap-2"
|
||||
>
|
||||
<Calendar className="h-4 w-4" />
|
||||
Review Date
|
||||
</Label>
|
||||
<Input
|
||||
id="reviewDate"
|
||||
type="date"
|
||||
value={reviewDate}
|
||||
onChange={(e) => setReviewDate(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<c20ef485780e9d9544f536609ae060af>>
|
||||
* @generated SignedSource<<d242fdb748915009dc461be5596b6fc1>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -14,6 +14,7 @@ export type CreatePolicyInput = {
|
||||
content: string;
|
||||
name: string;
|
||||
organizationId: string;
|
||||
reviewDate?: string | null | undefined;
|
||||
status: PolicyStatus;
|
||||
};
|
||||
export type CreatePolicyPageMutation$variables = {
|
||||
@@ -27,6 +28,7 @@ export type CreatePolicyPageMutation$data = {
|
||||
readonly content: string;
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
readonly reviewDate: string | null | undefined;
|
||||
readonly status: PolicyStatus;
|
||||
};
|
||||
};
|
||||
@@ -98,6 +100,13 @@ v3 = {
|
||||
"kind": "ScalarField",
|
||||
"name": "status",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "reviewDate",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
@@ -171,16 +180,16 @@ return {
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "f9d97eecb99b47365557e372c724af41",
|
||||
"cacheID": "64796b84575bf926f45da4c98d31e645",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "CreatePolicyPageMutation",
|
||||
"operationKind": "mutation",
|
||||
"text": "mutation CreatePolicyPageMutation(\n $input: CreatePolicyInput!\n) {\n createPolicy(input: $input) {\n policyEdge {\n node {\n id\n name\n content\n status\n }\n }\n }\n}\n"
|
||||
"text": "mutation CreatePolicyPageMutation(\n $input: CreatePolicyInput!\n) {\n createPolicy(input: $input) {\n policyEdge {\n node {\n id\n name\n content\n status\n reviewDate\n }\n }\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "dca08dd146693bcf614e7d02785e57b5";
|
||||
(node as any).hash = "b7ecb61ced1e31c0c0093946135eca3b";
|
||||
|
||||
export default node;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<be4844f007d260c332082a01fe125a57>>
|
||||
* @generated SignedSource<<0eb945d3cbf8f223621fe7aa2b93eddc>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -19,6 +19,7 @@ export type PolicyOverviewPageQuery$data = {
|
||||
readonly createdAt?: string;
|
||||
readonly id: string;
|
||||
readonly name?: string;
|
||||
readonly reviewDate?: string | null | undefined;
|
||||
readonly status?: PolicyStatus;
|
||||
readonly updatedAt?: string;
|
||||
};
|
||||
@@ -81,6 +82,13 @@ v3 = {
|
||||
"name": "updatedAt",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "reviewDate",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
@@ -145,16 +153,16 @@ return {
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "07fedea13b4dbbe58e15dfaa644b24fa",
|
||||
"cacheID": "d3b31142132a379f9c3a8812ddcfb7da",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "PolicyOverviewPageQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query PolicyOverviewPageQuery(\n $policyId: ID!\n) {\n node(id: $policyId) {\n __typename\n id\n ... on Policy {\n name\n content\n createdAt\n updatedAt\n status\n }\n }\n}\n"
|
||||
"text": "query PolicyOverviewPageQuery(\n $policyId: ID!\n) {\n node(id: $policyId) {\n __typename\n id\n ... on Policy {\n name\n content\n createdAt\n updatedAt\n reviewDate\n status\n }\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "17389d925f3f3ffa3ed5eb8ed9051ae9";
|
||||
(node as any).hash = "1519b589fe7da5a258621ad445970ca7";
|
||||
|
||||
export default node;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<ecd63bc4d12703ce647666a146598810>>
|
||||
* @generated SignedSource<<9a54ece29b9ff9a2efa624f67f40f803>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -15,6 +15,7 @@ export type UpdatePolicyInput = {
|
||||
expectedVersion: number;
|
||||
id: string;
|
||||
name?: string | null | undefined;
|
||||
reviewDate?: string | null | undefined;
|
||||
status?: PolicyStatus | null | undefined;
|
||||
};
|
||||
export type UpdatePolicyPageMutation$variables = {
|
||||
@@ -26,6 +27,7 @@ export type UpdatePolicyPageMutation$data = {
|
||||
readonly content: string;
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
readonly reviewDate: string | null | undefined;
|
||||
readonly status: PolicyStatus;
|
||||
readonly version: number;
|
||||
};
|
||||
@@ -101,6 +103,13 @@ v1 = [
|
||||
"kind": "ScalarField",
|
||||
"name": "version",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "reviewDate",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
@@ -127,16 +136,16 @@ return {
|
||||
"selections": (v1/*: any*/)
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "ca013100ee6a0bf7c4e572474f1ba088",
|
||||
"cacheID": "ce2ccf9449b52e3df3b2b9bb82c55166",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "UpdatePolicyPageMutation",
|
||||
"operationKind": "mutation",
|
||||
"text": "mutation UpdatePolicyPageMutation(\n $input: UpdatePolicyInput!\n) {\n updatePolicy(input: $input) {\n policy {\n id\n name\n content\n status\n version\n }\n }\n}\n"
|
||||
"text": "mutation UpdatePolicyPageMutation(\n $input: UpdatePolicyInput!\n) {\n updatePolicy(input: $input) {\n policy {\n id\n name\n content\n status\n version\n reviewDate\n }\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "c17a1ff9bf786b0e251374a14fff0086";
|
||||
(node as any).hash = "d5329966d0e13b8931d6f01d9afb74e2";
|
||||
|
||||
export default node;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<b7ecab3dac17a6d1b23ec639484a4322>>
|
||||
* @generated SignedSource<<5ee387b238e8fdc7c41851c7e6740c95>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -18,6 +18,7 @@ export type UpdatePolicyPageQuery$data = {
|
||||
readonly content?: string;
|
||||
readonly id: string;
|
||||
readonly name?: string;
|
||||
readonly reviewDate?: string | null | undefined;
|
||||
readonly status?: PolicyStatus;
|
||||
readonly version?: number;
|
||||
};
|
||||
@@ -79,6 +80,13 @@ v3 = {
|
||||
"kind": "ScalarField",
|
||||
"name": "version",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "reviewDate",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"type": "Policy",
|
||||
@@ -137,16 +145,16 @@ return {
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "ed70bb0199119ba5b9080ed86081ac79",
|
||||
"cacheID": "fc062f2d2fcce04954feb69436433093",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "UpdatePolicyPageQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query UpdatePolicyPageQuery(\n $policyId: ID!\n) {\n node(id: $policyId) {\n __typename\n id\n ... on Policy {\n name\n content\n status\n version\n }\n }\n}\n"
|
||||
"text": "query UpdatePolicyPageQuery(\n $policyId: ID!\n) {\n node(id: $policyId) {\n __typename\n id\n ... on Policy {\n name\n content\n status\n version\n reviewDate\n }\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "303abaec54b66ef4f5c886d1cd606f12";
|
||||
(node as any).hash = "4ae49cad4f03a09d87475483c271bd94";
|
||||
|
||||
export default node;
|
||||
|
||||
Reference in New Issue
Block a user