message: ProceedingsStore: Due dates for admonitions and complaints
diff: -import type { Request } from '../types/request';
  +import type { Request, RequestType } from '../types/request';
  import { Message, MessageId, Proceeding, ProceedingStatus } from '../types/proceedings.d';
  import create, { GetState, SetState, StoreApi, Mutate } from 'zustand';
  import { persist } from 'zustand/middleware';
  @@ -7,7 +7,7 @@ import { Privacy, PRIVACY_ACTIONS } from '../Utility/Privacy';
  import type { SetOptional } from 'type-fest';
  import { ErrorException } from '../Utility/errors';
  import { UserRequest } from '../DataType/UserRequests';
  -import { isUserRequest } from '../Utility/requests';
  +import { isUserRequest, REQUEST_TYPES } from '../Utility/requests';
  import { PrivacyAsyncStorage } from '../Utility/PrivacyAsyncStorage';
  import { t_r } from '../Utility/i18n';
  import type { ComponentChildren } from 'preact';
  @@ -164,13 +164,36 @@ export const getNewestMessage = (proceeding: Proceeding): Message | undefined =>
  return msgArray[msgArray.length - 1];
  };
  +export const getProceedingDueDate = (proceeding: Proceeding): Date | undefined => {
  + const newestMessage = getNewestMessage(proceeding);
  + // We can only determine a reasonable due dates for proceedings where the latest message was generated by us. For
  + // everything else, we just don't have enough information.
  + if (!newestMessage?.sentByMe) return undefined;
  +
  + const dueDate = new Date(newestMessage.date);
  +
  + // For complaints, the SVA needs to at least inform the data subject about the progress or outcome of the
  + // complaint within three months (Art. 78(2) GDPR).
  + if (newestMessage.type === 'complaint') dueDate.setDate(dueDate.getDate() + 3 * 31);
  + // In our admonitions, we set a period of two weeks.
  + else if (newestMessage.type === 'admonition') dueDate.setDate(dueDate.getDate() + 14);
  + // For requests, controllers regularly have to respond within one month (Art. 12(3) GDPR). While this could be
  + // extended to three months if justified, we can't handle that here.
  + else if (newestMessage.type !== 'custom' && REQUEST_TYPES.includes(newestMessage.type as 'access'))
  + dueDate.setDate(dueDate.getDate() + 31);
  + // Otherwise, we can't know the due date.
  + else return undefined;
  +
  + return dueDate;
  +};
  const shouldHaveStatus = (proceeding: Proceeding): ProceedingStatus => {
  if (proceeding.status === 'done') return 'done';
  +
  const newestMessage = getNewestMessage(proceeding);
  if (newestMessage?.sentByMe) {
  - const dueDate = new Date(newestMessage.date);
  - dueDate.setDate(dueDate.getDate() + 32); // TODO: Make this a setting? Should this depend on context?
  - return dueDate > new Date() ? 'waitingForResponse' : 'overdue';
  + const dueDate = getProceedingDueDate(proceeding);
  + if (dueDate && new Date() > dueDate) return 'overdue';
  + return 'waitingForResponse';
  }
  return 'actionNeeded';
  