Fix react warnings

Closes #55
This commit is contained in:
Kuba Orlik 2022-07-09 16:52:29 +02:00
parent 8a93cf5463
commit 4a030e47c3
7 changed files with 19 additions and 15 deletions

View File

@ -25,7 +25,6 @@ export default function EmailContent({
downloadFiles: Function;
user_role: string;
}) {
console.log('rendering email!', answers);
const _ = (key: string) => v(key, answers.zaimek);
const problems = deduceProblems(answers, clusters);
const explainers = Array.from(
@ -64,7 +63,9 @@ export default function EmailContent({
{mode === 'email'
? emailIntro(email_tone, _, visited_url)
: reportIntro(visited_url)}
{problems.map((problem) => problem.getEmailContent(mode, email_tone))}
{problems.map((problem, index) => (
<problem.getEmailContent mode={mode} tone={email_tone} key={index} />
))}
{explainers.map((explainer) => explainer(answers.zaimek))}
<h2>Państwa rola jako współadministratora danych osobowych</h2>
{mode == 'email' ? (

View File

@ -6,7 +6,7 @@ export default class NoInformationAtAllProblem extends Problem {
qualifies() {
return this.answers.popup_type === 'none';
}
getEmailContent(mode: 'email' | 'report', tone: 'official' | 'polite') {
getEmailContent({ mode, tone }: { mode: 'email' | 'report'; tone: 'official' | 'polite' }) {
const _ = (word: string) => v(word, this.answers.zaimek);
return (
<>

View File

@ -16,7 +16,10 @@ function formatRange(cluster: RequestCluster) {
export abstract class Problem {
constructor(public answers: ParsedAnswers, public clusters: Record<string, RequestCluster>) {}
abstract getEmailContent(mode: 'email' | 'report', tone: 'polite' | 'official'): JSX.Element;
abstract getEmailContent(props: {
mode: 'email' | 'report';
tone: 'polite' | 'official';
}): JSX.Element;
abstract getNecessaryExplainers(): ExplainerKey[];
abstract qualifies(): boolean;

View File

@ -20,7 +20,7 @@ export class TransferOutsideEU extends Problem {
.map(([id]) => this.clusters[id]);
}
getEmailContent(mode: 'email' | 'report') {
getEmailContent({ mode }: { mode: 'email' | 'report'; tone: 'official' | 'polite' }) {
const clusters = this.getRelatedClusters();
const _ = (key: string) => v(key, this.answers.zaimek);
return (

View File

@ -1,6 +1,4 @@
import { RequestCluster } from '../../../request-cluster';
import { ExplainerKey } from '../explainers';
import { ParsedHostAnswers } from '../parse-answers';
import { v } from '../verbs';
import { Problem } from './problem';
@ -13,7 +11,7 @@ export class UnknownIdentity extends Problem {
return this.answers.administrator_identity_available_before_choice == 'no';
}
getEmailContent(mode: 'email' | 'report', tone: 'polite' | 'official') {
getEmailContent({ mode, tone }: { mode: 'email' | 'report'; tone: 'official' | 'polite' }) {
const _ = (key: string) => v(key, this.answers.zaimek);
return (
<>

View File

@ -36,7 +36,7 @@ export class UnknownLegalBasis extends Problem {
);
}
getEmailContent(mode: 'email' | 'report', tone: 'polite' | 'official') {
getEmailContent({ mode, tone }: { mode: 'email' | 'report'; tone: 'official' | 'polite' }) {
const clusters = this.getRelatedClusters();
const _ = (key: string) => v(key, this.answers.zaimek);
return (

View File

@ -23,7 +23,7 @@ export class UnlawfulCookieAccess extends Problem {
});
}
getEmailContent(mode: 'email' | 'report', tone: 'official' | 'polite') {
getEmailContent({ mode, tone }: { mode: 'email' | 'report'; tone: 'official' | 'polite' }) {
const cookie_clusters = Object.values(this.clusters).filter((c) => c.hasMarkedCookies());
const unnecessary_hosts = Object.entries(this.answers.hosts)
.filter(([, answers]) => answers.was_processing_necessary === 'no')
@ -245,10 +245,12 @@ export class UnlawfulCookieAccess extends Problem {
</p>
)
) : (
<p>
Jeżeli zgoda nadal ma być używana jako podstawa prawna do odczytu cookiesów
przez skrypty wyżej wymienionych podmiotów, to należy zmienić mechanizm
zgody tak, aby:{' '}
<>
<p>
Jeżeli zgoda nadal ma być używana jako podstawa prawna do odczytu plików
cookies przez skrypty wyżej wymienionych podmiotów, to należy zmienić
mechanizm zgody tak, aby:{' '}
</p>{' '}
<ul>
<li>
dawał użytkownikowi końcowemu możliwość odmowy zgody w sposób równie
@ -262,7 +264,7 @@ export class UnlawfulCookieAccess extends Problem {
na nie zgody.
</li>
</ul>
</p>
</>
)}
{maybe_unnecessary_hosts.length > 1 && mode == 'email' && tone == 'official' ? (
<p>