From 9c86182e967af4156203b0dbd7b95ca06b7d92fc Mon Sep 17 00:00:00 2001 From: Muhammad Abdurrehman Date: Tue, 6 Aug 2024 15:55:42 +0500 Subject: [PATCH] invite system removed --- src/api/invitationLimits.ts | 16 ---- src/api/invitations.ts | 45 --------- .../InvitationStatusBadge/index.tsx | 18 ---- src/constants/store.ts | 2 - src/dispatchers/invitationLimits.ts | 8 -- src/dispatchers/invitations.ts | 28 ------ src/enums/index.ts | 2 - src/enums/invitations.ts | 4 - .../forms/CreateAccountForm.tsx | 4 - src/modals/InvitationModal/Styles.ts | 9 -- src/modals/InvitationModal/index.tsx | 78 ---------------- .../Profile/Invitations/Invitation/Styles.ts | 10 -- .../Profile/Invitations/Invitation/index.tsx | 93 ------------------- src/pages/Profile/Invitations/Styles.ts | 91 ------------------ src/pages/Profile/Invitations/index.tsx | 89 ------------------ src/pages/Profile/Layout/index.tsx | 15 +-- src/pages/Profile/index.tsx | 9 -- src/selectors/state.ts | 2 - src/store/index.ts | 4 - src/store/invitationLimits.ts | 20 ---- src/store/invitations.ts | 26 ------ src/types/api/invitations.ts | 3 - src/types/api/users.ts | 1 - src/types/index.ts | 8 -- src/types/invitationLimits.ts | 9 -- src/types/invitations.ts | 13 --- 26 files changed, 2 insertions(+), 605 deletions(-) delete mode 100644 src/api/invitationLimits.ts delete mode 100644 src/api/invitations.ts delete mode 100644 src/components/InvitationStatusBadge/index.tsx delete mode 100644 src/dispatchers/invitationLimits.ts delete mode 100644 src/dispatchers/invitations.ts delete mode 100644 src/enums/invitations.ts delete mode 100644 src/modals/InvitationModal/Styles.ts delete mode 100644 src/modals/InvitationModal/index.tsx delete mode 100644 src/pages/Profile/Invitations/Invitation/Styles.ts delete mode 100644 src/pages/Profile/Invitations/Invitation/index.tsx delete mode 100644 src/pages/Profile/Invitations/Styles.ts delete mode 100644 src/pages/Profile/Invitations/index.tsx delete mode 100644 src/store/invitationLimits.ts delete mode 100644 src/store/invitations.ts delete mode 100644 src/types/api/invitations.ts delete mode 100644 src/types/invitationLimits.ts delete mode 100644 src/types/invitations.ts diff --git a/src/api/invitationLimits.ts b/src/api/invitationLimits.ts deleted file mode 100644 index 7299a5bc..00000000 --- a/src/api/invitationLimits.ts +++ /dev/null @@ -1,16 +0,0 @@ -import axios from 'axios'; - -import {InvitationLimit} from 'types'; -import {authorizationHeaders} from 'utils/authentication'; - -const BASE_URL = `${process.env.REACT_APP_API_URL}/api/invitation_limits`; - -export const getInvitationLimit = async (id: number): Promise => { - try { - const response = await axios.get(`${BASE_URL}/${id}`, authorizationHeaders()); - return response.data; - } catch (error) { - console.error(error); - throw error; - } -}; diff --git a/src/api/invitations.ts b/src/api/invitations.ts deleted file mode 100644 index 617aa9c5..00000000 --- a/src/api/invitations.ts +++ /dev/null @@ -1,45 +0,0 @@ -import axios from 'axios'; - -import {CreateInvitationRequest, Invitation} from 'types'; -import {authorizationHeaders} from 'utils/authentication'; - -const BASE_URL = `${process.env.REACT_APP_API_URL}/api/invitations`; - -export const createInvitation = async (data: CreateInvitationRequest): Promise => { - try { - const response = await axios.post(BASE_URL, data, authorizationHeaders()); - return response.data; - } catch (error) { - console.error(error); - throw error; - } -}; - -export const deleteInvitation = async (id: number): Promise => { - try { - await axios.delete(`${BASE_URL}/${id}`, authorizationHeaders()); - } catch (error) { - console.error(error); - throw error; - } -}; - -export const getInvitations = async (): Promise => { - try { - const response = await axios.get(BASE_URL, authorizationHeaders()); - return response.data; - } catch (error) { - console.error(error); - throw error; - } -}; - -export const updateInvitation = async (id: number, data: CreateInvitationRequest): Promise => { - try { - const response = await axios.patch(`${BASE_URL}/${id}`, data, authorizationHeaders()); - return response.data; - } catch (error) { - console.error(error); - throw error; - } -}; diff --git a/src/components/InvitationStatusBadge/index.tsx b/src/components/InvitationStatusBadge/index.tsx deleted file mode 100644 index 9ae14f3c..00000000 --- a/src/components/InvitationStatusBadge/index.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import Badge, {BadgeStyle} from 'components/Badge'; -import {InvitationStatus} from 'enums'; -import {SFC} from 'types'; - -export interface InvitationStatusBadgeProps { - invitationStatus: InvitationStatus; -} - -const InvitationStatusBadge: SFC = ({invitationStatus}) => { - const badgeStyle = { - [InvitationStatus.ACCEPTED]: BadgeStyle.success, - [InvitationStatus.PENDING]: BadgeStyle.draft, - }; - - return ; -}; - -export default InvitationStatusBadge; diff --git a/src/constants/store.ts b/src/constants/store.ts index b5b14485..09aff1b2 100644 --- a/src/constants/store.ts +++ b/src/constants/store.ts @@ -15,8 +15,6 @@ export const EXCHANGE_ORDERS = 'exchangeOrders'; export const FOLLOWERS = 'followers'; export const FOLLOWINGS = 'followings'; export const IA = 'ia'; -export const INVITATIONS = 'invitations'; -export const INVITATION_LIMITS = 'invitationLimits'; export const LECTURES = 'lectures'; export const MANAGER = 'manager'; export const MESSAGES = 'messages'; diff --git a/src/dispatchers/invitationLimits.ts b/src/dispatchers/invitationLimits.ts deleted file mode 100644 index 51b2ec19..00000000 --- a/src/dispatchers/invitationLimits.ts +++ /dev/null @@ -1,8 +0,0 @@ -import {getInvitationLimit as _getInvitationLimit} from 'api/invitationLimits'; -import {setInvitationLimit} from 'store/invitationLimits'; -import {AppDispatch} from 'types'; - -export const getInvitationLimit = (id: number) => async (dispatch: AppDispatch) => { - const responseData = await _getInvitationLimit(id); - dispatch(setInvitationLimit(responseData)); -}; diff --git a/src/dispatchers/invitations.ts b/src/dispatchers/invitations.ts deleted file mode 100644 index fba2d684..00000000 --- a/src/dispatchers/invitations.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { - createInvitation as _createInvitation, - deleteInvitation as _deleteInvitation, - getInvitations as _getInvitations, - updateInvitation as _updateInvitation, -} from 'api/invitations'; -import {setInvitation, setInvitations, unsetInvitation} from 'store/invitations'; -import {AppDispatch, CreateInvitationRequest} from 'types'; - -export const createInvitation = (data: CreateInvitationRequest) => async (dispatch: AppDispatch) => { - const responseData = await _createInvitation(data); - dispatch(setInvitation(responseData)); -}; - -export const deleteInvitation = (id: number) => async (dispatch: AppDispatch) => { - await _deleteInvitation(id); - dispatch(unsetInvitation(id)); -}; - -export const getInvitations = () => async (dispatch: AppDispatch) => { - const responseData = await _getInvitations(); - dispatch(setInvitations(responseData)); -}; - -export const updateInvitation = (id: number, data: CreateInvitationRequest) => async (dispatch: AppDispatch) => { - const responseData = await _updateInvitation(id, data); - dispatch(setInvitation(responseData)); -}; diff --git a/src/enums/index.ts b/src/enums/index.ts index 89001bb0..483b49a2 100644 --- a/src/enums/index.ts +++ b/src/enums/index.ts @@ -1,7 +1,6 @@ import {ActivationStatus} from 'enums/products'; import {ExchangeOrderType, FillStatus} from 'enums/exchangeOrders'; import {FollowerType} from 'enums/follower'; -import {InvitationStatus} from 'enums/invitations'; import {PublicationStatus} from 'enums/publicationStatus'; import {SenderType} from 'enums/messages'; import {ShopToolbarType} from 'enums/shopToolbar'; @@ -17,7 +16,6 @@ export { ExchangeOrderType, FillStatus, FollowerType, - InvitationStatus, PublicationStatus, SenderType, ShopToolbarType, diff --git a/src/enums/invitations.ts b/src/enums/invitations.ts deleted file mode 100644 index 0924dc70..00000000 --- a/src/enums/invitations.ts +++ /dev/null @@ -1,4 +0,0 @@ -export enum InvitationStatus { - ACCEPTED = 'ACCEPTED', - PENDING = 'PENDING', -} diff --git a/src/layouts/Unauthenticated/forms/CreateAccountForm.tsx b/src/layouts/Unauthenticated/forms/CreateAccountForm.tsx index 3a8fe52b..d5670499 100644 --- a/src/layouts/Unauthenticated/forms/CreateAccountForm.tsx +++ b/src/layouts/Unauthenticated/forms/CreateAccountForm.tsx @@ -18,7 +18,6 @@ const CreateAccountForm: SFC = () => { const initialValues = { confirmPassword: '', - invitationCode: '', password: '', username: '', }; @@ -28,7 +27,6 @@ const CreateAccountForm: SFC = () => { const handleSubmit = async (values: FormValues): Promise => { try { const requestData = { - invitation_code: values.invitationCode, password: values.password, username: values.username, }; @@ -46,7 +44,6 @@ const CreateAccountForm: SFC = () => { .string() .oneOf([yup.ref('password'), undefined], 'Passwords must match') .required('Confirm Password is required'), - invitationCode: yup.string().required('Invitation code is required'), password: yup.string().required(), username: yup .string() @@ -71,7 +68,6 @@ const CreateAccountForm: SFC = () => { touched={touched} type="password" /> - = ({className, close, invitation}) => { - const dispatch = useDispatch(); - - const initialValues = useMemo( - () => ({ - note: invitation?.note || '', - }), - [invitation?.note], - ); - - type FormValues = typeof initialValues; - - const handleSubmit = async (values: FormValues): Promise => { - try { - if (invitation) { - await dispatch(updateInvitation(invitation.id, values)); - displayToast('Invitation updated!', ToastType.SUCCESS); - } else { - await dispatch(createInvitation(values)); - displayToast('Invitation created!', ToastType.SUCCESS); - } - - close(); - } catch (error) { - console.error(error); - const verb = invitation ? 'updating' : 'creating'; - displayErrorToast(`Error ${verb} invitation`); - } - }; - - const validationSchema = useMemo(() => { - return yup.object().shape({ - note: yup.string(), - }); - }, []); - - const verb = invitation ? 'Update' : 'Create'; - - return ( - - - {({dirty, errors, isSubmitting, isValid, touched}) => ( -
- -