From 06f5269c8c1344bef0bba0b3be2374541d5a03ea Mon Sep 17 00:00:00 2001 From: Truong An Date: Tue, 14 Jul 2020 18:21:22 +0700 Subject: [PATCH] =?UTF-8?q?feat:=20update=20=E2=80=98developer=20managemen?= =?UTF-8?q?t=E2=80=99=20on=20admin=20portal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/admin-portal/package.json | 2 +- .../src/actions/developer-set-status.ts | 10 +- .../__snapshots__/admin-apps.test.tsx.snap | 6 +- .../admin-dev-management.test.tsx.snap | 1315 +++++++++++++++-- .../admin-dev-management.tsx | 85 +- .../__snapshots__/status-modal.test.tsx.snap | 852 +++++++++++ .../__tests__/status-modal.test.tsx | 76 + .../set-status-modal/form-schema.ts | 33 + .../set-status-modal/status-modal.tsx | 119 ++ .../src/sagas/__stubs__/app-usage-stats.ts | 63 - .../src/sagas/developer-set-status.ts | 3 + .../admin-portal/src/services/statistics.ts | 26 - .../src/tests/badges/badge-branches.svg | 2 +- .../src/tests/badges/badge-functions.svg | 2 +- .../src/tests/badges/badge-lines.svg | 2 +- .../src/tests/badges/badge-statements.svg | 2 +- .../src/tests/badges/badge-branches.svg | 2 +- .../src/tests/badges/badge-functions.svg | 2 +- .../src/tests/badges/badge-lines.svg | 2 +- .../src/tests/badges/badge-statements.svg | 2 +- .../src/tests/badges/badge-branches.svg | 2 +- .../src/tests/badges/badge-functions.svg | 2 +- .../src/tests/badges/badge-lines.svg | 2 +- .../src/tests/badges/badge-statements.svg | 2 +- .../__snapshots__/admin-apps.test.tsx.snap | 6 +- .../admin-dev-management.test.tsx.snap | 4 +- .../general-information-section.test.tsx.snap | 20 +- .../__snapshots__/register.test.tsx.snap | 8 +- .../src/tests/badges/badge-branches.svg | 2 +- .../src/tests/badges/badge-functions.svg | 2 +- .../src/tests/badges/badge-lines.svg | 2 +- .../src/tests/badges/badge-statements.svg | 2 +- .../elements/src/components/Input/index.tsx | 8 +- .../RadioSelect/__tests__/index.tsx | 13 +- .../src/components/RadioSelect/index.tsx | 14 +- .../src/tests/badges/badge-branches.svg | 2 +- .../src/tests/badges/badge-functions.svg | 2 +- .../elements/src/tests/badges/badge-lines.svg | 2 +- .../src/tests/badges/badge-statements.svg | 2 +- .../src/components/modal/__styles__/index.ts | 9 +- .../src/v2/src/components/modal/index.tsx | 12 +- .../src/tests/badges/badge-branches.svg | 2 +- .../src/tests/badges/badge-functions.svg | 2 +- .../src/tests/badges/badge-lines.svg | 2 +- .../src/tests/badges/badge-statements.svg | 2 +- .../src/tests/badges/badge-branches.svg | 2 +- .../src/tests/badges/badge-functions.svg | 2 +- .../src/tests/badges/badge-lines.svg | 2 +- .../src/tests/badges/badge-statements.svg | 2 +- .../src/tests/badges/badge-branches.svg | 2 +- .../src/tests/badges/badge-functions.svg | 2 +- .../src/tests/badges/badge-lines.svg | 2 +- .../src/tests/badges/badge-statements.svg | 2 +- .../src/tests/badges/badge-branches.svg | 2 +- .../src/tests/badges/badge-functions.svg | 2 +- .../src/tests/badges/badge-lines.svg | 2 +- .../src/tests/badges/badge-statements.svg | 2 +- .../src/tests/badges/badge-branches.svg | 2 +- .../src/tests/badges/badge-functions.svg | 2 +- .../src/tests/badges/badge-lines.svg | 2 +- .../src/tests/badges/badge-statements.svg | 2 +- .../src/tests/badges/badge-branches.svg | 2 +- .../src/tests/badges/badge-functions.svg | 2 +- .../src/tests/badges/badge-lines.svg | 2 +- .../src/tests/badges/badge-statements.svg | 2 +- packages/utils/src/form/regexs.ts | 1 + 66 files changed, 2480 insertions(+), 293 deletions(-) create mode 100644 packages/admin-portal/src/components/pages/admin-dev-management/set-status-modal/__tests__/__snapshots__/status-modal.test.tsx.snap create mode 100644 packages/admin-portal/src/components/pages/admin-dev-management/set-status-modal/__tests__/status-modal.test.tsx create mode 100644 packages/admin-portal/src/components/pages/admin-dev-management/set-status-modal/form-schema.ts create mode 100644 packages/admin-portal/src/components/pages/admin-dev-management/set-status-modal/status-modal.tsx delete mode 100644 packages/admin-portal/src/sagas/__stubs__/app-usage-stats.ts delete mode 100644 packages/admin-portal/src/services/statistics.ts diff --git a/packages/admin-portal/package.json b/packages/admin-portal/package.json index 9e738d3eb0..b206a3ddf5 100644 --- a/packages/admin-portal/package.json +++ b/packages/admin-portal/package.json @@ -40,7 +40,7 @@ "snyk": "^1.341.1" }, "devDependencies": { - "@reapit/foundations-ts-definitions": "0.0.85", + "@reapit/foundations-ts-definitions": "0.0.86", "@types/nanoid": "^2.1.0", "redux-mock-store": "^1.5.4" }, diff --git a/packages/admin-portal/src/actions/developer-set-status.ts b/packages/admin-portal/src/actions/developer-set-status.ts index a380ecc350..64f143672d 100644 --- a/packages/admin-portal/src/actions/developer-set-status.ts +++ b/packages/admin-portal/src/actions/developer-set-status.ts @@ -1,8 +1,14 @@ import { actionCreator } from '../utils/actions' import ActionTypes from '../constants/action-types' -import { DeveloperModel } from '@reapit/foundations-ts-definitions' +import { UpdateDeveloperModel } from '@reapit/foundations-ts-definitions' -export const developerSetStatusRequest = actionCreator(ActionTypes.DEVELOPER_SET_STATUS_REQUEST) +export type UpdateDeveloperModelRequest = { + callback?: (success: boolean) => void +} & UpdateDeveloperModel + +export const developerSetStatusRequest = actionCreator( + ActionTypes.DEVELOPER_SET_STATUS_REQUEST, +) export const developerSetStatusRequestLoading = actionCreator(ActionTypes.DEVELOPER_SET_STATUS_REQUEST_LOADING) export const developerSetStatusRequestFailure = actionCreator(ActionTypes.DEVELOPER_SET_STATUS_REQUEST_FAILURE) export const developerSetStatusRequestSuccess = actionCreator(ActionTypes.DEVELOPER_SET_STATUS_REQUEST_SUCCESS) diff --git a/packages/admin-portal/src/components/pages/admin-apps/__tests__/__snapshots__/admin-apps.test.tsx.snap b/packages/admin-portal/src/components/pages/admin-apps/__tests__/__snapshots__/admin-apps.test.tsx.snap index cff19fb198..c726b53511 100644 --- a/packages/admin-portal/src/components/pages/admin-apps/__tests__/__snapshots__/admin-apps.test.tsx.snap +++ b/packages/admin-portal/src/components/pages/admin-apps/__tests__/__snapshots__/admin-apps.test.tsx.snap @@ -226,7 +226,7 @@ exports[`admin-apps AdminApprovals should match a snapshot 1`] = ` validate={null} >
Created + + Status + - - + /> @@ -831,90 +838,1210 @@ exports[`AdminDevManagement should render blank Info when data is empty 1`] = ` } > - -
-
-
-
-
-
- - - - - -`; - -exports[`AdminDevManagement should show loader when LOADING true 1`] = ` - - - - - -
+ -
-
-
-
-
- + +
+ +

