Recently visited section

This commit is contained in:
Ben Grant 2021-04-15 15:29:30 +10:00
parent d4c89c4517
commit b5bf833dcf
4 changed files with 70 additions and 3 deletions

View file

@ -34,7 +34,7 @@ import {
} from './eventStyle';
import api from 'services';
import { useSettingsStore } from 'stores';
import { useSettingsStore, useRecentsStore } from 'stores';
import logo from 'res/logo.svg';
import timezones from 'res/timezones.json';
@ -47,6 +47,8 @@ const Event = (props) => {
const timeFormat = useSettingsStore(state => state.timeFormat);
const weekStart = useSettingsStore(state => state.weekStart);
const addRecent = useRecentsStore(state => state.addRecent);
const { register, handleSubmit } = useForm();
const { id } = props.match.params;
const { offline } = props;
@ -74,6 +76,11 @@ const Event = (props) => {
const response = await api.get(`/event/${id}`);
setEvent(response.data);
addRecent({
id: response.data.id,
created: response.data.created,
name: response.data.name,
});
document.title = `${response.data.name} | Crab Fit`;
} catch (e) {
console.error(e);
@ -83,7 +90,7 @@ const Event = (props) => {
};
fetchEvent();
}, [id]);
}, [id, addRecent]);
useEffect(() => {
const fetchPeople = async () => {