Skip to content

Commit

Permalink
Refactor code: Remove Spinner component and update mentor feedback fo…
Browse files Browse the repository at this point in the history
…rm UI
  • Loading branch information
mayura-andrew committed Oct 10, 2024
1 parent 77c11b5 commit 882152b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { z } from 'zod';
import { MenteeCheckInSchema } from '../../schemas';
import { useSubmitCheckIn } from '../../hooks/useSubmitCheckIn';
import closeIcon from '../../assets/svg/closeIcon.svg';
import Spinner from '../Spinner/Spinner.component';
import CloseIcon from '../../assets/svg/Icons/CloseIcon';
import Loading from '../../assets/svg/Loading';

type MenteeCheckInForm = z.infer<typeof MenteeCheckInSchema>;

Expand Down Expand Up @@ -221,11 +221,16 @@ const MonthlyCheckInModal: React.FC<{
<button
type="submit"
disabled={loading}
className={`inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white ${
loading ? 'bg-gray-400' : 'bg-blue-600 hover:bg-blue-700'
} focus:outline-none focus:ring focus:ring-blue-500`}
className="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700
focus:outline-none focus:ring focus:ring-blue-500"
>
{loading ? <Spinner /> : 'Submit Check-In'}
{loading ? (
<div className="inline-flex items-center justify-center w-6 h-6">
<Loading />
</div>
) : (
'Submit'
)}
</button>
<button
type="button"
Expand Down
4 changes: 2 additions & 2 deletions src/components/MonthlyChecking/MenteeMonthlyChecking.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React, { useState } from 'react';
import { format } from 'date-fns';
import Spinner from '../Spinner/Spinner.component';
import NoCheckInsIcon from '../../assets/svg/Icons/NoCheckInsIcon';
import { useMonthlyCheckIns } from '../../hooks/useSubmitCheckIn';
import { MonthlyCheckIn } from '../../types';
import NewSubmissionsToggle from '../Toggle/NewSubmissionToggle';
import HistoryToggle from '../Toggle/HistoryToggle';
import ArrowIcon from '../../assets/svg/Icons/ArrowIcon';
import Loading from '../../assets/svg/Loading';

interface MenteeMonthlyCheckingProps {
menteeId: string;
Expand Down Expand Up @@ -118,7 +118,7 @@ const MenteeMonthlyChecking: React.FC<MenteeMonthlyCheckingProps> = ({
if (isLoading) {
return (
<div className="flex justify-center items-center h-64">
<Spinner />
<Loading />
</div>
);
}
Expand Down
10 changes: 6 additions & 4 deletions src/components/MonthlyChecking/MentorFeedbackForm.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useForm } from 'react-hook-form';
import { zodResolver } from '@hookform/resolvers/zod';
import { MentorFeedbackSchema } from '../../schemas';
import { useMentorFeedback } from '../../hooks/useSubmitCheckIn';
import Spinner from '../Spinner/Spinner.component';
import Loading from '../../assets/svg/Loading';

interface MentorFeedbackFormData {
menteeId: string;
Expand Down Expand Up @@ -53,7 +53,10 @@ const MentorFeedbackForm: React.FC<MentorFeedbackFormProps> = ({
};

return (
<form onSubmit={handleSubmit(handleSubmitFeedback)} className="mt-3">
<form
onSubmit={handleSubmit(handleSubmitFeedback)}
className="mt-3 p-4 bg-gray-100 rounded-md shadow-sm"
>
<input type="hidden" {...register('menteeId')} />
<input type="hidden" {...register('checkInId')} />
<textarea
Expand Down Expand Up @@ -83,8 +86,7 @@ const MentorFeedbackForm: React.FC<MentorFeedbackFormProps> = ({
>
{isSubmitting ? (
<span className="flex items-center justify-center">
<Spinner />
<span>Submitting...</span>
<Loading />
</span>
) : (
'Submit Feedback'
Expand Down
6 changes: 3 additions & 3 deletions src/components/MonthlyChecking/MentorMonthlyChecking.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React, { useState } from 'react';
import { format } from 'date-fns';
import MentorFeedbackForm from './MentorFeedbackForm.component';
import Spinner from '../Spinner/Spinner.component';
import NoCheckInsIcon from '../../assets/svg/Icons/NoCheckInsIcon';
import { MonthlyCheckIn } from '../../types';
import NewSubmissionsToggle from '../Toggle/NewSubmissionToggle';
import HistoryToggle from '../Toggle/HistoryToggle';
import ArrowIcon from '../../assets/svg/Icons/ArrowIcon';
import Loading from '../../assets/svg/Loading';

interface MentorMonthlyCheckingProps {
menteeId: string;
Expand Down Expand Up @@ -111,7 +111,7 @@ const CheckInItem: React.FC<CheckInItemProps> = ({
<>
{isSubmitting ? (
<div className="flex justify-center items-center h-32">
<Spinner />
<Loading />
</div>
) : (
!isAdmin && (
Expand Down Expand Up @@ -155,7 +155,7 @@ const MentorMonthlyChecking: React.FC<MentorMonthlyCheckingProps> = ({
if (isLoading) {
return (
<div className="flex justify-center items-center h-64">
<Spinner />
<Loading />
</div>
);
}
Expand Down
6 changes: 0 additions & 6 deletions src/components/Spinner/Spinner.component.tsx

This file was deleted.

0 comments on commit 882152b

Please sign in to comment.