{
"data": {
"buildhub.near": {
"widget": {
"components.modals.projects.PotlockImport": {
"": "const { Modal, Button } = VM.require(\"buildhub.near/widget/components\") || {\n Modal: () => <></>,\n Button: () => <></>,\n};\nconst { getTagsFromSocialProfileData, getTeamMembersFromSocialProfileData } =\n VM.require(\"potlock.near/widget/utils\") || {\n getTagsFromSocialProfileData: () => [],\n getTeamMembersFromSocialProfileData: () => [],\n };\nconst showModal = props.showModal;\nconst toggleModal = props.toggleModal;\nconst toggle = props.toggle;\nconst bootstrapTheme = props.bootstrapTheme || \"dark\";\nlet ListsSDK =\n VM.require(\"potlock.near/widget/SDK.lists\") ||\n (() => ({\n getRegistrations: () => {},\n }));\nListsSDK = ListsSDK({ env: \"production\" });\nconst allRegistrations = ListsSDK.getRegistrations() || [];\nconst isRegisteredProject = allRegistrations.find(\n (registration) => registration.registrant_id === accountId\n);\nconst [showCreateModalProjectId, setShowCreateModalProjectId] = useState(null);\nconst [projects, approvedProjects] = useMemo(() => {\n allRegistrations.sort((a, b) =>\n b.status === \"Approved\"\n ? -1\n : a.status === \"Approved\"\n ? 1\n : a.status.localeCompare(b.status)\n );\n allRegistrations.sort((a, b) => b.submitted_ms - a.submitted_ms);\n const approvedProjects = allRegistrations.filter(\n (project) => project.status === \"Approved\"\n );\n return [allRegistrations, approvedProjects];\n}, allRegistrations);\nconst [filteredProjects, setFilteredProjects] = useState([]);\nuseEffect(() => {\n if (!filteredProjects.length) {\n setFilteredProjects(approvedProjects);\n }\n}, [approvedProjects]);\nconst searchByWords = (projects, searchTerm) => {\n searchTerm = searchTerm.toLowerCase().trim();\n let results = [];\n projects.forEach((project) => {\n const { registrant_id, status } = project;\n const data = Social.getr(`${registrant_id}/profile`);\n if (\n registrant_id.includes(searchTerm) ||\n status.toLowerCase().includes(searchTerm)\n ) {\n results.push(project);\n } else if (data) {\n if (\n data.description.toLowerCase().includes(searchTerm) ||\n data.name.toLowerCase().includes(searchTerm) ||\n getTagsFromSocialProfileData(data)\n .join(\"\")\n .toLowerCase()\n .includes(searchTerm) ||\n getTeamMembersFromSocialProfileData(data)\n .join(\"\")\n .toLowerCase()\n .includes(searchTerm)\n ) {\n results.push(project);\n }\n }\n });\n setFilteredProjects(results);\n};\nconst ProjectList = styled.div`\n display: grid;\n gap: 31px;\n padding-bottom: 3rem;\n // For mobile devices (1 column)\n @media screen and (max-width: 739px) {\n grid-template-columns: repeat(1, 1fr);\n }\n // For tablet devices (2 columns)\n @media screen and (min-width: 740px) and (max-width: 1023px) {\n grid-template-columns: repeat(2, 1fr);\n }\n // For desktop devices (3 columns)\n @media screen and (min-width: 1024px) {\n grid-template-columns: repeat(3, 1fr);\n }\n`;\nconst Search = useMemo(() => {\n return (\n <Widget\n src={\"buildhub.near/widget/components.modals.projects.SearchBar\"}\n props={{\n title: sort,\n numItems: filteredProjects.length,\n itemName: \"project\",\n onSearch: (value) => {\n searchByWords(projects, value);\n },\n }}\n />\n );\n}, []);\nfunction shuffleArray(array) {\n return array.sort(() => Math.random() - 0.5);\n}\nconst ProjectsComponent = useMemo(() => {\n const shuffledProjects = shuffleArray(filteredProjects || []);\n return (\n <ProjectList>\n {(shuffledProjects || []).slice(0, 18).map((project) => {\n return (\n <Widget\n src={\n \"buildhub.near/widget/components.modals.projects.PotlockProjectCard\"\n }\n loading={\n <div\n style={{\n width: \"300px\",\n height: \"450px\",\n borderRadius: \"12px\",\n background: \"#23242b\",\n boxShadow: \"0px -2px 0px #dbdbdb inset\",\n border: \"1px solid #dbdbdb\",\n }}\n />\n }\n props={{\n ...props,\n projectId: project.registrant_id,\n allowDonate: false,\n setShowCreateModalProjectId: setShowCreateModalProjectId,\n }}\n />\n );\n })}\n </ProjectList>\n );\n}, [filteredProjects]);\nif (showCreateModalProjectId) {\n return (\n <Widget\n src=\"buildhub.near/widget/components.modals.projects.Create\"\n loading=\"\"\n props={{\n showModal: !!showCreateModalProjectId,\n toggleModal: (v) => setShowCreateModalProjectId(v),\n togglePotlockImportModal: () => toggleModal(),\n poltlockProjectId: showCreateModalProjectId,\n }}\n />\n );\n}\nconsole.log({ filteredProjects, allRegistrations, projects, approvedProjects });\nreturn (\n <Modal\n open={showModal}\n title={\"Import from Potlock\"}\n onOpenChange={toggleModal}\n toggle={toggle}\n >\n <div className=\"d-flex flex-column gap-4\">\n {Search}\n {ProjectsComponent}\n </div>\n </Modal>\n);\n"
}
}
}
}
}