Improved the data refresh
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable @next/next/no-img-element */
|
||||
import Layout from "@/components/High/Layout";
|
||||
import Checkbox from "@/components/Low/Checkbox";
|
||||
import Tooltip from "@/components/Low/Tooltip";
|
||||
import {useListSearch} from "@/hooks/useListSearch";
|
||||
import usePagination from "@/hooks/usePagination";
|
||||
@@ -11,7 +10,7 @@ import {convertToUsers, getGroup} from "@/utils/groups.be";
|
||||
import {shouldRedirectHome} from "@/utils/navigation.disabled";
|
||||
import {checkAccess, getTypesOfUser} from "@/utils/permissions";
|
||||
import {getUserName} from "@/utils/users";
|
||||
import {getLinkedUsers, getSpecificUsers, getUsers} from "@/utils/users.be";
|
||||
import {getLinkedUsers, getSpecificUsers} from "@/utils/users.be";
|
||||
import axios from "axios";
|
||||
import clsx from "clsx";
|
||||
import {withIronSessionSsr} from "iron-session/next";
|
||||
@@ -21,23 +20,10 @@ import Link from "next/link";
|
||||
import {useRouter} from "next/router";
|
||||
import {Divider} from "primereact/divider";
|
||||
import {useEffect, useMemo, useState} from "react";
|
||||
import {
|
||||
BsArrowLeft,
|
||||
BsChevronLeft,
|
||||
BsClockFill,
|
||||
BsEnvelopeFill,
|
||||
BsFillPersonVcardFill,
|
||||
BsPencil,
|
||||
BsPerson,
|
||||
BsPlus,
|
||||
BsStopwatchFill,
|
||||
BsTag,
|
||||
BsTrash,
|
||||
BsX,
|
||||
} from "react-icons/bs";
|
||||
import {BsChevronLeft, BsClockFill, BsEnvelopeFill, BsFillPersonVcardFill, BsPlus, BsStopwatchFill, BsTag, BsTrash, BsX} from "react-icons/bs";
|
||||
import {toast, ToastContainer} from "react-toastify";
|
||||
|
||||
export const getServerSideProps = withIronSessionSsr(async ({req, res, params}) => {
|
||||
export const getServerSideProps = withIronSessionSsr(async ({req, params}) => {
|
||||
const user = req.session.user as User;
|
||||
|
||||
if (!user) {
|
||||
@@ -119,7 +105,7 @@ export default function Home({user, group, users}: Props) {
|
||||
.patch(`/api/groups/${group.id}`, {participants: group.participants.map((x) => x.id).filter((x) => !selectedUsers.includes(x))})
|
||||
.then(() => {
|
||||
toast.success("The group has been updated successfully!");
|
||||
setTimeout(() => router.reload(), 500);
|
||||
router.replace(router.asPath);
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
@@ -141,7 +127,7 @@ export default function Home({user, group, users}: Props) {
|
||||
.patch(`/api/groups/${group.id}`, {participants: [...group.participants.map((x) => x.id), ...selectedUsers]})
|
||||
.then(() => {
|
||||
toast.success("The group has been updated successfully!");
|
||||
setTimeout(() => router.reload(), 500);
|
||||
router.replace(router.asPath);
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
@@ -161,7 +147,7 @@ export default function Home({user, group, users}: Props) {
|
||||
.patch(`/api/groups/${group.id}`, {name})
|
||||
.then(() => {
|
||||
toast.success("The group has been updated successfully!");
|
||||
setTimeout(() => router.reload(), 500);
|
||||
router.replace(router.asPath);
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
@@ -180,7 +166,7 @@ export default function Home({user, group, users}: Props) {
|
||||
.delete(`/api/groups/${group.id}`)
|
||||
.then(() => {
|
||||
toast.success("This group has been successfully deleted!");
|
||||
setTimeout(() => router.push("/groups"), 1000);
|
||||
router.replace("/groups");
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
/* eslint-disable @next/next/no-img-element */
|
||||
import Layout from "@/components/High/Layout";
|
||||
import Button from "@/components/Low/Button";
|
||||
import Checkbox from "@/components/Low/Checkbox";
|
||||
import Input from "@/components/Low/Input";
|
||||
import Tooltip from "@/components/Low/Tooltip";
|
||||
import {useListSearch} from "@/hooks/useListSearch";
|
||||
import usePagination from "@/hooks/usePagination";
|
||||
import {GroupWithUsers, User} from "@/interfaces/user";
|
||||
import {User} from "@/interfaces/user";
|
||||
import {sessionOptions} from "@/lib/session";
|
||||
import {USER_TYPE_LABELS} from "@/resources/user";
|
||||
import {convertToUsers, getGroup} from "@/utils/groups.be";
|
||||
import {shouldRedirectHome} from "@/utils/navigation.disabled";
|
||||
import {checkAccess, getTypesOfUser} from "@/utils/permissions";
|
||||
import {getUserName} from "@/utils/users";
|
||||
import {getLinkedUsers, getSpecificUsers, getUsers} from "@/utils/users.be";
|
||||
import {getLinkedUsers} from "@/utils/users.be";
|
||||
import axios from "axios";
|
||||
import clsx from "clsx";
|
||||
import {withIronSessionSsr} from "iron-session/next";
|
||||
@@ -22,25 +18,11 @@ import Head from "next/head";
|
||||
import Link from "next/link";
|
||||
import {useRouter} from "next/router";
|
||||
import {Divider} from "primereact/divider";
|
||||
import {useEffect, useMemo, useState} from "react";
|
||||
import {
|
||||
BsArrowLeft,
|
||||
BsCheck,
|
||||
BsChevronLeft,
|
||||
BsClockFill,
|
||||
BsEnvelopeFill,
|
||||
BsFillPersonVcardFill,
|
||||
BsPencil,
|
||||
BsPerson,
|
||||
BsPlus,
|
||||
BsStopwatchFill,
|
||||
BsTag,
|
||||
BsTrash,
|
||||
BsX,
|
||||
} from "react-icons/bs";
|
||||
import {useState} from "react";
|
||||
import {BsCheck, BsChevronLeft, BsClockFill, BsEnvelopeFill, BsStopwatchFill} from "react-icons/bs";
|
||||
import {toast, ToastContainer} from "react-toastify";
|
||||
|
||||
export const getServerSideProps = withIronSessionSsr(async ({req, res, params}) => {
|
||||
export const getServerSideProps = withIronSessionSsr(async ({req}) => {
|
||||
const user = req.session.user as User;
|
||||
|
||||
if (!user) {
|
||||
@@ -93,7 +75,7 @@ export default function Home({user, users}: Props) {
|
||||
.post<{id: string}>(`/api/groups`, {name, participants: selectedUsers, admin: user.id})
|
||||
.then((result) => {
|
||||
toast.success("Your group has been created successfully!");
|
||||
setTimeout(() => router.push(`/groups/${result.data.id}`), 250);
|
||||
router.replace(`/groups/${result.data.id}`);
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
|
||||
@@ -4,21 +4,20 @@ import {withIronSessionSsr} from "iron-session/next";
|
||||
import {sessionOptions} from "@/lib/session";
|
||||
import {ToastContainer} from "react-toastify";
|
||||
import Layout from "@/components/High/Layout";
|
||||
import {Group, GroupWithUsers, User, WithUser} from "@/interfaces/user";
|
||||
import {GroupWithUsers, User} from "@/interfaces/user";
|
||||
import {shouldRedirectHome} from "@/utils/navigation.disabled";
|
||||
import {getUserName} from "@/utils/users";
|
||||
import {convertToUsers, getGroupsForUser, getParticipantGroups, getUserGroups} from "@/utils/groups.be";
|
||||
import {getSpecificUsers, getUsers} from "@/utils/users.be";
|
||||
import {convertToUsers, getGroupsForUser} from "@/utils/groups.be";
|
||||
import {getSpecificUsers} from "@/utils/users.be";
|
||||
import {checkAccess} from "@/utils/permissions";
|
||||
import usePagination from "@/hooks/usePagination";
|
||||
import {useListSearch} from "@/hooks/useListSearch";
|
||||
import Link from "next/link";
|
||||
import {uniq} from "lodash";
|
||||
import {BsPlus} from "react-icons/bs";
|
||||
import {Divider} from "primereact/divider";
|
||||
import Separator from "@/components/Low/Separator";
|
||||
|
||||
export const getServerSideProps = withIronSessionSsr(async ({req, res}) => {
|
||||
export const getServerSideProps = withIronSessionSsr(async ({req}) => {
|
||||
const user = req.session.user;
|
||||
|
||||
if (!user) {
|
||||
|
||||
Reference in New Issue
Block a user