diff --git a/.env.example b/.env.example index 4e861f9..29326b9 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,3 @@ NEXT_PUBLIC_API_BASE_URL= NEXT_PUBLIC_APP_BASE_URL= -NEXT_PUBLIC_SSO_BASE_URL= \ No newline at end of file +NEXT_PUBLIC_SSO_BASE_URL= diff --git a/src/components/Button.tsx b/src/components/Button.tsx new file mode 100644 index 0000000..6e1c383 --- /dev/null +++ b/src/components/Button.tsx @@ -0,0 +1,27 @@ +import React, { ReactNode, MouseEvent } from 'react'; + +interface ButtonProps { + content: ReactNode; + additionalStyle?: string; + onClick?: (event: MouseEvent) => void; + disabled?: boolean; +} + +const Button: React.FC = ({ + content, + additionalStyle, + onClick, + disabled, +}: ButtonProps) => { + return ( + + ); +}; + +export default Button; diff --git a/src/components/Modal.tsx b/src/components/Modal.tsx index 56c7c44..17240c3 100644 --- a/src/components/Modal.tsx +++ b/src/components/Modal.tsx @@ -1,5 +1,6 @@ import { Dialog, Transition } from '@headlessui/react'; import { Fragment, ReactNode } from 'react'; +import Button from './Button'; import { ibmPlexSansThai } from './font'; export interface ModalProps { @@ -58,25 +59,19 @@ export const Modal = ({ {children}
- - + disabled={false} + />
diff --git a/src/components/Profile/BaanSelection/components/BaanPanel.tsx b/src/components/Profile/BaanSelection/components/BaanPanel.tsx index 50f5747..a4b4204 100644 --- a/src/components/Profile/BaanSelection/components/BaanPanel.tsx +++ b/src/components/Profile/BaanSelection/components/BaanPanel.tsx @@ -4,6 +4,7 @@ import { useRouter } from 'next/router'; import { useAuth } from '@/context/AuthContext'; import { useMemo } from 'react'; import { BaanSize, IShortBaan } from '@/types/baan'; +import Button from '@/components/Button'; const profilePic = '/images/pfp-placeholder.svg'; @@ -81,15 +82,15 @@ export default function BaanPanel() {
)} - + /> ); diff --git a/src/components/Profile/BaanSelection/components/GroupPanel.tsx b/src/components/Profile/BaanSelection/components/GroupPanel.tsx index 270d79e..6899df1 100644 --- a/src/components/Profile/BaanSelection/components/GroupPanel.tsx +++ b/src/components/Profile/BaanSelection/components/GroupPanel.tsx @@ -6,6 +6,7 @@ import { httpDelete } from '@/utils/axios'; import { Modal } from '@/components/Modal'; import { useAppContext } from '@/context/ModalContext'; import { StarIcon, XMarkIcon } from '@heroicons/react/24/solid'; +import Button from '@/components/Button'; const profilePic = '/images/pfp-placeholder.svg'; @@ -139,13 +140,13 @@ export default function GroupPanel() {

- + />
); diff --git a/src/components/Profile/BaanSelection/components/ProfileInfoPanel.tsx b/src/components/Profile/BaanSelection/components/ProfileInfoPanel.tsx index 77995c6..ab08867 100644 --- a/src/components/Profile/BaanSelection/components/ProfileInfoPanel.tsx +++ b/src/components/Profile/BaanSelection/components/ProfileInfoPanel.tsx @@ -1,3 +1,4 @@ +import Button from '@/components/Button'; import { useAuth } from '@/context/AuthContext'; import { StarIcon, PencilSquareIcon } from '@heroicons/react/24/solid'; import Image from 'next/image'; @@ -25,16 +26,20 @@ export default function ProfileInfoPanel() {

{user?.firstname}
{user?.lastname}

- - + disabled={false} + /> ); diff --git a/src/context/AuthContext.tsx b/src/context/AuthContext.tsx index 9fcd644..d1cf85a 100644 --- a/src/context/AuthContext.tsx +++ b/src/context/AuthContext.tsx @@ -46,6 +46,7 @@ const AuthProvider = ({ children }: { children: ReactNode }) => { const token = localStorage.getItem('token'); if (token) { const userProfile = await getUserProfile(); + if (!userProfile) { localStorage.clear(); window.location.href = '/'; diff --git a/src/pages/baan-selection/index.tsx b/src/pages/baan-selection/index.tsx index 03ee9ee..8d759c5 100644 --- a/src/pages/baan-selection/index.tsx +++ b/src/pages/baan-selection/index.tsx @@ -11,6 +11,7 @@ import { transformBaanDTOtoIBaan } from '@/utils/baan'; import { useRouter } from 'next/router'; import { useAuth } from '@/context/AuthContext'; import { useToast } from '@/components/Toast'; +import Button from '@/components/Button'; function useAllBaans() { const [allBaans, setAllBaans] = useState([]); @@ -164,8 +165,10 @@ const BaanChoosing = () => { )} - + />