diff --git a/src/components/ProfileCoverpage.tsx b/src/components/ProfileCoverpage.tsx index 98379665c..961d602ed 100644 --- a/src/components/ProfileCoverpage.tsx +++ b/src/components/ProfileCoverpage.tsx @@ -62,7 +62,7 @@ export default function ProfileCoverpage({ formData.append('upload_preset', 'my_upload'); const avatar = await axios.post( - 'https://api.cloudinary.com/v1_1/dj24yfas5/image/upload', + `${process.env.COVER_IMAGE_URL}`, formData, ); /* istanbul ignore next */ @@ -97,7 +97,7 @@ export default function ProfileCoverpage({ formData.append('upload_preset', 'my_upload'); const cover = await axios.post( - 'https://api.cloudinary.com/v1_1/dta2axdpw/image/upload', + `${process.env.COVER_IMAGE_URL}`, formData, ); /* istanbul ignore next */ diff --git a/src/components/ProfileTabs.tsx b/src/components/ProfileTabs.tsx index d33cfc2fb..9336c2528 100644 --- a/src/components/ProfileTabs.tsx +++ b/src/components/ProfileTabs.tsx @@ -23,8 +23,22 @@ import { UserContext } from '../hook/useAuth'; import { CountryComponent } from '../pages/Profile'; import { GET_ALL_TRAINEES } from '../Mutations/Ratings'; -import { FaEdit, FaEraser, FaGithub, FaGithubSquare, FaPlusSquare, FaRemoveFormat } from 'react-icons/fa'; -import { ADD_REPO, GET_GITHUB_STATISTICS, GET_ORGANISATION, REMOVE_REPO, UPDATE_ORGANISATION_NAME, GET_TRAINEE_PROFILE, } from '../Mutations/manageStudentMutations'; +import { + FaEdit, + FaEraser, + FaGithub, + FaGithubSquare, + FaPlusSquare, + FaRemoveFormat, +} from 'react-icons/fa'; +import { + ADD_REPO, + GET_GITHUB_STATISTICS, + GET_ORGANISATION, + REMOVE_REPO, + UPDATE_ORGANISATION_NAME, + GET_TRAINEE_PROFILE, +} from '../Mutations/manageStudentMutations'; import Spinner from './Spinner'; import GitHubActivityChart from './chartGitHub'; import BookOpenIcon from '@heroicons/react/outline/BookOpenIcon'; @@ -130,9 +144,9 @@ export default function ProfileTabs({ data: profileData }: any) { cohort: null, team: null, phase: null, - startDate: null + startDate: null, }); - const role: String | undefined = profileData?.user?.role + const role: String | undefined = profileData?.user?.role; /* istanbul ignore next */ const [fetchData2] = useLazyQuery(GET_ALL_TRAINEES, { @@ -147,11 +161,11 @@ export default function ProfileTabs({ data: profileData }: any) { }, }); - const [getGitHubStatistics]= useLazyQuery(GET_GITHUB_STATISTICS, { + const [getGitHubStatistics] = useLazyQuery(GET_GITHUB_STATISTICS, { variables: { organisation: localStorage.getItem('orgName')?.split('.')[0], username: profileData?.githubUsername, - } + }, }); const [fetchProfile] = useLazyQuery(GET_TRAINEE_PROFILE, { @@ -160,40 +174,39 @@ export default function ProfileTabs({ data: profileData }: any) { }, }); - - -/* istanbul ignore next */ + /* istanbul ignore next */ useEffect(() => { - switch(role) { + switch (role) { case 'manager': setManagementData((data: any) => ({ ...data, - program: profileData.user.program?.name - })) + program: profileData.user.program?.name, + })); break; case 'coordinator': setManagementData((data: any) => ({ ...data, cohort: profileData.user.cohort?.name, - program: profileData.user.cohort?.program?.name - })) + program: profileData.user.cohort?.program?.name, + })); break; case 'trainee': // eslint-disable-next-line no-case-declarations - const {team} = profileData.user - team && setManagementData((data: any) => ({ - ...data, - program: team.cohort?.program?.name, - cohort: team.cohort?.name, - team: team.name, - phase: team.cohort?.phase?.name, - startDate: team.cohort?.startDate - })) + const { team } = profileData.user; + team && + setManagementData((data: any) => ({ + ...data, + program: team.cohort?.program?.name, + cohort: team.cohort?.name, + team: team.name, + phase: team.cohort?.phase?.name, + startDate: team.cohort?.startDate, + })); break; default: } - }, [profileData, role]) -/* istanbul ignore next */ + }, [profileData, role]); + /* istanbul ignore next */ useEffect(() => { fetchData2({ fetchPolicy: 'network-only', @@ -207,44 +220,40 @@ export default function ProfileTabs({ data: profileData }: any) { getGitHubStatistics({ fetchPolicy: 'network-only', onCompleted: (data) => { - setIsLoaded(false) + setIsLoaded(false); setGitHubStatistics(data.gitHubActivity); - }, - onError:(error)=>{ - setIsLoaded(false) - } - }); + onError: (error) => { + setIsLoaded(false); + }, + }); fetchOrgData({ fetchPolicy: 'network-only', onCompleted: (data) => { setOrganisation(data.getOrganization); - } + }, }); - fetchProfile({ fetchPolicy: 'network-only', onCompleted: (data) => { setTraineeProfile(data.getProfile); - }, }); - }, []); const [addActiveRepostoOrganization] = useMutation(ADD_REPO, { variables: { name: orgName, - repoUrl: repo + repoUrl: repo, }, /* istanbul ignore next */ onCompleted: (data) => { setTimeout(() => { setButtonLoading(false); toast.success(' added successfully'); - setRepoModel(false); + setRepoModel(false); }, 500); }, /* istanbul ignore next */ @@ -252,17 +261,15 @@ export default function ProfileTabs({ data: profileData }: any) { setTimeout(() => { setButtonLoading(false); toast.error(err.message); - setRepoModel(false); - + setRepoModel(false); }, 1000); }, }); - const [removeActiveRepostoOrganization] = useMutation(REMOVE_REPO, { variables: { name: orgName, - repoUrl: repo + repoUrl: repo, }, /* istanbul ignore next */ onCompleted: (data) => { @@ -275,22 +282,19 @@ export default function ProfileTabs({ data: profileData }: any) { toast.success('deleted successfully'); setRemoveRepoModel(false); }, 500); - } + }, }); - }, /* istanbul ignore next */ onError: (err) => { setTimeout(() => { setButtonLoading(false); toast.error(err.message); - setRepoModel(false); - + setRepoModel(false); }, 1000); }, }); - const [updateGithubOrganisation] = useMutation(UPDATE_ORGANISATION_NAME, { /* istanbul ignore next */ onCompleted: (data) => { @@ -303,9 +307,8 @@ export default function ProfileTabs({ data: profileData }: any) { toast.success('organisation name updated'); setOrgModel(false); }, 500); - } + }, }); - }, /* istanbul ignore next */ onError: (err) => { @@ -313,7 +316,6 @@ export default function ProfileTabs({ data: profileData }: any) { setButtonLoading(false); toast.error(err.message); setOrgModel(false); - }, 1000); }, }); @@ -326,9 +328,7 @@ export default function ProfileTabs({ data: profileData }: any) { setSingleUser(singleTrainne[0]); // returns an object with single trainnee data that can be accessed singleUser.email }, [traineeData]); - - - + console.log('ProfileData', traineeProfile); return (
@@ -339,43 +339,45 @@ export default function ProfileTabs({ data: profileData }: any) { className="flex flex-row flex-wrap pt-3 pb-4 mb-0 text-black list-none dark:text-dark-text-fill" role="tablist" > - {tabs.filter((tab) => { - switch (role) { - case "superAdmin": - if (tab === "About") { - return true - } - return false - default: - return true; - } - }).map((tab) => ( -
  • - { - /* istanbul ignore next */ - e.preventDefault(); - /* istanbul ignore next */ - setOpenTab(`${tab}`); - }} - data-toggle="tab" - href="#link1" - role="tablist" - data-testid="tab-link" + {tabs + .filter((tab) => { + switch (role) { + case 'superAdmin': + if (tab === 'About') { + return true; + } + return false; + default: + return true; + } + }) + .map((tab) => ( +
  • - {t(tab)} - -
  • - ))} + { + /* istanbul ignore next */ + e.preventDefault(); + /* istanbul ignore next */ + setOpenTab(`${tab}`); + }} + data-toggle="tab" + href="#link1" + role="tablist" + data-testid="tab-link" + > + {t(tab)} + + + ))} {/* Profile tabs option end */}
    @@ -391,15 +393,15 @@ export default function ProfileTabs({ data: profileData }: any) {

    - {profileData?.name || "Name not available"}{' '} + {profileData?.name || 'Name not available'}{' '}

    - {user?.email || "unavailable"} + {user?.email || 'unavailable'}
    - {profileData?.phoneNumber || "unavailable"} + {profileData?.phoneNumber || 'unavailable'}
    @@ -407,8 +409,8 @@ export default function ProfileTabs({ data: profileData }: any) { {/* istanbul ignore next */} {profileData?.city && /* istanbul ignore next */ - profileData?.country && ',' - } + profileData?.country && + ','} {profileData?.country && ( /* istanbul ignore next */ @@ -417,204 +419,249 @@ export default function ProfileTabs({ data: profileData }: any) {
    {profileData?.githubUsername} -
    - -
    - - - View Resume - +
    + {traineeProfile.resume ? ( + <> + + + View Resume + + + ) : ( +

    No Resume uploaded yet

    + )}
    - + {/* Or you can disable the link like below */} + {/*
    + {traineeProfile.resume ? ( + <> + + + View Resume + + + ) : ( + + )} +
    */}
    -

    - {t('Biography')} -

    -

    {profileData?.biography || 'No biography'}

    +

    {t('Biography')}

    +

    + {profileData?.biography || 'No biography'} +

    {/* istanbul ignore next */} - {role && [].includes(role as never) && - /* istanbul ignore next */ -
    -
    - logo -
    -

    - {orgName} -

    -

    - https://andela.pulse.com/ -

    -
    -
    -
    -

    - {/* You in the organization */} - {t('You in the organization')} -

    -
    -

    {t('Role')}:

    - {user?.role} -
    -
    -

    {t('Team')}:

    - {singleUser && singleUser.team - ? singleUser.team.name - : 'Unavailabe'} -
    -
    -
    -

    - {t('Management')} -

    -
    -

    - {t('program')}: -

    - {singleUser && singleUser.team - ? singleUser.team.cohort.program.name - : 'Unavailabe'} + {role && [].includes(role as never) && ( + /* istanbul ignore next */ +
    +
    + logo +
    +

    + {orgName} +

    +

    + https://andela.pulse.com/ +

    +
    -
    -

    - {t('Stage(current)')}: +
    +

    + {/* You in the organization */} + {t('You in the organization')} +

    +
    +

    + {t('Role')}: +

    + {user?.role} +
    +
    +

    + {t('Team')}: +

    {singleUser && singleUser.team - ? singleUser.team.cohort.phase.name + ? singleUser.team.name : 'Unavailabe'} -

    +
    -
    -

    - {t('Manager')}: -

    +
    +

    + {t('Management')} +

    +
    +

    + {t('program')}: +

    + {singleUser && singleUser.team + ? singleUser.team.cohort.program.name + : 'Unavailabe'} +
    +
    +

    + {t('Stage(current)')}: + {singleUser && singleUser.team + ? singleUser.team.cohort.phase.name + : 'Unavailabe'} +

    +
    +
    +

    + {t('Manager')}: +

    - {singleUser && singleUser.team - ? singleUser.team.cohort.program.manager.profile.name - : 'Unavailabe'} + {singleUser && singleUser.team + ? singleUser.team.cohort.program.manager.profile.name + : 'Unavailabe'} +
    -
    } + )}
    - - - {isLoaded?( -

    - -

    - - Loading gitHub statistics... - - -
    -
    -

    - ):( -
    -
    - - - - {gitHubStatistics?.totalCommits} total commits - - - - -
    -
    -
    - {gitHubStatistics?( - - ):( - <> - - + {isLoaded ? ( +

    +

    + Loading gitHub statistics... + +
    +
    +

    + ) : ( +
    +
    + + {gitHubStatistics?.totalCommits} total commits + +
    +
    +
    + {gitHubStatistics ? ( + + ) : ( + <> + )} +
    +
    +
    )} - -
    -
    - )} -
    -
    +

    - Github Organisation - + Github Organisation

    -
    -
    - - {organisation?.gitHubOrganisation} -
    - - { - setOrg(organisation?.gitHubOrganisation); - setOrgModel(true); - }} /> +
    +
    + + {organisation?.gitHubOrganisation} +
    + { + setOrg(organisation?.gitHubOrganisation); + setOrgModel(true); + }} + />
    - -
    -
    -

    - Repository - -

    - */} - - -
    -
    - {organisation?.activeRepos?.map((repo: any) => ( -
    -

    - {repo} -

    - - { - setRepo(repo) - setRemoveRepoModel(true) - }} /> - -
    +
    + {organisation?.activeRepos?.map((repo: any) => ( +
    +

    + {repo} +

    + + { + setRepo(repo); + setRemoveRepoModel(true); + }} + /> +
    ))} -
    - +
    @@ -639,56 +686,60 @@ export default function ProfileTabs({ data: profileData }: any) {
    -
    +

    {t('You in the organization')}

    -

    {t('Role')}:

    +

    + {t('Role')}: +

    {user?.role}
    -
    - {role && ['manager', 'coordinator', 'trainee'].includes(role as never) && ( -
    -

    - {t('Management')} -

    - {managementData.program && ( -
    -

    - {t('Program')}: -

    - {managementData.program} -
    - )} - {managementData.cohort && ( -
    -

    - {t('Cohort')}: -

    - {managementData.cohort} -
    - )} - {managementData.team && ( -
    -

    - {t('Team')}: -

    - {managementData.team} -
    - )} - {managementData.phase && ( -
    -

    - {t('Phase')}: -

    - {managementData.phase} -
    - )} -
    - )} + {role && + ['manager', 'coordinator', 'trainee'].includes( + role as never, + ) && ( +
    +

    + {t('Management')} +

    + {managementData.program && ( +
    +

    + {t('Program')}: +

    + {managementData.program} +
    + )} + {managementData.cohort && ( +
    +

    + {t('Cohort')}: +

    + {managementData.cohort} +
    + )} + {managementData.team && ( +
    +

    + {t('Team')}: +

    + {managementData.team} +
    + )} + {managementData.phase && ( +
    +

    + {t('Phase')}: +

    + {managementData.phase} +
    + )} +
    + )}
    @@ -703,68 +754,59 @@ export default function ProfileTabs({ data: profileData }: any) {
    + {' '} + {/* =========================== Start:: RemoveTraineeModel =============================== */} +
    +
    +
    +

    + {t('Remove Repo')} +

    +
    +
    +
    +
    +
    +

    + Are you sure you want to delete this repository, +

    +
    - {/* =========================== Start:: RemoveTraineeModel =============================== */} - -
    -
    -
    -

    - {t('Remove Repo')} -

    -
    -
    -
    - -
    -

    - - Are you sure you want to delete this repository, - -

    -
    - -
    - - +
    + + +
    + +
    - -
    -
    -
    -{/* =========================== End:: RemoveTraineeModel =============================== */} - - - - -{/* =========================== Start:: InviteTraineeModel =============================== */} - -
    + {/* =========================== End:: RemoveTraineeModel =============================== */} + {/* =========================== Start:: InviteTraineeModel =============================== */} +

    - Fill in the repository name + Fill in the repository name

    @@ -805,13 +847,10 @@ export default function ProfileTabs({ data: profileData }: any) { variant="info" size="sm" style="w-[30%] md:w-1/4 text-sm font-sans" - onClick={ - () => setRepoModel(false) - } + onClick={() => setRepoModel(false)} children={t('Cancel')} /> -
    {/* =========================== End:: InviteTraineeModel =============================== */} - - - -{/* =========================== Start:: InviteTraineeModel =============================== */} - -

    - Fill in the organisation name + Fill in the organisation name

    @@ -876,13 +911,10 @@ export default function ProfileTabs({ data: profileData }: any) { variant="info" size="sm" style="w-[30%] md:w-1/4 text-sm font-sans" - onClick={ - () => setOrgModel(false) - } + onClick={() => setOrgModel(false)} children={t('Cancel')} /> -
    diff --git a/src/pages/tests/__snapshots__/userRegister.test.tsx.snap b/src/pages/tests/__snapshots__/userRegister.test.tsx.snap index 862e468dd..d361fadac 100644 --- a/src/pages/tests/__snapshots__/userRegister.test.tsx.snap +++ b/src/pages/tests/__snapshots__/userRegister.test.tsx.snap @@ -72,7 +72,7 @@ exports[`TraineeRatingDashboard Tests Renders TraineeRatingDashboard 1`] = ` className="text-gray-400 border border-primary py-2 dark:bg-dark-bg rounded outline-none px-5 font-sans text-xs w-full h-[38px] " data-placeholder="Date of birth" id="date-placeholder" - max="2023-10-02" + max="2023-09-19" name="dateOfBirth" onBlur={[Function]} onChange={[Function]}