+ Developer Management +

+
+
+
+ + +
+ + +
+ +
+ Developer Management Filter Form +
+
+ +
+ Filter the result by Name and Company +
+
+ +
+ +
+ + +
+
+ + +
+
+
+
+
+
+ +
+ + +
+
+ + +
+
+
+
+
+
+ +
+ + +
+
+ + + } + customTimeInput={null} + dateFormat="MM/dd/yyyy" + dateFormatCalendar="LLLL yyyy" + disabled={false} + disabledKeyboardNavigation={false} + dropdownMode="scroll" + enableTabLoop={true} + excludeScrollbar={true} + id="registeredFrom" + inlineFocusSelectedMonth={false} + maxDate={2019-10-10T22:39:51.389Z} + monthsShown={1} + name="registeredFrom" + nextMonthButtonLabel="Next Month" + nextYearButtonLabel="Next Year" + onBlur={[Function]} + onCalendarClose={[Function]} + onCalendarOpen={[Function]} + onChange={[Function]} + onClickOutside={[Function]} + onFocus={[Function]} + onInputClick={[Function]} + onInputError={[Function]} + onKeyDown={[Function]} + onMonthChange={[Function]} + onSelect={[Function]} + onYearChange={[Function]} + preventOpenOnFocus={false} + previousMonthButtonLabel="Previous Month" + previousYearButtonLabel="Previous Year" + readOnly={false} + renderDayContents={[Function]} + shouldCloseOnSelect={true} + showFullMonthYearPicker={false} + showMonthYearPicker={false} + showPopperArrow={true} + showPreviousMonths={false} + showQuarterYearPicker={false} + showTimeInput={false} + showTimeSelect={false} + showYearPicker={false} + strictParsing={false} + timeCaption="Time" + timeInputLabel="Time" + timeIntervals={30} + value="" + withPortal={false} + > + + +
+ } + > + + + +
+
+ + + +
+
+
+
+
+
+ +
+
+ +
+
+
+ +
+ + +
+
+ + + } + customTimeInput={null} + dateFormat="MM/dd/yyyy" + dateFormatCalendar="LLLL yyyy" + disabled={false} + disabledKeyboardNavigation={false} + dropdownMode="scroll" + enableTabLoop={true} + excludeScrollbar={true} + id="registeredTo" + inlineFocusSelectedMonth={false} + maxDate={2019-10-10T22:39:51.389Z} + minDate={Date { NaN }} + monthsShown={1} + name="registeredTo" + nextMonthButtonLabel="Next Month" + nextYearButtonLabel="Next Year" + onBlur={[Function]} + onCalendarClose={[Function]} + onCalendarOpen={[Function]} + onChange={[Function]} + onClickOutside={[Function]} + onFocus={[Function]} + onInputClick={[Function]} + onInputError={[Function]} + onKeyDown={[Function]} + onMonthChange={[Function]} + onSelect={[Function]} + onYearChange={[Function]} + preventOpenOnFocus={false} + previousMonthButtonLabel="Previous Month" + previousYearButtonLabel="Previous Year" + readOnly={false} + renderDayContents={[Function]} + shouldCloseOnSelect={true} + showFullMonthYearPicker={false} + showMonthYearPicker={false} + showPopperArrow={true} + showPreviousMonths={false} + showQuarterYearPicker={false} + showTimeInput={false} + showTimeSelect={false} + showYearPicker={false} + strictParsing={false} + timeCaption="Time" + timeInputLabel="Time" + timeIntervals={30} + value="" + withPortal={false} + > + + +
+ } + > + + + +
+
+ + + +
+
+
+
+
+
+ +
+
+ +
+
+
+ +
+ + + +
+
+
+ +
+ + + + + + +
+
+
+
+
+
+ + + + + + + +`; + +exports[`AdminDevManagement should show loader when LOADING true 1`] = ` + + + + + + + +
+ +

