Skip to content

Commit

Permalink
Placing team mutations
Browse files Browse the repository at this point in the history
  • Loading branch information
YvetteNyibuka committed Oct 3, 2024
1 parent 36bc829 commit 438498a
Show file tree
Hide file tree
Showing 22 changed files with 266 additions and 220 deletions.
38 changes: 38 additions & 0 deletions src/Mutations/OrganisationMutations.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { gql } from '@apollo/client';

export const AddOrganization = gql`
mutation AddOrganization(
$organizationInput: OrganizationInput
$action: String
) {
addOrganization(organizationInput: $organizationInput, action: $action) {
id
}
}
`;

// delete organisation
export const DeleteOrganization = gql`
mutation DeleteOrganization($deleteOrganizationId: ID!) {
deleteOrganization(id: $deleteOrganizationId) {
id
name
description
}
}
`;

export const RegisterNewOrganization = gql`
mutation RegisterNewOrganization(
$organizationInput: OrganizationInput
$action: String
) {
RegisterNewOrganization(
organizationInput: $organizationInput
action: $action
) {
name
status
}
}
`;
45 changes: 45 additions & 0 deletions src/Mutations/cohortMutations.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { gql } from '@apollo/client';

export const AddCohort = gql`
mutation AddCohort(
$name: String!
$phaseName: String!
$coordinatorEmail: String!
$programName: String!
$startDate: DateTime!
$endDate: DateTime
$orgToken: String!
) {
addCohort(
name: $name
phaseName: $phaseName
coordinatorEmail: $coordinatorEmail
programName: $programName
startDate: $startDate
endDate: $endDate
orgToken: $orgToken
) {
id
name
phase {
name
}
coordinator {
email
}
program {
name
}
startDate
endDate
}
}
`;

export const DeleteCohort = gql`
mutation DeleteCohort($deleteCohortId: ID!, $orgToken: String) {
deleteCohort(id: $deleteCohortId, orgToken: $orgToken) {
id
}
}
`;
16 changes: 16 additions & 0 deletions src/Mutations/coverMutations.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { gql } from '@apollo/client';

export const UPDATE_AVATAR = gql`
mutation UpdateAvatar($avatar: String) {
updateAvatar(avatar: $avatar) {
avatar
}
}
`;
export const UPDATE_COVER = gql`
mutation UpdateCover($cover: String) {
updateCoverImage(cover: $cover) {
cover
}
}
`;
17 changes: 17 additions & 0 deletions src/Mutations/phaseMutations.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { gql } from '@apollo/client';

export const AddPhase = gql`
mutation AddPhase($name: String!, $description: String!, $orgToken: String!) {
addPhase(name: $name, description: $description, orgToken: $orgToken) {
id
}
}
`;

export const DeletePhase = gql`
mutation DeletePhase($deletePhaseId: ID!, $orgToken: String) {
deletePhase(id: $deletePhaseId, orgToken: $orgToken) {
id
}
}
`;
38 changes: 38 additions & 0 deletions src/Mutations/profileMutation.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { gql } from '@apollo/client';

export const UPDATE_PROFILE = gql`
mutation UpdateProfile(
$lastName: String
$firstName: String
$address: String
$city: String
$country: String
$phoneNumber: String
$biography: String
$fileName: String
$cover: String
$githubUsername: String
) {
updateProfile(
lastName: $lastName
firstName: $firstName
address: $address
city: $city
country: $country
phoneNumber: $phoneNumber
biography: $biography
fileName: $fileName
cover: $cover
githubUsername: $githubUsername
) {
id
lastName
firstName
biography
phoneNumber
address
city
country
}
}
`;
27 changes: 27 additions & 0 deletions src/Mutations/programMutations.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { gql } from '@apollo/client';

export const AddProgram = gql`
mutation AddProgram(
$name: String!
$description: String!
$managerEmail: String!
$orgToken: String!
) {
addProgram(
name: $name
description: $description
managerEmail: $managerEmail
orgToken: $orgToken
) {
id
}
}
`;

export const DeleteProgram = gql`
mutation DeleteProgram($deleteProgramId: ID!, $orgToken: String) {
deleteProgram(id: $deleteProgramId, orgToken: $orgToken) {
id
}
}
`;
9 changes: 9 additions & 0 deletions src/Mutations/resumeMutation.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { gql } from '@apollo/client';

export const UPLOAD_RESUME = gql`
mutation UploadResume($userId: ID!, $resume: String!) {
uploadResume(userId: $userId, resume: $resume) {
resume
}
}
`;
28 changes: 28 additions & 0 deletions src/Mutations/teamMutation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,34 @@ export const ADD_TEAMS = gql`
}
}
`;
export const AddTeam = gql`
mutation Mutation(
$name: String!
$cohortName: String!
$orgToken: String!
$startingPhase: DateTime!
$ttlEmail: String!
) {
addTeam(
name: $name
cohortName: $cohortName
orgToken: $orgToken
startingPhase: $startingPhase
ttlEmail: $ttlEmail
) {
name
cohort {
name
}
}
}
`;

