File size: 816 Bytes
56b6519
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import React, { createContext } from 'react';

type FindingType = {
  id: number;
  name: string;
  category: string;
  severity: string;
  identifier: string;
  status: number;
};

type AuditContextType = {
  title: string;
  auditType: string;
  locale: string;
  handlerFindings: () => Promise<FindingType[]>;
};

const defaultContextValue: AuditContextType = {
  title: '',
  auditType: '',
  locale: '',
  handlerFindings: () => Promise.resolve([]),
};

type AuditContextProps = {
  children: React.ReactNode;
  value: AuditContextType;
};

export const AuditContext =
  createContext<AuditContextType>(defaultContextValue);

export const AuditProvider: React.FC<AuditContextProps> = ({
  children,
  value,
}) => {
  return (
    <AuditContext.Provider value={value}>{children}</AuditContext.Provider>
  );
};