Skip to content

Commit

Permalink
feat: store history on refer link
Browse files Browse the repository at this point in the history
  • Loading branch information
Zain-ul-din committed Apr 13, 2024
1 parent 9c6ddae commit 121c52d
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions src/components/Timetable.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TimetableData, TimetableInput } from '~/types/typedef';
import styles from '~/styles/Timetable.module.css';
import Loader from './design/Loader';
import React, { useRef } from 'react';
import React, { useEffect, useRef } from 'react';

import {
TableContainer,
Expand Down Expand Up @@ -45,7 +45,16 @@ const day_sorter = {
};

interface IProps {
timetableData: any;
timetableData: {
id: string;
payload: {
program: string;
section: string;
semester: string;
};
updatedAt: string;
timetable: any;
};
metaData: string;
}

Expand All @@ -54,8 +63,22 @@ import Image from 'next/image';
export default function Timetable({ metaData, timetableData }: IProps) {
let printTableRef = useRef<any>();

const { setColorMode } = useColorMode();
const toast = useToast();
const [_, setLocalHistory] = useTimetableHistory();

useEffect(() => {
const payload = {
fall: timetableData.payload.program,
semester: timetableData.payload.semester,
section: timetableData.payload.section
};

setLocalHistory({
payload,
created_at: new Date().toISOString(),
hash: hashStr(JSON.stringify(payload))
});
}, [timetableData, setLocalHistory]);

return (
<>
Expand Down Expand Up @@ -277,6 +300,7 @@ import TimetableChart from './charts/TimetableChart';
import PalestineSideAd from './announcements/PalestineSideAd';
import { useRouter } from 'next/router';
import { hashStr } from '~/lib/cipher';
import useTimetableHistory from '~/hooks/useTimetableHistory';

const Card = ({ day, data, idx }: { idx: number; day: string; data: Array<any> }) => {
const { isOpen, onToggle } = useDisclosure({
Expand Down

0 comments on commit 121c52d

Please sign in to comment.