-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
136 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Aup } from "@/models/aup"; | ||
|
||
const calculate = (aup: Aup) => { | ||
const newDate = new Date(aup.lastUpdateTime as string); | ||
return new Date( | ||
newDate.setDate(newDate.getDate() + aup.signatureValidityInDays + 900) | ||
); | ||
}; | ||
|
||
export const AupCard = (props: { aup: Aup }) => { | ||
const { aup } = props; | ||
const nextSignDate = aup.signatureValidityInDays == 0 ? calculate(aup) : ""; | ||
return ( | ||
<div> | ||
<h2> | ||
<b>Acceptable Usage Policy URL</b> | ||
</h2> | ||
<a href="{aup?.url}">{aup?.url}</a> | ||
<h3> | ||
The URL above is presented to users at registration time or periodically | ||
if the AUP is configured for periodic reacceptance | ||
</h3> | ||
<h2> | ||
<b>Created</b> | ||
</h2> | ||
<h3>{new Date(aup.creationTime).toISOString()}</h3> | ||
<h2> | ||
<b>Last updated</b> | ||
</h2> | ||
<h3>{new Date(aup?.lastUpdateTime as string)?.toISOString()}</h3> | ||
<h2> | ||
<b>Signature Validity (in days)</b> | ||
</h2> | ||
<h3>{aup?.signatureValidityInDays}</h3> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Button } from "@/components/Button"; | ||
import { fetchAup } from "@/services/aup"; | ||
import { DocumentTextIcon } from "@heroicons/react/16/solid"; | ||
import { AupCard } from "./AupCard"; | ||
|
||
export default async function Aup() { | ||
const aup = await fetchAup(); | ||
return ( | ||
<div> | ||
<div className="flex items-stretch"> | ||
<div | ||
className="me-2 my-auto" | ||
style={{ | ||
width: "24px", | ||
height: "24px", | ||
}} | ||
> | ||
<DocumentTextIcon /> | ||
</div> | ||
<div> | ||
<h1>Acceptable Usage Policy</h1> | ||
</div> | ||
</div> | ||
|
||
<AupCard aup={aup}></AupCard> | ||
<div> | ||
<Button type="button" className="my-auto" color="primary"> | ||
Edit AUP | ||
</Button> | ||
<Button type="button" className="my-auto" color="warning"> | ||
Request AUP signature | ||
</Button> | ||
<Button type="button" className="my-auto" color="danger"> | ||
Delete AUP | ||
</Button> | ||
</div> | ||
</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
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,20 @@ | ||
type Aup = { | ||
url: string; | ||
text?: string | null; | ||
description?: string | null; | ||
signatureValidityInDays: number; | ||
creationTime: string; | ||
lastUpdateTime?: string | null; | ||
}; | ||
|
||
type Account = { | ||
uuid: string; | ||
username: string; | ||
name: string; | ||
}; | ||
|
||
export interface AupSignature { | ||
aup: Aup; | ||
account: Account; | ||
signatureTime: string; | ||
} |
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,8 @@ | ||
export interface Aup { | ||
url: string; | ||
text?: string | null; | ||
description?: string | null; | ||
signatureValidityInDays: number; | ||
creationTime: string; | ||
lastUpdateTime?: string | null; | ||
} |
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,26 @@ | ||
import { Aup } from "@/models/aup"; | ||
import getConfig from "@/utils/config"; | ||
import { getItem } from "@/utils/fetch"; | ||
|
||
const { BASE_URL } = getConfig(); | ||
|
||
export const fetchAup = async () => { | ||
let url = `${BASE_URL}/iam/aup`; | ||
|
||
return await getItem<Aup>(url); | ||
}; | ||
|
||
export const fetchAupSignature = async () => { | ||
let url = `${BASE_URL}/iam/aup/signature`; | ||
|
||
return await getItem<Aup>(url); | ||
}; | ||
|
||
// export const editAup = async (_: string | undefined, formData: FormData) => { | ||
// const urlAup = formData.get("url") as string | undefined; | ||
// const validity = formData.get("validity") as string | undefined; | ||
|
||
// let url = `${BASE_URL}/iam/aup`; | ||
|
||
// // return await putItem<Aup>(url); | ||
// }; |
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