-
-
Notifications
You must be signed in to change notification settings - Fork 125
Expand file tree
/
Copy pathV1ProjectMetadataProvider.tsx
More file actions
44 lines (40 loc) · 1.19 KB
/
V1ProjectMetadataProvider.tsx
File metadata and controls
44 lines (40 loc) · 1.19 KB
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
43
44
import { PV_V1 } from 'constants/pv'
import { ProjectMetadataContext } from 'contexts/ProjectMetadataContext'
import { ProjectMetadata } from 'models/projectMetadata'
import useProjectIdForHandle from 'packages/v1/hooks/contractReader/useProjectIdForHandle'
import { PropsWithChildren } from 'react'
import { isHardArchived } from 'utils/archived'
export function V1ProjectMetadataProvider({
handle,
metadata,
children,
}: PropsWithChildren<{
handle: string
metadata: ProjectMetadata | undefined
}>) {
const { data: projectId } = useProjectIdForHandle(handle)
const isArchived =
((projectId &&
isHardArchived({ pv: PV_V1, projectId: projectId.toNumber() })) ||
metadata?.archived) ??
false
const isLoading = !metadata
return (
<ProjectMetadataContext.Provider
value={{
refetchProjectMetadata: () => {
throw new Error(
'V1ProjectMetadataProvider.refetchProjectMetadata called but is not implemented',
)
},
projectMetadata: metadata,
isArchived,
projectId: projectId?.toNumber(),
pv: PV_V1,
isLoading,
}}
>
{children}
</ProjectMetadataContext.Provider>
)
}