+ Developer Management +

+
+
+
+ + +
+ + +
+ +
+ Developer Management Filter Form +
+
+ +
+ Filter the result by Name and Company +
+
+ +
+ +
+ + +
+
+ + +
+
+
+
+
+
+ +
+ + +
+
+ + +
+
+
+
+
+
+ +
+ + +
+
+ + + } + customTimeInput={null} + dateFormat="MM/dd/yyyy" + dateFormatCalendar="LLLL yyyy" + disabled={false} + disabledKeyboardNavigation={false} + dropdownMode="scroll" + enableTabLoop={true} + excludeScrollbar={true} + id="registeredFrom" + inlineFocusSelectedMonth={false} + maxDate={2019-10-10T22:39:51.389Z} + monthsShown={1} + name="registeredFrom" + nextMonthButtonLabel="Next Month" + nextYearButtonLabel="Next Year" + onBlur={[Function]} + onCalendarClose={[Function]} + onCalendarOpen={[Function]} + onChange={[Function]} + onClickOutside={[Function]} + onFocus={[Function]} + onInputClick={[Function]} + onInputError={[Function]} + onKeyDown={[Function]} + onMonthChange={[Function]} + onSelect={[Function]} + onYearChange={[Function]} + preventOpenOnFocus={false} + previousMonthButtonLabel="Previous Month" + previousYearButtonLabel="Previous Year" + readOnly={false} + renderDayContents={[Function]} + shouldCloseOnSelect={true} + showFullMonthYearPicker={false} + showMonthYearPicker={false} + showPopperArrow={true} + showPreviousMonths={false} + showQuarterYearPicker={false} + showTimeInput={false} + showTimeSelect={false} + showYearPicker={false} + strictParsing={false} + timeCaption="Time" + timeInputLabel="Time" + timeIntervals={30} + value="" + withPortal={false} + > + + +
+ } + > + + + +
+
+ + + +
+
+
+
+
+
+ +
+
+ +
+
+
+ +
+ + +
+
+ + + } + customTimeInput={null} + dateFormat="MM/dd/yyyy" + dateFormatCalendar="LLLL yyyy" + disabled={false} + disabledKeyboardNavigation={false} + dropdownMode="scroll" + enableTabLoop={true} + excludeScrollbar={true} + id="registeredTo" + inlineFocusSelectedMonth={false} + maxDate={2019-10-10T22:39:51.389Z} + minDate={Date { NaN }} + monthsShown={1} + name="registeredTo" + nextMonthButtonLabel="Next Month" + nextYearButtonLabel="Next Year" + onBlur={[Function]} + onCalendarClose={[Function]} + onCalendarOpen={[Function]} + onChange={[Function]} + onClickOutside={[Function]} + onFocus={[Function]} + onInputClick={[Function]} + onInputError={[Function]} + onKeyDown={[Function]} + onMonthChange={[Function]} + onSelect={[Function]} + onYearChange={[Function]} + preventOpenOnFocus={false} + previousMonthButtonLabel="Previous Month" + previousYearButtonLabel="Previous Year" + readOnly={false} + renderDayContents={[Function]} + shouldCloseOnSelect={true} + showFullMonthYearPicker={false} + showMonthYearPicker={false} + showPopperArrow={true} + showPreviousMonths={false} + showQuarterYearPicker={false} + showTimeInput={false} + showTimeSelect={false} + showYearPicker={false} + strictParsing={false} + timeCaption="Time" + timeInputLabel="Time" + timeIntervals={30} + value="" + withPortal={false} + > + + +
+ } + > + + + +
+
+ + + +
+
+
+
+
+
+ +
+
+ +
+
+
+ +
+ + + +
+
+
+ +
+ + + + + + +
+
+
+
+
+
+ + + diff --git a/packages/admin-portal/src/components/pages/admin-dev-management/admin-dev-management.tsx b/packages/admin-portal/src/components/pages/admin-dev-management/admin-dev-management.tsx index 1156479b55..f8542ad389 100644 --- a/packages/admin-portal/src/components/pages/admin-dev-management/admin-dev-management.tsx +++ b/packages/admin-portal/src/components/pages/admin-dev-management/admin-dev-management.tsx @@ -22,13 +22,14 @@ import Routes from '@/constants/routes' import AdminDevManagementFilterForm, { AdminDevManagementFilterFormValues, } from '@/components/ui/admin-dev-management-filter-form' -import AdminSetDeveloperStatusModal from '@/components/ui/developer-set-status' +// import AdminSetDeveloperStatusModal from '@/components/ui/developer-set-status' import { DeveloperModel } from '@reapit/foundations-ts-definitions' import { adminDevManagementRequestData, AdminDevManagementRequestDataValues } from '@/actions/admin-dev-management' import qs from 'querystring' import { selectAdminDevManagement } from '@/selector/admin' import { Dispatch } from 'redux' import { cleanObject } from '@reapit/utils' +import StatusModal from './set-status-modal/status-modal' export interface AdminDevManagementMappedActions { fetchData: (requestdata: AdminDevManagementRequestDataValues) => void @@ -109,25 +110,43 @@ export const AdminDevManagement: React.FC = () => { const pageNo = pageNumber - 1 const pageNoTimesRevsions = pageNo * REVISIONS_PER_PAGE const HeaderCell = ({ row: { index } }) =>
{pageNoTimesRevsions + index + 1}
- const ButtonCell = ({ row: { original } }) => { - const { id, isInactive } = original as DeveloperModel + // Note: Comment because not use in the moment + + // const ButtonCell = ({ row: { original } }) => { + // const { id, isInactive } = original as DeveloperModel + + // return ( + // + // ) + // } + + const CreatedCell = ({ cell: { value } }) =>

{toLocalTime(value)}

+ const StatusBtnCell = ({ row: { original } }) => { return ( ) } - const CreatedCell = ({ cell: { value } }) =>

{toLocalTime(value)}

const columns = [ { @@ -145,17 +164,20 @@ export const AdminDevManagement: React.FC = () => { accessor: 'created', Cell: CreatedCell, }, + { + Header: 'Status', + accessor: 'status', + columnProps: { + className: 'capitalize', + }, + }, { Header: '', id: 'buttonColumn', - Cell: ButtonCell, + Cell: StatusBtnCell, }, ] - if (loading || !data) { - return - } - if (!loading && data?.data?.length === 0) { return ( @@ -177,24 +199,31 @@ export const AdminDevManagement: React.FC = () => {

Developer Management

-
- - -
-
Total: {data.totalCount}
-
- - + ) : ( + <> +
+
+ +
+
Total: {data.totalCount}
+
+ + {/* + /> */} + + + )} ) } diff --git a/packages/admin-portal/src/components/pages/admin-dev-management/set-status-modal/__tests__/__snapshots__/status-modal.test.tsx.snap b/packages/admin-portal/src/components/pages/admin-dev-management/set-status-modal/__tests__/__snapshots__/status-modal.test.tsx.snap new file mode 100644 index 0000000000..82b84a4c61 --- /dev/null +++ b/packages/admin-portal/src/components/pages/admin-dev-management/set-status-modal/__tests__/__snapshots__/status-modal.test.tsx.snap @@ -0,0 +1,852 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[` 1`] = ` +
+ +
+`; + +exports[`StatusModal should match snapshot 1`] = ` + + + + + CANCEL + , + + SAVE + , + ] + } + isCentered={true} + visible={true} + > + + CANCEL + , + + SAVE + , + ] + } + visible={true} + wrapClassName="" + > + + + +
+
+ + } + > + + CANCEL + , + + SAVE + , + ] + } + getContainer={[Function]} + getOpenCount={[Function]} + keyboard={true} + mask={true} + maskClosable={true} + prefixCls="rc-dialog" + switchScrollingEffect={[Function]} + visible={true} + wrapClassName="" + > +
+ +
+ +
+ + + +
+ +
+
+ + + + + + + + +`; diff --git a/packages/admin-portal/src/components/pages/admin-dev-management/set-status-modal/__tests__/status-modal.test.tsx b/packages/admin-portal/src/components/pages/admin-dev-management/set-status-modal/__tests__/status-modal.test.tsx new file mode 100644 index 0000000000..7849c7673f --- /dev/null +++ b/packages/admin-portal/src/components/pages/admin-dev-management/set-status-modal/__tests__/status-modal.test.tsx @@ -0,0 +1,76 @@ +import { onSubmitStatus, reapitRefInput, StatusModal, onAfterSubmit } from '../status-modal' +import { developerSetStatusRequest } from '@/actions/developer-set-status' +import { shallow, mount } from 'enzyme' +import React from 'react' +import { FormikProps } from '@reapit/elements' +import configureStore from 'redux-mock-store' +import { PagedResultDeveloperModel_ } from '@/types/marketplace-api-schema' +import appState from '@/reducers/__stubs__/app-state' +import * as ReactRedux from 'react-redux' + +const createStore = (loading: boolean, data?: PagedResultDeveloperModel_) => { + return { + ...appState, + adminDevManagement: { + loading, + ...(data ? { data } : {}), + }, + } +} + +describe('onSubmitStatus', () => { + it('should run correctly', () => { + const developer = {} + const dispatch = jest.fn() + const setSubmitting = jest.fn() + const onAfterSubmit = jest.fn() + const fn = onSubmitStatus(developer, dispatch, setSubmitting, onAfterSubmit) + const params = { status: 'status', reapitReference: 'reapitReference' } + fn(params) + expect(setSubmitting).toBeCalledWith(true) + expect(dispatch).toBeCalledWith( + developerSetStatusRequest({ + ...developer, + status: params.status, + reapitReference: params.reapitReference, + callback: onAfterSubmit, + }), + ) + }) +}) + +describe('onAfterSubmit', () => { + const setSubmitting = jest.fn() + const onClose = jest.fn() + const fn = onAfterSubmit(setSubmitting, onClose) + fn(true) + expect(setSubmitting).toBeCalledWith(false) + expect(onClose).toBeCalled() +}) + +describe('ReapitRefInput', () => { + const form = { + values: { + status: 'confirmed', + }, + } as FormikProps + expect(shallow(
{reapitRefInput(form)}
)).toMatchSnapshot() +}) + +describe('StatusModal', () => { + let store, mockStore + beforeEach(() => { + mockStore = configureStore() + }) + it('should match snapshot', () => { + store = mockStore(createStore(false, {})) + + expect( + mount( + + + , + ), + ).toMatchSnapshot() + }) +}) diff --git a/packages/admin-portal/src/components/pages/admin-dev-management/set-status-modal/form-schema.ts b/packages/admin-portal/src/components/pages/admin-dev-management/set-status-modal/form-schema.ts new file mode 100644 index 0000000000..cb6cae73b2 --- /dev/null +++ b/packages/admin-portal/src/components/pages/admin-dev-management/set-status-modal/form-schema.ts @@ -0,0 +1,33 @@ +import * as Yup from 'yup' +import errorMessages from '@/constants/error-messages' +import { FormFieldInfo, reapitRefRegex } from '@reapit/utils' + +export type FieldKey = 'status' | 'reapitReference' +export const formFields: Record = { + status: { + name: 'status', + label: 'Status', + }, + reapitReference: { + name: 'reapitReference', + label: 'Reapit Reference', + placeHolder: 'Please enter reference', + errorMessage: 'Reapit Reference must be 6 characters, e.g. "HJP092"', + }, +} + +const { status, reapitReference } = formFields + +export const validationSchema = Yup.object().shape({ + [status.name]: Yup.string() + .trim() + .required(errorMessages.FIELD_REQUIRED), + [reapitReference.name]: Yup.string() + .trim() + .when(status.name, { + is: val => val == 'confirmed', + then: Yup.string() + .required(errorMessages.FIELD_REQUIRED) + .matches(reapitRefRegex, reapitReference.errorMessage), + }), +}) diff --git a/packages/admin-portal/src/components/pages/admin-dev-management/set-status-modal/status-modal.tsx b/packages/admin-portal/src/components/pages/admin-dev-management/set-status-modal/status-modal.tsx new file mode 100644 index 0000000000..e551be4709 --- /dev/null +++ b/packages/admin-portal/src/components/pages/admin-dev-management/set-status-modal/status-modal.tsx @@ -0,0 +1,119 @@ +import React, { useState } from 'react' +import { ModalV2, Formik, Form, Button, RadioSelect, RadioSelectOption, Input, FormikProps } from '@reapit/elements' +import { UpdateDeveloperModel, DeveloperModel } from '@reapit/foundations-ts-definitions' +import { developerSetStatusRequest } from '@/actions/developer-set-status' +import { Dispatch } from 'redux' +import { useDispatch } from 'react-redux' +import { validationSchema } from './form-schema' + +interface StatusModalProps { + visible: boolean + developer: DeveloperModel + resetModal: (refreshDevList: boolean) => any +} + +export const onSubmitStatus = (developer: UpdateDeveloperModel, dispatch: Dispatch, setSubmitting, onAfterSubmit) => { + return ({ status, reapitReference }) => { + setSubmitting(true) + dispatch( + developerSetStatusRequest({ + ...developer, + status, + reapitReference, + callback: onAfterSubmit, + }), + ) + } +} + +export const onAfterSubmit = (setSubmitting, onClose) => (success: boolean) => { + setSubmitting(false) + if (success) onClose() +} + +export const reapitRefInput: React.FC> = form => { + const { values } = form + if (values.status === 'confirmed') + return ( + + ) + return null +} + +const options: RadioSelectOption[] = [ + { + value: 'incomplete', + label: 'Incomplete', + }, + { + value: 'pending', + label: 'Pending', + }, + { + value: 'confirmed', + label: 'Confirmed', + additionalField: reapitRefInput, + }, + { + value: 'underReview', + label: 'Under Review', + }, + { + value: 'removed', + label: 'Removed', + }, +] + +export const StatusModal: React.FC = ({ visible, developer, resetModal }) => { + if (!visible) return null + const dispatch = useDispatch() + const [submitting, setSubmitting] = useState(false) + + const { company, status, reapitReference } = developer + const initialValues = { + status, + reapitReference, + } + return ( + + {({ handleSubmit, setFieldValue, values }) => { + const { status } = values + return ( + + CANCEL + , + , + ]} + destroyOnClose + onClose={resetModal(false)} + > +

Status

+
+ + +
+ ) + }} +
+ ) +} + +export default StatusModal diff --git a/packages/admin-portal/src/sagas/__stubs__/app-usage-stats.ts b/packages/admin-portal/src/sagas/__stubs__/app-usage-stats.ts deleted file mode 100644 index b2bff97978..0000000000 --- a/packages/admin-portal/src/sagas/__stubs__/app-usage-stats.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { UsageStatsModel } from '@reapit/foundations-ts-definitions' - -export const usageStatsDataStub: UsageStatsModel = { - dateFrom: '2019-11-09T00:00:00+00:00', - dateTo: '2020-02-07T00:00:00+00:00', - totalRequestsForPeriod: 5, - appUsage: [ - { - appId: '09043eb8-9e5e-4650-b7f1-f0cb62699027', - requestsForPeriod: 5, - usage: [ - { - date: '2019-11-15T00:00:00+00:00', - requests: 5, - }, - ], - }, - ], -} - -export const usageStatsForMultipleAppsDataStub: UsageStatsModel = { - dateFrom: '2020-02-09T09:18:23.957Z', - dateTo: '2020-02-09T09:18:23.957Z', - totalRequestsForPeriod: 13, - appUsage: [ - { - appId: '09043eb8-9e5e-4650-b7f1-f0cb62699027', - requestsForPeriod: 7, - usage: [ - { - date: '2020-02-09T09:18:23.957Z', - requests: 2, - }, - { - date: '2020-02-01T09:18:23.957Z', - requests: 5, - }, - { - date: '2020-02-05T09:18:23.957Z', - requests: 0, - }, - ], - }, - { - appId: '261da083-cee2-4f5c-a18f-8f9375f1f5af', - requestsForPeriod: 6, - usage: [ - { - date: '2020-02-09T09:18:23.957Z', - requests: 3, - }, - { - date: '2020-02-01T09:18:23.957Z', - requests: 3, - }, - { - date: '2020-02-05T09:18:23.957Z', - requests: 0, - }, - ], - }, - ], -} diff --git a/packages/admin-portal/src/sagas/developer-set-status.ts b/packages/admin-portal/src/sagas/developer-set-status.ts index bff25aa625..9b677e59e8 100644 --- a/packages/admin-portal/src/sagas/developer-set-status.ts +++ b/packages/admin-portal/src/sagas/developer-set-status.ts @@ -13,6 +13,7 @@ import { logger } from '@reapit/utils' import { updateDeveloperById } from '@/services/developers' export const developerSetStatusRequestSaga = function*({ data: dev }) { + const { callback } = dev try { if (!dev.id) { throw new Error('developerId is not exist') @@ -23,8 +24,10 @@ export const developerSetStatusRequestSaga = function*({ data: dev }) { yield call(updateDeveloperById, { ...dev, companyName: dev.company }) yield put(developerSetStatusRequestSuccess()) + callback && callback(true) } catch (err) { logger(err) + callback && callback(false) yield put(developerSetStatusRequestFailure()) yield put( errorThrownServer({ diff --git a/packages/admin-portal/src/services/statistics.ts b/packages/admin-portal/src/services/statistics.ts deleted file mode 100644 index 130510d773..0000000000 --- a/packages/admin-portal/src/services/statistics.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { UsageStatsModel } from '@reapit/foundations-ts-definitions' -import { fetcher, setQueryParams } from '@reapit/elements' -import { URLS } from './constants' -import { generateHeader } from './utils' -import { logger } from '@reapit/utils' - -export type FetchStatisticsListParams = { - appId?: string[] - dateFrom?: string - dateTo?: string -} - -export const fetchStatisticsList = async (params: FetchStatisticsListParams): Promise => { - try { - const response = await fetcher({ - url: `${URLS.statistics}?${setQueryParams(params)}`, - api: window.reapit.config.marketplaceApiUrl, - method: 'GET', - headers: generateHeader(window.reapit.config.marketplaceApiKey), - }) - return response - } catch (error) { - logger(error) - throw new Error(error) - } -} diff --git a/packages/admin-portal/src/tests/badges/badge-branches.svg b/packages/admin-portal/src/tests/badges/badge-branches.svg index 2eb03dc779..f57b71276a 100644 --- a/packages/admin-portal/src/tests/badges/badge-branches.svg +++ b/packages/admin-portal/src/tests/badges/badge-branches.svg @@ -1 +1 @@ -Coverage:branchesCoverage:branches70.11%70.11% \ No newline at end of file +Coverage:branches: 73.53%Coverage:branches73.53% \ No newline at end of file diff --git a/packages/admin-portal/src/tests/badges/badge-functions.svg b/packages/admin-portal/src/tests/badges/badge-functions.svg index 254aa95085..588d35abc8 100644 --- a/packages/admin-portal/src/tests/badges/badge-functions.svg +++ b/packages/admin-portal/src/tests/badges/badge-functions.svg @@ -1 +1 @@ -Coverage:functionsCoverage:functions81.9%81.9% \ No newline at end of file +Coverage:functions: 83.52%Coverage:functions83.52% \ No newline at end of file diff --git a/packages/admin-portal/src/tests/badges/badge-lines.svg b/packages/admin-portal/src/tests/badges/badge-lines.svg index e4889efa95..973de80fb2 100644 --- a/packages/admin-portal/src/tests/badges/badge-lines.svg +++ b/packages/admin-portal/src/tests/badges/badge-lines.svg @@ -1 +1 @@ -Coverage:linesCoverage:lines91.26%91.26% \ No newline at end of file +Coverage:lines: 88.88%Coverage:lines88.88% \ No newline at end of file diff --git a/packages/admin-portal/src/tests/badges/badge-statements.svg b/packages/admin-portal/src/tests/badges/badge-statements.svg index cbb590d7bb..ccc93cb14c 100644 --- a/packages/admin-portal/src/tests/badges/badge-statements.svg +++ b/packages/admin-portal/src/tests/badges/badge-statements.svg @@ -1 +1 @@ -Coverage:statementsCoverage:statements90.27%90.27% \ No newline at end of file +Coverage:statements: 88.38%Coverage:statements88.38% \ No newline at end of file diff --git a/packages/aml-checklist/src/tests/badges/badge-branches.svg b/packages/aml-checklist/src/tests/badges/badge-branches.svg index 28d6f15059..b1f2950432 100644 --- a/packages/aml-checklist/src/tests/badges/badge-branches.svg +++ b/packages/aml-checklist/src/tests/badges/badge-branches.svg @@ -1 +1 @@ -Coverage:branchesCoverage:branches61.94%61.94% \ No newline at end of file +Coverage:branches: 61.94%Coverage:branches61.94% \ No newline at end of file diff --git a/packages/aml-checklist/src/tests/badges/badge-functions.svg b/packages/aml-checklist/src/tests/badges/badge-functions.svg index 3b45d7a57b..fa719fb48f 100644 --- a/packages/aml-checklist/src/tests/badges/badge-functions.svg +++ b/packages/aml-checklist/src/tests/badges/badge-functions.svg @@ -1 +1 @@ -Coverage:functionsCoverage:functions73.36%73.36% \ No newline at end of file +Coverage:functions: 73.36%Coverage:functions73.36% \ No newline at end of file diff --git a/packages/aml-checklist/src/tests/badges/badge-lines.svg b/packages/aml-checklist/src/tests/badges/badge-lines.svg index 4fccda735b..084c9377ce 100644 --- a/packages/aml-checklist/src/tests/badges/badge-lines.svg +++ b/packages/aml-checklist/src/tests/badges/badge-lines.svg @@ -1 +1 @@ -Coverage:linesCoverage:lines86.78%86.78% \ No newline at end of file +Coverage:lines: 86.78%Coverage:lines86.78% \ No newline at end of file diff --git a/packages/aml-checklist/src/tests/badges/badge-statements.svg b/packages/aml-checklist/src/tests/badges/badge-statements.svg index 98a0998c93..69218d879b 100644 --- a/packages/aml-checklist/src/tests/badges/badge-statements.svg +++ b/packages/aml-checklist/src/tests/badges/badge-statements.svg @@ -1 +1 @@ -Coverage:statementsCoverage:statements86.29%86.29% \ No newline at end of file +Coverage:statements: 86.29%Coverage:statements86.29% \ No newline at end of file diff --git a/packages/cognito-auth/src/tests/badges/badge-branches.svg b/packages/cognito-auth/src/tests/badges/badge-branches.svg index dfc98d123c..859550b5d6 100644 --- a/packages/cognito-auth/src/tests/badges/badge-branches.svg +++ b/packages/cognito-auth/src/tests/badges/badge-branches.svg @@ -1 +1 @@ -Coverage:branchesCoverage:branches80.92%80.92% \ No newline at end of file +Coverage:branches: 80.92%Coverage:branches80.92% \ No newline at end of file diff --git a/packages/cognito-auth/src/tests/badges/badge-functions.svg b/packages/cognito-auth/src/tests/badges/badge-functions.svg index e1117ddc0c..4c04d382e7 100644 --- a/packages/cognito-auth/src/tests/badges/badge-functions.svg +++ b/packages/cognito-auth/src/tests/badges/badge-functions.svg @@ -1 +1 @@ -Coverage:functionsCoverage:functions93.55%93.55% \ No newline at end of file +Coverage:functions: 93.55%Coverage:functions93.55% \ No newline at end of file diff --git a/packages/cognito-auth/src/tests/badges/badge-lines.svg b/packages/cognito-auth/src/tests/badges/badge-lines.svg index 561a5df7e2..e13ff3c3cd 100644 --- a/packages/cognito-auth/src/tests/badges/badge-lines.svg +++ b/packages/cognito-auth/src/tests/badges/badge-lines.svg @@ -1 +1 @@ -Coverage:linesCoverage:lines95.6%95.6% \ No newline at end of file +Coverage:lines: 95.6%Coverage:lines95.6% \ No newline at end of file diff --git a/packages/cognito-auth/src/tests/badges/badge-statements.svg b/packages/cognito-auth/src/tests/badges/badge-statements.svg index 29fbaf0d33..b584db5eb3 100644 --- a/packages/cognito-auth/src/tests/badges/badge-statements.svg +++ b/packages/cognito-auth/src/tests/badges/badge-statements.svg @@ -1 +1 @@ -Coverage:statementsCoverage:statements95.63%95.63% \ No newline at end of file +Coverage:statements: 95.63%Coverage:statements95.63% \ No newline at end of file diff --git a/packages/developer-portal/src/components/pages/admin-apps/__tests__/__snapshots__/admin-apps.test.tsx.snap b/packages/developer-portal/src/components/pages/admin-apps/__tests__/__snapshots__/admin-apps.test.tsx.snap index cff19fb198..c726b53511 100644 --- a/packages/developer-portal/src/components/pages/admin-apps/__tests__/__snapshots__/admin-apps.test.tsx.snap +++ b/packages/developer-portal/src/components/pages/admin-apps/__tests__/__snapshots__/admin-apps.test.tsx.snap @@ -226,7 +226,7 @@ exports[`admin-apps AdminApprovals should match a snapshot 1`] = ` validate={null} >
Coverage:branchesCoverage:branches68.7%68.7% +Coverage:branches: 68.37%Coverage:branches68.37% \ No newline at end of file diff --git a/packages/developer-portal/src/tests/badges/badge-functions.svg b/packages/developer-portal/src/tests/badges/badge-functions.svg index 9eb230d7ae..7058be17e5 100644 --- a/packages/developer-portal/src/tests/badges/badge-functions.svg +++ b/packages/developer-portal/src/tests/badges/badge-functions.svg @@ -1 +1 @@ -Coverage:functionsCoverage:functions79.34%79.34% +Coverage:functions: 79.39%Coverage:functions79.39% \ No newline at end of file diff --git a/packages/developer-portal/src/tests/badges/badge-lines.svg b/packages/developer-portal/src/tests/badges/badge-lines.svg index 8c369a301d..0c210737a3 100644 --- a/packages/developer-portal/src/tests/badges/badge-lines.svg +++ b/packages/developer-portal/src/tests/badges/badge-lines.svg @@ -1 +1 @@ -Coverage:linesCoverage:lines89.66%89.66% +Coverage:lines: 89.65%Coverage:lines89.65% \ No newline at end of file diff --git a/packages/developer-portal/src/tests/badges/badge-statements.svg b/packages/developer-portal/src/tests/badges/badge-statements.svg index 2ca47f26d4..88754d34d4 100644 --- a/packages/developer-portal/src/tests/badges/badge-statements.svg +++ b/packages/developer-portal/src/tests/badges/badge-statements.svg @@ -1 +1 @@ -Coverage:statementsCoverage:statements88.64%88.64% +Coverage:statements: 88.63%Coverage:statements88.63% \ No newline at end of file diff --git a/packages/elements/src/components/Input/index.tsx b/packages/elements/src/components/Input/index.tsx index aff17bee84..790e1e9b2f 100644 --- a/packages/elements/src/components/Input/index.tsx +++ b/packages/elements/src/components/Input/index.tsx @@ -16,6 +16,7 @@ export interface InputProps { disabled?: boolean validate?: (value: string) => string | null maxLength?: number + className?: string } export const Input = ({ @@ -31,14 +32,15 @@ export const Input = ({ maxLength, validate = fieldValidateRequire, helperText, + className = '', }: InputProps) => ( {({ field, meta }: FieldProps) => { const hasError = checkError(meta) - const className = hasError ? 'input is-danger' : 'input is-primary' + const inputClassName = hasError ? 'input is-danger' : 'input is-primary' const defaultValue = '' return ( -
+
{type !== 'hidden' && !rightIcon && labelText && (