Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
472fc13
PLAT-536 #comment add logout #time 15m
brooketopcoder Mar 4, 2022
2ca5f17
PLAt-536 #comment fix link hover #time 5m
brooketopcoder Mar 7, 2022
80d4bbe
PLAT-536 #comment fix logo size #time 15m
brooketopcoder Mar 8, 2022
c981053
PLAT-764 #comment convert svgs to components and
brooketopcoder Mar 8, 2022
43c3b70
PLAT-764 #comment remove styling from SVGs;
brooketopcoder Mar 8, 2022
29b1ee5
PLAT-764 #comment refactor narrow tool selectors
brooketopcoder Mar 8, 2022
d14ae22
PLAT-764 #comment rename svgs folder #time 5m
brooketopcoder Mar 8, 2022
0aa2bbe
PLAT-764 #comment clean up styles and svgs; #time 30m
brooketopcoder Mar 8, 2022
25087d1
PLAT-764 #comment clean-up #time 5m
brooketopcoder Mar 8, 2022
a19de5c
PALT-764 #comment clean-up #time 5m
brooketopcoder Mar 8, 2022
5485f05
PLAT-764 #comment clean-up #time 5m
brooketopcoder Mar 8, 2022
dd5275e
PLAT-764 #comment clean-up #time 5m
brooketopcoder Mar 9, 2022
ecf205e
PLAT-764 #comment clean-upo #time 5m
brooketopcoder Mar 9, 2022
ce7209a
Merge branch 'master' into PLAT-754_tools-config
brooketopcoder Mar 9, 2022
6e902ec
PLAT-754 #comment convert url configs to constants;
brooketopcoder Mar 9, 2022
83d24b8
PLAT-754 #comment create and use route
brooketopcoder Mar 10, 2022
efd8e51
PLAT-745 #comment add child routes;
brooketopcoder Mar 10, 2022
f257056
PLAT-754 #comment configure sections in content
brooketopcoder Mar 10, 2022
38ceed9
PLAT-754 #comment replace route config
brooketopcoder Mar 10, 2022
0047be9
PLAT-754 #comment hide sections for tools
brooketopcoder Mar 10, 2022
9c467d3
PLAT-754 #comment fix styling for expanded
brooketopcoder Mar 10, 2022
6b00439
PLAT-754 #comment route provider cleanup #time 1h
brooketopcoder Mar 10, 2022
bdf45cf
PLAT-754 #comment tools narrow clean-up; #time 30m
brooketopcoder Mar 10, 2022
4420617
PLAT-764 #comment clean-up #time 5m
brooketopcoder Mar 10, 2022
a7df686
PLAT-7584 #comment clean-up #time 10m
brooketopcoder Mar 10, 2022
9478eff
POLAT-754 #comment clean-up #time 5m
brooketopcoder Mar 10, 2022
37928c7
PLAT-754 #comment clean-up #time 5m
brooketopcoder Mar 10, 2022
784461e
PLAT-754 #comment clean-up #time 5m
brooketopcoder Mar 10, 2022
9d161e8
Merge branch 'master' into PLAT-754_tools-config
brooketopcoder Mar 10, 2022
8011b5c
PLAT-754 #comment update readme #time 10m
brooketopcoder Mar 10, 2022
3070fc5
Merge branch 'master' into PLAT-754_tools-config
brooketopcoder Mar 10, 2022
9da630d
Merge branch 'master' into PLAT-754_tools-config
brooketopcoder Mar 10, 2022
fbf5296
PLAT-754 #comment fix build issues #time 10m
brooketopcoder Mar 10, 2022
74f84ba
PLAT-754 #comment clean-up #time 5m
brooketopcoder Mar 10, 2022
e5f1fc0
Merge branch 'master' into PLAT-754_tools-config
brooketopcoder Mar 11, 2022
ddad763
PLAT-754 #comment remove commented out tests #time 5m
brooketopcoder Mar 11, 2022
0687f21
PLAT-802 #comment create profile util;
brooketopcoder Mar 11, 2022
9d38a6c
PLAT-825 #comment fix profile styling;
brooketopcoder Mar 14, 2022
20411b1
Merge branch 'PLAT-802_profile-util' into PLAT-825_form-text-fields
brooketopcoder Mar 14, 2022
6373d82
PLAT-825 #comment consolidate font styles; #time 1h
brooketopcoder Mar 14, 2022
3beac2d
PLAT-828 #comment create button component;
brooketopcoder Mar 14, 2022
9d0dc29
PLAT-825 Form Text Fields & Profile - PLAT-802_profile-util (#46)
brooketopcoder Mar 15, 2022
63b1c87
PLAT-828 #comment use axios for xhr;
brooketopcoder Mar 15, 2022
353f0d4
PLAT-828 #comment rename all services to
brooketopcoder Mar 15, 2022
2738b0e
PLAT-828 #comment add update password functions
brooketopcoder Mar 15, 2022
40f51dd
Merge branch 'PLAT-802_profile-util' into PLAT-828_profile-api
brooketopcoder Mar 15, 2022
a5288a7
PLAT-828 #comment clean-up #time 5m
brooketopcoder Mar 15, 2022
da90fd6
PLAT-828 #comment clean-up #time 10m
brooketopcoder Mar 16, 2022
322f729
PLAT-828 #comment use v3 api for pw change
brooketopcoder Mar 16, 2022
3d1e645
PLAT-828 profile api to PLAT-802_profile-util (#50)
brooketopcoder Mar 16, 2022
29b6408
Merge branch 'PLAT-802_profile-util' into PLAT-826_validation
brooketopcoder Mar 16, 2022
cd5d848
PLAT-826 #comment reset pw fields upon submission
brooketopcoder Mar 16, 2022
07a211a
PLAT-826 #comment permit buttons
brooketopcoder Mar 16, 2022
dce60af
PLAT-826 #comment support for fields
brooketopcoder Mar 16, 2022
4e36e0a
PLAT-826 #comment clean-up #time 10m
brooketopcoder Mar 16, 2022
71a7cec
PLAT-826 #comment clean-up #time 5m
brooketopcoder Mar 16, 2022
7282b63
PLAT-826 #comment fix eslint rules #time 25m
brooketopcoder Mar 16, 2022
1814110
PLAT-895 #comment convert tool tool to work intake
brooketopcoder Mar 17, 2022
1ca1bec
PROD-265 #comment Merge branch 'PROD-265_work-intake' into PROD-500_c…
brooketopcoder Mar 23, 2022
fb5a995
PROD-500 #comment clean-up #time 10m
brooketopcoder Mar 23, 2022
8be91d5
PROD-500 #comment rename profileContext
brooketopcoder Mar 24, 2022
84f068f
PROD-500 #comment clean up error handling; #time 10m
brooketopcoder Mar 24, 2022
9dc2fcb
PROD-500 #comment create work intake form;
brooketopcoder Mar 24, 2022
4bd77ec
PROD-500 #comment rename routecontext #time 5m
brooketopcoder Mar 24, 2022
105c887
PROD-500 #comment clean-up #time 10m
brooketopcoder Mar 24, 2022
7722e6f
PROD-500 #comment remove ordering;
brooketopcoder Mar 24, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import { toast, ToastContainer } from 'react-toastify'
import { EnvironmentConfig } from './config'
import { Header } from './header'
import { analyticsInitialize, logInitialize, ProfileProvider } from './lib'
import { RouteContext, RouteContextData } from './lib/route-provider'
import { routeContext, RouteContextData } from './lib/route-provider'

analyticsInitialize(EnvironmentConfig)
logInitialize(EnvironmentConfig)

const App: FC<{}> = () => {

const { allRoutes }: RouteContextData = useContext(RouteContext)
const { allRoutes }: RouteContextData = useContext(routeContext)

const routeElements: Array<ReactElement> = allRoutes
.map(route => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import classNames from 'classnames'
import { Dispatch, FC, SetStateAction, useContext, useState } from 'react'

import { IconOutline, RouteContext, RouteContextData } from '../../../lib'
import { IconOutline, routeContext, RouteContextData } from '../../../lib'

import { ToolSelectorNarrow } from './tool-selector-narrow'
import styles from './ToolSelectorsNarrow.module.scss'

const ToolSelectorsNarrow: FC<{}> = () => {

const { toolsRoutes }: RouteContextData = useContext(RouteContext)
const { toolsRoutes }: RouteContextData = useContext(routeContext)
const [isOpen, setIsOpen]: [boolean, Dispatch<SetStateAction<boolean>>] = useState<boolean>(false)

const closed: JSX.Element = <IconOutline.MenuIcon />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { FC, useContext } from 'react'

import { RouteContext, RouteContextData } from '../../../lib'
import { routeContext, RouteContextData } from '../../../lib'

import { ToolSelectorWide } from './tool-selector-wide'
import styles from './ToolSelectorsWide.module.scss'

const ToolSelectorsWide: FC<{}> = () => {

const { toolsRoutes }: RouteContextData = useContext(RouteContext)
const { toolsRoutes }: RouteContextData = useContext(routeContext)

const selectors: Array<JSX.Element> = toolsRoutes
.map(route => <ToolSelectorWide key={route.title} route={route} />)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FC, useContext } from 'react'

import { ProfileContext, ProfileContextData } from '../../../../lib'
import { profileContext, ProfileContextData } from '../../../../lib'
import '../../../../lib/styles/index.scss'

import { ProfileLoggedIn } from './profile-logged-in'
Expand All @@ -12,7 +12,7 @@ const ProfileSelector: FC<{}> = () => {
const {
initialized,
profile,
}: ProfileContextData = useContext(ProfileContext)
}: ProfileContextData = useContext(profileContext)

// if we're not initialized, don't render anything
if (!initialized) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import { Dispatch, FC, SetStateAction, useContext, useState } from 'react'

import { Avatar, IconOutline, logInfo , ProfileContext, ProfileContextData } from '../../../../../lib'
import {
Avatar,
IconOutline,
logInfo,
profileContext,
ProfileContextData,
} from '../../../../../lib'

import { ProfilePanel } from './profile-panel'
import styles from './ProfileLoggedIn.module.scss'

const ProfileLoggedIn: FC<{}> = () => {

const { profile }: ProfileContextData = useContext(ProfileContext)
const { profile }: ProfileContextData = useContext(profileContext)
const [profilePanelOpen, setProfilePanelOpen]: [boolean, Dispatch<SetStateAction<boolean>>] = useState<boolean>(false)

if (!profile) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { Link } from 'react-router-dom'

import {
authUrlLogout,
ProfileContext,
profileContext,
ProfileContextData,
RouteContext,
routeContext,
RouteContextData,
} from '../../../../../../lib'

Expand All @@ -17,8 +17,8 @@ interface ProfilePanelProps {

const ProfilePanel: FC<ProfilePanelProps> = (props: ProfilePanelProps) => {

const { profile }: ProfileContextData = useContext(ProfileContext)
const { getPath }: RouteContextData = useContext(RouteContext)
const { profile }: ProfileContextData = useContext(profileContext)
const { getPath }: RouteContextData = useContext(routeContext)

if (!profile) {
// this should never happen
Expand Down
12 changes: 8 additions & 4 deletions src/lib/button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@ import { Link } from 'react-router-dom'

import styles from './Button.module.scss'

interface ButtonProps {
readonly buttonStyle?: 'primary' | 'secondary' | 'tertiary' | 'text'
export type ButtonSize = 'sm' | 'md' | 'lg' | 'xl'
export type ButtonStyle = 'primary' | 'secondary' | 'tertiary' | 'text'
export type ButtonType = 'button' | 'submit'

export interface ButtonProps {
readonly buttonStyle?: ButtonStyle
readonly className?: string
readonly disable?: boolean
readonly label: string
readonly onClick?: (event?: any) => void
readonly route?: string
readonly size?: 'sm' | 'md' | 'lg' | 'xl'
readonly size?: ButtonSize
readonly tabIndex: number
readonly type?: 'button' | 'submit'
readonly type?: ButtonType
readonly url?: string
}

Expand Down
6 changes: 6 additions & 0 deletions src/lib/button/Buttons.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import '@testing-library/jest-dom'

describe('<Button />', () => {

test('it should render the content', () => { })
})
7 changes: 6 additions & 1 deletion src/lib/button/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
export { default as Button } from './Button'
export { default as Button } from './Button'
export type {
ButtonSize,
ButtonStyle,
ButtonType
} from './Button'
5 changes: 0 additions & 5 deletions src/lib/form-elements/form-functions/form-definition.model.ts

This file was deleted.

15 changes: 0 additions & 15 deletions src/lib/form-elements/form-functions/form-input.model.ts

This file was deleted.

11 changes: 0 additions & 11 deletions src/lib/form-elements/form-functions/index.ts

This file was deleted.

3 changes: 0 additions & 3 deletions src/lib/form-elements/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/lib/form-elements/text-input/index.ts

This file was deleted.

12 changes: 12 additions & 0 deletions src/lib/form/Form.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@import '../../lib/styles';

.form-fields {
display: grid;
grid-template-columns: .5fr;
justify-content: flex-end;

@include ltemd {
grid-template-columns: 1fr;
justify-content: center;
}
}
6 changes: 6 additions & 0 deletions src/lib/form/Form.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import '@testing-library/jest-dom'

describe('<Form />', () => {

test('it should render the form', () => {})
})
126 changes: 126 additions & 0 deletions src/lib/form/Form.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
import { Dispatch, FormEvent, SetStateAction, useState } from 'react'

import { Button } from '../button'
import '../styles/index.scss'

import { FormDefinition } from './form-definition.model'
import {
FormErrorMessage,
formGetInputModel,
formInitializeValues,
formReset,
formSubmitAsync,
formValidateAndUpdate,
} from './form-functions'
import { FormInputModel } from './form-input.model'
import styles from './Form.module.scss'
import { TextInput } from './text-input'

interface FormProps<ValueType, RequestType> {
readonly formDef: FormDefinition
readonly formValues?: ValueType
readonly requestGenerator: (inputs: ReadonlyArray<FormInputModel>) => RequestType
readonly resetOnError: boolean
readonly save: (value: RequestType) => Promise<void>
}

const Form: <ValueType extends any, RequestType extends any>(props: FormProps<ValueType, RequestType>) => JSX.Element
= <ValueType extends any, RequestType extends any>(props: FormProps<ValueType, RequestType>) => {

const [disableSave, setDisableSave]: [boolean, Dispatch<SetStateAction<boolean>>]
= useState<boolean>(true)

const [formDef, setFormDef]: [FormDefinition, Dispatch<SetStateAction<FormDefinition>>]
= useState<FormDefinition>({ ...props.formDef })

const [formKey, setFormKey]: [number, Dispatch<SetStateAction<number>>]
= useState<number>(Date.now())

function onChange(event: FormEvent<HTMLFormElement>): void {
const isValid: boolean = formValidateAndUpdate(event, formDef.inputs)
setFormDef({ ...formDef })
setDisableSave(!isValid)
}

function onReset(): void {
setFormDef({ ...formDef })
formReset(props.formDef.inputs, props.formValues)
setFormKey(Date.now())
}

async function onSubmit(event: FormEvent<HTMLFormElement>): Promise<void> {
const values: RequestType = props.requestGenerator(formDef.inputs)
formSubmitAsync<RequestType, void>(event, formDef.inputs, props.formDef.title, values, props.save, setDisableSave)
.then(() => {
setFormKey(Date.now())
formReset(formDef.inputs, props.formValues)
setFormDef({ ...formDef })
})
.catch((error: FormErrorMessage) => {
// only reset on save errors
if (props.resetOnError && error === FormErrorMessage.save) {
formReset(formDef.inputs, props.formValues)
setFormKey(Date.now())
}
setFormDef({ ...formDef })
})
}

formInitializeValues(formDef.inputs, props.formValues)

const formInputs: Array<JSX.Element> = props.formDef.inputs
.map(input => formGetInputModel(props.formDef.inputs, input.name))
.map((inputModel, index) => {
return (
<TextInput
{...inputModel}
key={inputModel.name}
tabIndex={inputModel.notTabbable ? -1 : index + 1}
type={inputModel.type || 'text'}
value={inputModel.value}
/>
)
})

const buttons: Array<JSX.Element> = props.formDef.buttons
.map((button, index) => {
// if this is a reset button, set its onclick to reset
if (!!button.isReset) {
button = {
...button,
onClick: onReset,
}
}
return (
<Button
{...button}
disable={button.isSave && disableSave}
key={button.label}
tabIndex={button.notTabble ? -1 : index + props.formDef.inputs.length}
/>
)
})

return (
<form
action={''}
key={formKey}
onChange={onChange}
onSubmit={onSubmit}
>

<h6>{props.formDef.title}</h6>

<div className={styles['form-fields']}>
{formInputs}
</div>

<div className='button-container'>
{buttons}
</div>

</form>
)
}

export default Form
14 changes: 14 additions & 0 deletions src/lib/form/form-button.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { ButtonSize, ButtonStyle, ButtonType } from '../button'

export interface FormButton {
readonly buttonStyle?: ButtonStyle
readonly isReset?: boolean
readonly isSave?: boolean
readonly label: string
readonly notTabble?: boolean
readonly onClick?: (event?: any) => void
route?: string
readonly size?: ButtonSize
readonly type?: ButtonType
readonly url?: string
}
8 changes: 8 additions & 0 deletions src/lib/form/form-definition.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { FormButton } from './form-button.model'
import { FormInputModel } from './form-input.model'

export interface FormDefinition {
readonly buttons: ReadonlyArray<FormButton>
readonly inputs: ReadonlyArray<FormInputModel>
readonly title: string
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import { IconSolid } from '../../svgs'
import styles from './Form-Field-Wrapper.module.scss'

interface FormFieldWrapperProps {
children: ReactNode
dirty?: boolean
disabled: boolean
error?: string
hint?: string
label: string
name: string
readonly children: ReactNode
readonly dirty?: boolean
readonly disabled: boolean
readonly error?: string
readonly hint?: string
readonly label: string
readonly name: string
}

const FormFieldWrapper: FC<FormFieldWrapperProps> = (props: FormFieldWrapperProps) => {
Expand Down
Loading