diff --git a/src/App.tsx b/src/App.tsx index bd297dce5..02baa0706 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -49,6 +49,7 @@ import OrganizationSetting from "./modules/Dashboard/modules/Settings/pages/Orga import SettingsHome from "./modules/Dashboard/modules/Settings/pages/Settings/SettingsHome"; import LcReportAttendee from "./modules/Dashboard/modules/LearningCircle/pages/LcDashboard/components/LcAttendeeReport"; import LcAdmin from "./modules/Dashboard/modules/LearningCircle/pages/LcAdmin/LcAdmin"; +import VerifyOrganizations from "./modules/Dashboard/modules/VerifyOrganizations/VerifyOrganizations"; const Profile = lazy( () => import("./modules/Dashboard/modules/Profile/pages/Profile") @@ -376,6 +377,15 @@ function App() { /> ) }, + { + path: "verify-organizations", + element: ( + } + /> + ) + }, { path: "campus-details", element: ( diff --git a/src/modules/Common/Authentication/pages/Onboarding/CollegePage/CollegePage.module.css b/src/modules/Common/Authentication/pages/Onboarding/CollegePage/CollegePage.module.css index 6f649a823..39978feeb 100644 --- a/src/modules/Common/Authentication/pages/Onboarding/CollegePage/CollegePage.module.css +++ b/src/modules/Common/Authentication/pages/Onboarding/CollegePage/CollegePage.module.css @@ -62,3 +62,11 @@ color: red; font-size: small; } + +.skipButton { + color: var(--blue) !important; + + &:hover { + color: #fff !important; + } +} diff --git a/src/modules/Common/Authentication/pages/Onboarding/CollegePage/CollegePage.tsx b/src/modules/Common/Authentication/pages/Onboarding/CollegePage/CollegePage.tsx index 717600e19..b7886affe 100644 --- a/src/modules/Common/Authentication/pages/Onboarding/CollegePage/CollegePage.tsx +++ b/src/modules/Common/Authentication/pages/Onboarding/CollegePage/CollegePage.tsx @@ -14,7 +14,10 @@ import { useLocation, useNavigate } from "react-router-dom"; import OnboardingTemplate from "../../../components/OnboardingTeamplate/OnboardingTemplate"; import OnboardingHeader from "../../../components/OnboardingHeader/OnboardingHeader"; import { Switch } from "@chakra-ui/react"; -import { selectOrganization } from "../../../services/onboardingApis"; +import { + createNewOrganization, + selectOrganization +} from "../../../services/onboardingApis"; const inputObject = { organization: "Organization", @@ -61,6 +64,11 @@ export default function CollegePage() { id: "", title: "" }); + const [organizationInput, setOrganizationInput] = useState(""); + const [createOrganization, setCreateOrganization] = useState<{ + title: string; + org_type: string; + } | null>(null); const ruri = window.location.href.split("=")[1]; @@ -68,7 +76,6 @@ export default function CollegePage() { { label, value }: { label: string; value: string }, string: string ): boolean => { - if (value === "Others") return true; // Always show "Others" option if (!string) return true; return label.toLowerCase().includes(string.toLowerCase()); }; @@ -88,6 +95,21 @@ export default function CollegePage() { }); }, []); const onSubmit = async (values: any) => { + if (createOrganization) { + createNewOrganization({ + setIsLoading: setIsLoading, + org_data: createOrganization + }).then(res => { + if (res) { + if (ruri) { + navigate(`/${ruri}`); + } else { + navigate("/dashboard/connect-discord"); + } + } + }); + return; + } selectOrganization({ setIsLoading: setIsLoading, userData: { @@ -113,6 +135,40 @@ export default function CollegePage() { } }); }; + const getOptions = () => { + var orgs = isCollege ? colleges : companies; + var options: any[] = []; + orgs.forEach(org => { + options.push({ value: org.id, label: org.title }); + }); + if ( + organizationInput && + !options.some(opt => opt.label === organizationInput) + ) { + options.push({ + value: organizationInput, + label: `Create "${organizationInput}"` + }); + } + return options; + }; + const onOrgSelectChange = (e: any, formik: any) => { + if ( + (isCollege ? colleges : companies).filter(val => val.id == e.value) + .length < 1 + ) { + setCreateOrganization({ + title: e.value, + org_type: isCollege ? "College" : "Company" + }); + formik.setFieldValue("organization", e.value); + return; + } + setCreateOrganization(null); + setSelectedOrganization(e); + formik.setFieldValue("organization", e.value); + inputObject.organization = e.value; + }; return (
({ - value: college.id, - label: college.title - })) - : companies.map( - company => ({ - value: company.id, - label: company.title - }) - )) - ] as any - } + onInputChange={e => { + setOrganizationInput(e); + }} + options={getOptions()} name="organization" placeholder={ isCollege ? "College" : "Organization" } - value={selectedOrganization.title} filterOption={CustomFilter} isDisabled={isloading} onChange={(e: any) => { - setSelectedOrganization(e); - formik.setFieldValue( - "organization", - e.value - ); - inputObject.organization = e.value; + onOrgSelectChange(e, formik); }} />
@@ -188,7 +223,7 @@ export default function CollegePage() { {formik.errors.college} )} - {isCollege ? ( + {isCollege && !createOrganization ? ( <>
{ e.preventDefault(); diff --git a/src/modules/Common/Authentication/services/onboardingApis.ts b/src/modules/Common/Authentication/services/onboardingApis.ts index 75ec01e5e..148d74741 100644 --- a/src/modules/Common/Authentication/services/onboardingApis.ts +++ b/src/modules/Common/Authentication/services/onboardingApis.ts @@ -236,6 +236,31 @@ export const getCommunities = ({ setIsLoading && setIsLoading(false); }; +export const createNewOrganization = async ({ + setIsLoading, + org_data +}: { + setIsLoading: Dispatch>; + org_data: Object; +}) => { + try { + setIsLoading(true); + const res = await privateGateway.post( + "/api/v1/register/organization/create/", + org_data + ); + if (res.status == 200 && !res.data.hasError) { + toast.success(res.data.message.general[0]); + return true; + } else { + toast.error("Organization selection failed."); + } + setIsLoading(false); + } catch (err: any) { + toast.error("Unable to select organization."); + } + return false; +}; export const selectOrganization = async ({ setIsLoading, userData diff --git a/src/modules/Dashboard/layouts/DashboardRootLayout.tsx b/src/modules/Dashboard/layouts/DashboardRootLayout.tsx index 628dea579..30a3fe8d0 100644 --- a/src/modules/Dashboard/layouts/DashboardRootLayout.tsx +++ b/src/modules/Dashboard/layouts/DashboardRootLayout.tsx @@ -182,6 +182,12 @@ const DashboardRootLayout = (props: { component?: any }) => { hasView: true, roles: [roles.ADMIN] }, + { + url: "/dashboard/verify-organizations", + title: "Verify Organization", + hasView: true, + roles: [roles.ADMIN, roles.FELLOW] + }, { url: "/dashboard/college-levels", title: "College Levels", diff --git a/src/modules/Dashboard/modules/LearningCircle/pages/LcDashboard/components/LcAttendeeReport.tsx b/src/modules/Dashboard/modules/LearningCircle/pages/LcDashboard/components/LcAttendeeReport.tsx index 589c7a622..12330c671 100644 --- a/src/modules/Dashboard/modules/LearningCircle/pages/LcDashboard/components/LcAttendeeReport.tsx +++ b/src/modules/Dashboard/modules/LearningCircle/pages/LcDashboard/components/LcAttendeeReport.tsx @@ -215,10 +215,10 @@ const LcReportAttendee = () => { onChange={e => { if (e.target.files) { if ( - e.target.files[0].size > 5000000 + e.target.files[0].size > 2500000 ) { toast.error( - "File size should not exceed 5MB" + "File size should not exceed 2.5MB" ); return; } diff --git a/src/modules/Dashboard/modules/VerifyOrganizations/VerifyOrganizationAPIs.tsx b/src/modules/Dashboard/modules/VerifyOrganizations/VerifyOrganizationAPIs.tsx new file mode 100644 index 000000000..51fbc0382 --- /dev/null +++ b/src/modules/Dashboard/modules/VerifyOrganizations/VerifyOrganizationAPIs.tsx @@ -0,0 +1,20 @@ +import { privateGateway } from "@/MuLearnServices/apiGateways"; +import { organizationRoutes } from "@/MuLearnServices/urls"; + +export const getUnverifiedOrganizations = async ( + setData: UseStateFunc, + setIsLoading: UseStateFunc +) => { + setIsLoading(true); + try { + const data = ( + await privateGateway.get( + organizationRoutes.getUnverifiedOrganizations + ) + ).data.response; + setIsLoading(false); + setData(data); + } catch (err: unknown) { + setIsLoading(false); + } +}; diff --git a/src/modules/Dashboard/modules/VerifyOrganizations/VerifyOrganizations.tsx b/src/modules/Dashboard/modules/VerifyOrganizations/VerifyOrganizations.tsx new file mode 100644 index 000000000..f54e3824e --- /dev/null +++ b/src/modules/Dashboard/modules/VerifyOrganizations/VerifyOrganizations.tsx @@ -0,0 +1,64 @@ +import MuModal from "@/MuLearnComponents/MuModal/MuModal"; +import Pagination from "@/MuLearnComponents/Pagination/Pagination"; +import Table from "@/MuLearnComponents/Table/Table"; +import THead from "@/MuLearnComponents/Table/THead"; +import TableTop from "@/MuLearnComponents/TableTop/TableTop"; +import { useEffect, useState } from "react"; +import { Label } from "recharts"; +import { getUnverifiedOrganizations } from "./VerifyOrganizationAPIs"; + +export default function VerifyOrganizations() { + const [data, setData] = useState([]); + const [isLoading, setIsLoading] = useState(false); + const [isModalOpen, setIsModalOpen] = useState(false); + const [currentPage, setCurrentPage] = useState(1); + const [totalPages, setTotalPages] = useState(0); + const [perPage, setPerPage] = useState(20); + const columns = [ + { column: "title", Label: "Title", isSortable: false }, + { column: "org_type", Label: "Org Type", isSortable: false }, + { column: "created_by", Label: "Craeted By", isSortable: false }, + { column: "created_at", Label: "Created At", isSortable: false } + ]; + useEffect(() => { + getUnverifiedOrganizations(setData, setIsLoading); + }, []); + + return ( + <> + setIsModalOpen(false)} + title={`Verify Organization`} + type={"success"} + onDone={() => {}} + > + Nothing + + {data && ( + <> + + {}} + action={false} + /> +
+
+ + )} + + ); +} diff --git a/src/services/urls.ts b/src/services/urls.ts index 5ad62b0b2..2f05ab020 100644 --- a/src/services/urls.ts +++ b/src/services/urls.ts @@ -220,6 +220,7 @@ export const organizationRoutes = { putUpdateOrganization: "/api/v1/dashboard/organisation/institutes/edit/", deleteOrgnaization: "/api/v1/dashboard/organisation/institutes/delete/", postGetInfo: "/api/v1/dashboard/organisation/institutes/info/", + getUnverifiedOrganizations: "/api/v1/dashboard/organisation/verify/list/", getOrgCsv: (org_type: string) => `/api/v1/dashboard/organisation/institutes/${org_type}/csv/`,