mohammed-ahad

Untitled

Sep 19th, 2023
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { Fragment, useState } from "react";
  2. import { useForm, SubmitHandler } from "react-hook-form";
  3. import { zodResolver } from "@hookform/resolvers/zod";
  4. import * as z from "zod";
  5. import Page from "../../components/Page";
  6. import HobbiesDropdown from "../../components/DropdownMenu";
  7. import DayPicker from "../../components/DayPicker";
  8. import {
  9.   DEPARTMENT_NAME_QUERY,
  10.   DepartmentName,
  11. } from "../../gql/departmentQuery";
  12. import { useQuery } from "@apollo/client";
  13. import { useMutation } from "@apollo/client";
  14. import { CREATE_TEAM_MUTATION, MODIFY_TEAM_MUTATION, CreateTeamInput, UpdateTeamInput} from "../../gql/teamMutation";
  15. import { STAFF_MUTATION } from "../../gql/staffMutation";
  16. import { UserI } from "../../types";
  17. import { getUser } from "../../utils/getUser";
  18. import { UseQueryResult, useQuery as reactUseQuery } from "react-query";
  19. import Upload from "../../components/UploadAntDesign";
  20. import { useToasts } from "react-toast-notifications";
  21.  
  22. export default function CreateTeamForm() {
  23.   const { register, handleSubmit, formState: { errors } } = useForm<CreateTeamInput>();
  24.   const [createTeam] = useMutation(CREATE_TEAM_MUTATION);
  25.  
  26.   const onSubmit: SubmitHandler<CreateTeamInput> = async (data) => {
  27.     try {
  28.       const response = await createTeam({ variables: { newTeam: data } });
  29.       console.log('Team created', response);
  30.     } catch (error) {
  31.       console.error('Error creating team', error);
  32.     }
  33.   };
  34.  
  35.  
  36.   return (
  37.     <Page>
  38.     {/* Hero Section */}
  39.     <div className="grid place-items-center py-12">
  40.       <div
  41.         className="absolute inset-x-0 -top-40 -z-20 transform-gpu overflow-hidden blur-3xl sm:-top-80"
  42.         aria-hidden="true"
  43.       >
  44.         <div
  45.           className="relative left-[calc(50%-11rem)] aspect-[1155/678] w-[36.125rem] -translate-x-1/2 rotate-[30deg] bg-gradient-to-tr from-[#bfdbfe] to-[#2563eb] opacity-30 sm:left-[calc(50%-30rem)] sm:w-[72.1875rem]"
  46.           style={{
  47.             clipPath:
  48.               "polygon(74.1% 44.1%, 100% 61.6%, 97.5% 26.9%, 85.5% 0.1%, 80.7% 2%, 72.5% 32.5%, 60.2% 62.4%, 52.4% 68.1%, 47.5% 58.3%, 45.2% 34.5%, 27.5% 76.7%, 0.1% 64.9%, 17.9% 100%, 27.6% 76.8%, 76.1% 97.7%, 74.1% 44.1%)",
  49.           }}
  50.         />
  51.       </div>
  52.       <div className="mx-auto max-w-2xl">
  53.         <h1 className="text-4xl text-center font-semibold tracking-tight text-text-primary sm:text-6xl animate__animated animate__slideInDown flex pl-4 justify-center">
  54.           Creating or Updating a Team
  55.         </h1>
  56.         <p className="mt-6 text-lg text-center leading-8 text-text-secondary">
  57.           This page serves as a dedicated platform to efficiently manage teams
  58.           within a designated department. Seamlessly add or amend
  59.           teams from the chosen department.
  60.         </p>
  61.       </div>
  62.  
  63.     <form onSubmit={handleSubmit(onSubmit)}>
  64.       <div>
  65.         <label>Department ID</label>
  66.         <input {...register('departmentID', { required: true })} type="number" />
  67.         {errors.departmentID && <span>This field is required</span>}
  68.       </div>
  69.       <div>
  70.         <label>Title</label>
  71.         <input {...register('title')} type="text" />
  72.       </div>
  73.       {/* Add other fields here following the same pattern */}
  74.       <button type="submit">Create Team</button>
  75.     </form>
  76.     </div>
  77.     </Page>
  78.   );
  79. }
  80.  
Advertisement
Add Comment
Please, Sign In to add comment