export const DeleteTeam = gql`
mutation Mutation($deleteTeamId: ID!) {
deleteTeam(id: $deleteTeamId)
}
`;

export const GET_TEAMS_CARDS = gql`
query Query($orgToken: String!) {
Expand Down
12 changes: 1 addition & 11 deletions src/components/CreateOrganizationModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,7 @@ import { useForm } from 'react-hook-form';
import { TFunction, useTranslation } from 'react-i18next';
import { toast } from 'react-toastify';
import Button from './Buttons';

export const AddOrganization = gql`
mutation AddOrganization(
$organizationInput: OrganizationInput
$action: String
) {
addOrganization(organizationInput: $organizationInput, action: $action) {
id
}
}
`;
import { AddOrganization } from '../Mutations/OrganisationMutations';

export default function CreateOrganizationModal({
createOrganizationModel,
Expand Down
33 changes: 4 additions & 29 deletions src/components/Organizations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
import React, { useState, useEffect } from 'react';
import { FaEllipsisV } from 'react-icons/fa';
import { useTranslation } from 'react-i18next';
import CreateOrganizationModal, {
AddOrganization,
} from './CreateOrganizationModal';
import CreateOrganizationModal from './CreateOrganizationModal';
import { gql, useMutation, useQuery } from '@apollo/client';
import useDocumentTitle from '../hook/useDocumentTitle';
import Button from './Buttons';
import Tooltip from '@mui/material/Tooltip';
import { toast } from 'react-toastify';
import { Icon } from '@iconify/react';

import DataTable from '../components/DataTable';
import OrgSkeleton from '../Skeletons/Organization.skeleton';
import { DeleteOrganization } from '../Mutations/OrganisationMutations';
import { RegisterNewOrganization } from '../Mutations/OrganisationMutations';
import { AddOrganization } from '../Mutations/OrganisationMutations';

export interface Admin {
id: string;
Expand Down Expand Up @@ -42,31 +42,6 @@ export const getOrganizations = gql`
}
`;

export const DeleteOrganization = gql`
mutation DeleteOrganization($deleteOrganizationId: ID!) {
deleteOrganization(id: $deleteOrganizationId) {
id
name
description
}
}
`;

export const RegisterNewOrganization = gql`
mutation RegisterNewOrganization(
$organizationInput: OrganizationInput
$action: String
) {
RegisterNewOrganization(
organizationInput: $organizationInput
action: $action
) {
name
status
}
}
`;

function ActionButtons({
getData,
setData,
Expand Down
18 changes: 2 additions & 16 deletions src/components/ProfileCoverpage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { GET_PROFILE } from '../Mutations/User';
import Avatar from '../assets/avatar.png';
import Spinner from '../components/ButtonLoading';
import { UserContext } from '../hook/useAuth';
import { UPDATE_AVATAR, UPDATE_COVER } from '../Mutations/coverMutations';

export default function ProfileCoverpage({
currentPage,
Expand All @@ -29,21 +30,6 @@ export default function ProfileCoverpage({
const { t } = useTranslation();
const navigate = useNavigate();

const UPDATE_AVATAR = gql`
mutation UpdateAvatar($avatar: String) {
updateAvatar(avatar: $avatar) {
avatar
}
}
`;
const UPDATE_COVER = gql`
mutation UpdateCover($cover: String) {
updateCoverImage(cover: $cover) {
cover
}
}
`;

const client = useApolloClient();
const [UpdateAvatar, { loading }] = useMutation(UPDATE_AVATAR);
const [UpdateCover, { loading: loading2 }] = useMutation(UPDATE_COVER);
Expand Down Expand Up @@ -216,7 +202,7 @@ export default function ProfileCoverpage({
<div className="flex items-center justify-center w-full h-screen mt-24 ml-auto bg-grey-lighter">
<label className="flex items-center ml-auto mr-4 rounded-md bg-primary text-white hover:bg-[#7a5edc] p-[6px] cursor-pointer">
{spinnerCover ? (
<ClipLoader size={14} color="#ffffff" className='m-1'/>
<ClipLoader size={14} color="#ffffff" className="m-1" />
) : (
<CameraIcon className="w-5 dark:text-dark-text-fill" />
)}
Expand Down
9 changes: 1 addition & 8 deletions src/components/Resume.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,7 @@ import { toast } from 'react-toastify';
import Button from './Buttons';
import { UserContext } from '../hook/useAuth';
import Spinner from './Spinner';

const UPLOAD_RESUME = gql`
mutation UploadResume($userId: ID!, $resume: String!) {
uploadResume(userId: $userId, resume: $resume) {
resume
}
}
`;
import { UPLOAD_RESUME } from '../Mutations/resumeMutation';

interface UploadFormProps {
uploadType: number | null;
Expand Down
Loading

0 comments on commit 438498a

Please sign in to comment.