Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disclaimer #89

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 16 additions & 17 deletions next-app/src/app/datasources/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ export default function DataPage(): ReactElement {
}

function checkedDataFilter(
tagType: string,
tagType: keyof IDataSourceFilters,
tagName: string,
boxIndex: number
) {
setSelectedFilters((prev) => {
const newFilters = { ...prev };
const key = tagType === "dataType" ? "dataTypes" : "diseaseTypes";
const key = tagType === "dataTypes" ? "dataTypes" : "diseaseTypes";
if (newFilters[key].includes(tagName)) {
newFilters[key] = newFilters[key].filter((item) => item !== tagName);
} else {
Expand All @@ -118,18 +118,16 @@ export default function DataPage(): ReactElement {
function applyDataTypeFilter(dataSource: IDataSourcesDC) {
return (
selectedFilters.dataTypes.length === 0 ||
selectedFilters.dataTypes.every((filter) =>
dataSource.data.some(
(tag) => tag.toLowerCase() === filter.toLowerCase()
)
selectedFilters.dataTypes.some((filter) =>
dataSource.data.some((tag) => tag.toLowerCase() === filter.toLowerCase())
)
);
}

function applyDiseaseTypeFilter(dataSource: IDataSourcesDC) {
return (
selectedFilters.diseaseTypes.length === 0 ||
selectedFilters.diseaseTypes.every((filter) =>
selectedFilters.diseaseTypes.some((filter) =>
dataSource.disease_type.some(
(tag) => tag.toLowerCase() === filter.toLowerCase()
)
Expand Down Expand Up @@ -158,13 +156,11 @@ export default function DataPage(): ReactElement {
function sanitizeURL(url: string) {
try {
const parsedURL = new URL(url);
// Only allow http and https protocols
if (parsedURL.protocol !== "http:" && parsedURL.protocol !== "https:") {
return "#";
}
return parsedURL.toString();
} catch {
// If URL is invalid, return a safe default
return "#";
}
}
Expand Down Expand Up @@ -199,6 +195,11 @@ export default function DataPage(): ReactElement {
<div className="lg:grid lg:grid-cols-4 lg:gap-8 pt-8">
<div className="lg:col-span-1 mb-8 lg:mb-0">
<div className="space-y-8">
{/* Disclaimer */}
<div className="w-full max-w-lg bg-muted border border-neutral rounded-lg p-4 text-sm text-muted-foreground text-left mx-auto">
To access data, researchers may need to obtain ethical approval, submit data requests and set up data management agreements.
</div>
{/* Search */}
<div className="space-y-4">
<label
htmlFor="search"
Expand All @@ -210,12 +211,13 @@ export default function DataPage(): ReactElement {
id="search"
type="text"
name="search"
placeholder="Name/Keywords"
placeholder="Search by name or keyword"
value={searchBar}
onChange={(e) => setSearchBar(e.target.value)}
className="bg-muted"
/>
</div>
{/* Data Type Filters */}
<div className="space-y-4">
<h2 className="font-bold text-2xl text-foreground">Data Type</h2>
<Card>
Expand All @@ -229,11 +231,7 @@ export default function DataPage(): ReactElement {
id={`dataType-${index}`}
checked={checkedList[index]}
onCheckedChange={() =>
checkedDataFilter(
"dataType",
element.toLowerCase(),
index
)
checkedDataFilter("dataTypes", element, index)
}
/>
<label
Expand All @@ -247,6 +245,7 @@ export default function DataPage(): ReactElement {
</CardContent>
</Card>
</div>
{/* Disease Type Filters */}
<div className="space-y-4">
<h2 className="font-bold text-2xl text-foreground">
Disease Type
Expand All @@ -263,8 +262,8 @@ export default function DataPage(): ReactElement {
checked={checkedList[filters.dataTypes.length + index]}
onCheckedChange={() =>
checkedDataFilter(
"diseaseType",
element.toLowerCase(),
"diseaseTypes",
element,
filters.dataTypes.length + index
)
}
Expand Down
11 changes: 8 additions & 3 deletions next-app/src/app/registries/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ export default function RegistryPage() {
useEffect(() => {
async function fetchRegistryData() {
try {
// In a real-world scenario, you might fetch this data from an API
// For this example, we'll simulate an API call with a local import
const registryData = await import(
"@/assets/Kvalitetsregister_geo_dates_02.09.2024.json"
);
Expand Down Expand Up @@ -196,6 +194,11 @@ export default function RegistryPage() {
<div className="lg:grid lg:grid-cols-4 lg:gap-8 pt-8">
<div className="lg:col-span-1 mb-8 lg:mb-0">
<div className="space-y-8">
{/* Disclaimer */}
<div className="w-full max-w-lg bg-muted border border-neutral rounded-lg p-4 text-sm text-muted-foreground text-left mx-auto">
To access data, researchers may need to obtain ethical approval, submit data requests and set up data management agreements.
</div>
{/* Search */}
<div className="space-y-4">
<label
htmlFor="search"
Expand All @@ -207,12 +210,13 @@ export default function RegistryPage() {
id="search"
type="text"
name="search"
placeholder="Name/Keywords"
placeholder="Search by name or keyword"
value={searchBar}
onChange={(e) => setSearchBar(e.target.value)}
className="bg-muted"
/>
</div>
{/* Organisation Filters */}
<div className="space-y-4">
<h2 className="font-bold text-2xl text-foreground">
Organisation
Expand Down Expand Up @@ -242,6 +246,7 @@ export default function RegistryPage() {
</CardContent>
</Card>
</div>
{/* Category Filters */}
<div className="space-y-4">
<h2 className="font-bold text-2xl text-foreground">Category</h2>
<Card>
Expand Down
Loading