2022-04-13 11:44:59 +02:00
|
|
|
import { RequestCluster } from '../../../request-cluster';
|
2022-02-10 21:52:40 +01:00
|
|
|
import { ExplainerKey } from '../explainers';
|
|
|
|
import { ParsedAnswers } from '../parse-answers';
|
|
|
|
|
|
|
|
function formatRange(cluster: RequestCluster) {
|
2022-04-24 22:11:33 +02:00
|
|
|
const parts = [] as string[];
|
|
|
|
if (cluster.hasMarkedCookies()) {
|
|
|
|
parts.push('mojego identyfikatora internetowego pozyskanego z Cookie');
|
|
|
|
}
|
|
|
|
if (cluster.exposesOrigin()) {
|
|
|
|
parts.push('części mojej historii przeglądania');
|
|
|
|
}
|
|
|
|
return parts.join(' oraz ');
|
2022-02-10 21:52:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export abstract class Problem {
|
2022-04-24 22:11:33 +02:00
|
|
|
constructor(public answers: ParsedAnswers, public clusters: Record<string, RequestCluster>) {}
|
2022-02-10 21:52:40 +01:00
|
|
|
|
2022-07-09 16:52:29 +02:00
|
|
|
abstract getEmailContent(props: {
|
|
|
|
mode: 'email' | 'report';
|
|
|
|
tone: 'polite' | 'official';
|
|
|
|
}): JSX.Element;
|
2022-04-24 22:11:33 +02:00
|
|
|
abstract getNecessaryExplainers(): ExplainerKey[];
|
2022-07-07 21:16:48 +02:00
|
|
|
abstract qualifies(): boolean;
|
2022-02-10 21:52:40 +01:00
|
|
|
|
2022-04-24 22:11:33 +02:00
|
|
|
getMarkedClusters() {
|
|
|
|
return Object.values(this.clusters).filter((c) => c.hasMarks());
|
|
|
|
}
|
2022-02-10 21:52:40 +01:00
|
|
|
|
2022-04-24 22:11:33 +02:00
|
|
|
getRangeDescription() {
|
|
|
|
return (
|
|
|
|
<ul>
|
|
|
|
{this.getMarkedClusters().map((cluster) => (
|
|
|
|
<li key={cluster.id}>
|
|
|
|
{cluster.id} (w zakresie: {formatRange(cluster)})
|
|
|
|
</li>
|
|
|
|
))}
|
|
|
|
</ul>
|
|
|
|
);
|
|
|
|
}
|
2022-02-10 21:52:40 +01:00
|
|
|
}
|