Skip to content

Fix coordinators table #629

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/Mutations/User.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ export const DROP_TTL_USER = gql`
}
`;

export const DROP_COORDINATOR = gql`
mutation DropCordinator($id: String!, $reason: String!) {
dropCordinator(id: $id, reason: $reason)
}
`;
export const UNDROP_COORDINATOR = gql`
mutation UndropCordinator($id: String!) {
undropCordinator(id: $id)
}
`;

export const UNDROP_TTL_USER = gql`
mutation UnDropTTLUser($email: String!) {
undropTTLUser(email: $email)
Expand Down
21 changes: 9 additions & 12 deletions src/components/DataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,36 +68,33 @@ function DataTable({ data, columns, title, loading, className }: TableData) {

return (
<div
className={`relative font-serif bg-indigo-100 dark:bg-dark-bg shadow-lg h-fit px-5 md:py-4 lg:py-5 rounded-md w-[100%] overflow-auto custom-scrollbar "lg:ml-60 mx-auto"} lg:mb-10 ${className}`}
className={`relative font-serif bg-indigo-100 dark:bg-dark-bg shadow-lg h-fit px-5 py-8 rounded-md w-[100%] overflow-scroll "lg:ml-60 mx-auto"} mb-10 ${className}`}
>
<div className="flex flex-col md:flex-row items-center justify-between pb-6 space-y-4 md:space-y-0">
<div>
<h2 className="text-lg md:text-xl font-semibold text-gray-800 dark:text-white">
{t(title)}
</h2>
{/* Uncomment if you want a filter input */}
{/* <input
<input
value={filterInput}
aria-label="Filter table data"
placeholder="Filter"
className="px-4 py-2 mt-4 font-sans text-xs md:text-sm border rounded outline-none border-primary dark:bg-neutral-600 dark:text-white w-full sm:w-52 md:w-96"
onChange={handleFilterChange}
/> */}
/>
</div>
</div>
<div className="overflow-x-auto custom-scrollbar">
<div className="overflow-x-auto">
<table
className="min-w-full leading-normal text-xs md:text-sm"
{...getTableProps()}
>
<thead>
{headerGroups.map((headerGroup) => (
<tr {...headerGroup.getHeaderGroupProps()} key={headerGroup.id}>
<tr {...headerGroup.getHeaderGroupProps()}>
{headerGroup.headers.map((column) => (
<th
className={`thead w-1/${columns.length} text-center ${
column.isSorted ? 'sort-asc' : ''
}`}
className={`thead ${column.isSorted ? 'sort-asc' : ''}`}
{...column.getHeaderProps(column.getSortByToggleProps())}
key={column.id}
>
Expand All @@ -116,15 +113,15 @@ function DataTable({ data, columns, title, loading, className }: TableData) {
<tr
className={`border-b dark:border-gray-700 ${
row.index % 2 === 0
? 'bg-gray-600 dark:bg-neutral-600'
: 'bg-transparent'
? 'bg-light-bg dark:bg-neutral-600'
: 'bg-white dark:bg-dark-bg'
}`}
{...row.getRowProps()}
key={row.id}
>
{row.cells.map((cell) => (
<td
className={`w-1/${columns.length} data-cell px-4 py-2 text-center`}
className="data-cell px-4 py-2"
{...cell.getCellProps()}
key={cell.column.id}
>
Expand Down
118 changes: 118 additions & 0 deletions src/components/DropOrUndropUser.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';
import Button from './Buttons';

interface DropOrUndropUserProps {
subject: string;
title: string;
drop?: boolean;
loading: boolean;
removalReason?: string;
setRemovalReason?: React.Dispatch<React.SetStateAction<string>>;
onSubmit: (data: React.MouseEvent<HTMLButtonElement>) => void;
onClose: () => void;
}

function DropOrUndropUser({
subject,
title,
drop,
loading,
removalReason,
setRemovalReason,
onSubmit,
onClose,
}: DropOrUndropUserProps) {
const { t } = useTranslation();

const handleConfirm = (e: React.MouseEvent<HTMLButtonElement>) => {
e.stopPropagation();
if (onSubmit) onSubmit(e);
};

return (
<div className="h-screen w-screen bg-black bg-opacity-30 backdrop-blur-sm fixed top-0 left-0 z-20 flex items-center justify-center px-4">
<div className="w-full p-4 pb-8 bg-white rounded-lg dark:bg-dark-bg sm:w-3/4 xl:w-4/12">
<div className="flex flex-wrap items-center justify-center w-full card-title ">
<h3 className="w-11/12 text-sm font-bold text-center dark:text-white ">
{t(subject)}
</h3>
<hr className="w-full my-3 border-b bg-primary" />
</div>
<div className="card-body w-full">
<form className="px-8 py-3 w-full">
<div className="flex flex-wrap items-center justify-center w-full card-title ">
<h3 className="w-11/12 text-sm font-bold text-center dark:text-white ">
{t(title)}
</h3>
</div>
{/* Reason input field */}
{drop && setRemovalReason && (
<div className="mt-4">
<input
type="text"
className="mt-1 p-2 block w-full border rounded-md shadow-sm focus:ring focus:ring-opacity-50 focus:ring-primary dark:bg-dark-bg dark:border-gray-600 dark:text-white"
placeholder={t('Enter reason')}
value={removalReason}
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
setRemovalReason(e.target.value)
}
id="removalReason"
/>
<p
id="errorMessage"
className="text-red-500 text-xs mt-1 hidden"
>
Reason is required!
</p>
</div>
)}

<div className="flex justify-between w-full pt-3">
<Button
data-testid="removeModel2"
variant="info"
size="sm"
style="w-[8rem] h-[2.3rem] text-sm p-0 mx-0 flex justify-center items-center"
onClick={() => {
if (drop && setRemovalReason) {
setRemovalReason('');
document
.getElementById('errorMessage')!
.classList.add('hidden');
}
onClose();
}}
>
{t('Cancel')}
</Button>
<Button
variant="primary"
size="sm"
style="w-[8rem] h-[2.3rem] text-sm p-0 mx-0 flex justify-center items-center"
onClick={() => {
if (removalReason && !removalReason.trim() && drop) {
document
.getElementById('errorMessage')!
.classList.remove('hidden');
} else {
handleConfirm(
new MouseEvent(
'click',
) as unknown as React.MouseEvent<HTMLButtonElement>,
);
}
}}
loading={loading}
>
{loading ? t('Loading') : t('Proceed')}
</Button>
</div>
</form>
</div>
</div>
</div>
);
}

export default DropOrUndropUser;
2 changes: 1 addition & 1 deletion src/components/ViewComment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function Comment({ remark }: CommentProps) {
{isModalOpen && <div className="blur-background" />}
<dialog
ref={dialog}
className={`rounded-lg shadow-lg w-[40%] ${
className={`rounded-lg m-auto shadow-lg w-[40%] ${
isModalOpen ? 'modal-open' : ''
}`}
dat-testid="dialog"
Expand Down
Loading
Loading