diff --git a/src/components/AppHeader.jsx b/src/components/AppHeader.jsx
index c954218..0c6b06c 100644
--- a/src/components/AppHeader.jsx
+++ b/src/components/AppHeader.jsx
@@ -11,33 +11,45 @@ import NotificationsIcon from '@mui/icons-material/Notifications';
import EventAvailableIcon from '@mui/icons-material/EventAvailable';
import AccountCircle from '@mui/icons-material/AccountCircle';
import MoreIcon from '@mui/icons-material/MoreVert';
+import { Tooltip } from '@mui/material';
import { useQuery } from '@apollo/client';
import { GET_PROFILE, GET_ALL_OFFERS, GET_ALL_INTERVIEWS } from '../graphql/query';
import SearchBar from './SearchBar';
+import InterviewListDialog from './InterviewListDialog';
import JobApplicationDialog from './JobApplicationDialog';
import OfferListDialog from './OfferListDialog';
+import useInterviewListDialog from './hooks/useInterviewDialog';
import useJobApplicationDialog from './hooks/useJobApplicationDialog';
-import useOfferListDialog from './hooks/useOfferList';
+import useOfferListDialog from './hooks/useOfferListDialog';
import ProfileDialog from './ProfileDialog';
import JobApplicationList from './JobApplicationList';
import MobileMenu from './MobileMenu';
-import dayjs from 'dayjs';
+import { getFilteredInterviews } from '../utils/interviewUtil';
export default function AppHeader() {
const [mobileMoreAnchorEl, setMobileMoreAnchorEl] = useState(null);
const [profileOpen, setProfileOpen] = useState(false);
const [profile, setProfile] = useState('');
const [searchTerm, setSearchTerm] = useState('');
- const { data: offersData, loading: offersLoading, error: offersError, refetch } = useQuery(GET_ALL_OFFERS, {
+ const { data: offersData, loading: offersLoading, error: offersError, refetch: refetchOffers } = useQuery(GET_ALL_OFFERS, {
fetchPolicy: 'network-only',
});
- const { open, handleOpen, handleClose } = useJobApplicationDialog(refetch);
+ const { data: interviewsData, loading: interviewsLoading, error: interviewsError, refetch: refetchInterviews } = useQuery(GET_ALL_INTERVIEWS, {
+ fetchPolicy: 'network-only',
+ });
+ const { open, handleOpen, handleClose } = useJobApplicationDialog(refetchOffers);
- const {
+ const {
offerListingDialogOpen,
handleOfferListDialogOpen,
handleOfferListDialogClose,
- } = useOfferListDialog(refetch);
+ } = useOfferListDialog(refetchOffers);
+
+ const {
+ interviewListingDialogOpen,
+ handleInterviewListDialogOpen,
+ handleInterviewListDialogClose,
+ } = useInterviewListDialog(refetchInterviews);
const isMobileMenuOpen = Boolean(mobileMoreAnchorEl);
@@ -48,24 +60,9 @@ export default function AppHeader() {
variables: { id },
});
- const { data: interviewsData, loading: interviewsLoading, error: interviewsError } = useQuery(GET_ALL_INTERVIEWS, {
- fetchPolicy: 'network-only',
- });
-
const offerCount = offersData?.allOffer?.length || 0;
- const filteredInterviews = interviewsData?.allInterview?.filter((interview) => {
- const interviewDate = dayjs(interview.interviewDate);
- if (!interviewDate.isValid()) {
- console.warn('Invalid dayjs object for interviewDate:', interview.interviewDate);
- return false;
- }
-
- return (
- (interviewDate.isSame(dayjs(), 'day') || interviewDate.isAfter(dayjs(), 'day')) &&
- ['open', 'pending'].includes(interview.status)
- );
- }) || [];
+ const filteredInterviews = getFilteredInterviews(interviewsData?.allInterview);
const interviewCount = filteredInterviews?.length || 0;
@@ -96,6 +93,11 @@ export default function AppHeader() {
handleClose={handleProfileClose}
setOpen={setProfileOpen}
/>
+
-
-
-
- refetch()}>
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
setInterviews(getFilteredInterviews(data.allInterview)),
+ });
+
+ const {
+ open: jobDialogOpen,
+ jobApplication,
+ handleOpen: handleJobDialogOpen,
+ handleClose: handleJobDialogClose
+ } = useJobApplicationDialog(() => {
+ refetch().then(({ data }) => setInterviews(getFilteredInterviews(data.allInterview)));
+ });
+
+ const columns = [
+ {
+ key: 'jobApplication.companyName', // Nested property example
+ label: 'Company Name',
+ sortable: true,
+ render: (value, row) => value || row.jobApplication?.companyName || 'N/A', // Fallback for nested value
+ },
+ { key: 'interviewDate', label: 'Interview Date', sortable: true },
+ { key: 'interviewer', label: 'Interviewer', sortable: true },
+ { key: 'description', label: 'Note' },
+ { key: 'status', label: 'Status', sortable: true },
+ {
+ key: 'actions',
+ label: 'Job Application',
+ render: (value, row) => (
+
+ ),
+ align: 'center',
+ },
+ ];
+
+ const { sortedData, handleSort, getSortIndicator } = useSortableTable(interviews, columns);
+
+ useEffect(() => {
+ if (open) {
+ refetch()
+ .then(({ data }) => {
+ if (data) setInterviews(getFilteredInterviews(data.allInterview));
+ })
+ .catch((err) => console.error('Refetch error:', err));
+ }
+ }, [open, refetch]);
+
+ return (
+
+ );
+}
diff --git a/src/components/JobApplicationDialog.jsx b/src/components/JobApplicationDialog.jsx
index 417eb97..1dfff9d 100644
--- a/src/components/JobApplicationDialog.jsx
+++ b/src/components/JobApplicationDialog.jsx
@@ -35,6 +35,7 @@ export default function JobApplicationDialog({ jobApplication, handleClose, open
}}
>
+ {!isNew && (
+ )}
{activeTab === 0 && (
)}
diff --git a/src/components/JobApplicationList.jsx b/src/components/JobApplicationList.jsx
index 8d16998..e5501ff 100644
--- a/src/components/JobApplicationList.jsx
+++ b/src/components/JobApplicationList.jsx
@@ -29,14 +29,12 @@ import { DELETE_JOB_APPLICATION } from '../graphql/mutation';
import { GET_JOB_APPLICATIONS } from '../graphql/query';
export default function JobApplicationList({ searchTerm }) {
- // const [open, setOpen] = useState(false);
- // const [jobApplication, setJobApplication] = useState(null);
const [jobApplicationToDelete, setJobApplicationToDelete] = useState(null);
const [localData, setLocalData] = useState([]);
const { data, loading, error } = useJobApplications();
const { snackbarOpen, snackbarMessage, showSnackbar, handleSnackbarClose } = useSnackbar();
- const { confirmOpen, openConfirmDialog, cancel } = useConfirmDialog();
+ const { confirmDialogOpen, handleConfirmDialogOpen, handleConfirmDialogClose } = useConfirmDialog();
const { open, jobApplication, handleOpen, handleClose } = useJobApplicationDialog();
const [deleteJobApplication] = useMutation(DELETE_JOB_APPLICATION, {
@@ -49,13 +47,6 @@ export default function JobApplicationList({ searchTerm }) {
}
}, [data]);
- // const handleOpen = (jobApplication) => {
- // setJobApplication(jobApplication);
- // setOpen(true);
- // };
-
- // const handleClose = () => setOpen(false);
-
const confirmDeleteJobApplication = () => {
if (jobApplicationToDelete) {
deleteJobApplication({
@@ -69,13 +60,13 @@ export default function JobApplicationList({ searchTerm }) {
showSnackbar("Failed to delete the job application.");
});
}
- cancel();
+ handleConfirmDialogClose();
setJobApplicationToDelete(null);
};
const handleDeleteJobApplication = (jobApplication) => {
setJobApplicationToDelete(jobApplication);
- openConfirmDialog();
+ handleConfirmDialogOpen();
};
const containsIgnoreCase = (str, searchTerm) =>
@@ -176,8 +167,8 @@ export default function JobApplicationList({ searchTerm }) {
)}
New
-