-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #599 from Ekep-Obasi/admin-settings-area
feat: refactor settings to new Settings cog and implement admin/non-a…
- Loading branch information
Showing
9 changed files
with
382 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import styled from 'styled-components' | ||
import { GraphViewControl } from '~/components/App/ActionsToolbar/GraphViewControl' | ||
import { Button } from '~/components/Button' | ||
import { Flex } from '~/components/common/Flex' | ||
import { Text } from '~/components/common/Text' | ||
|
||
export const Appearance = () => ( | ||
<Wrapper direction="column"> | ||
<StyledText>Default graph view:</StyledText> | ||
<GraphViewControl /> | ||
<Flex mt={308}> | ||
<Button kind="big">Save changes</Button> | ||
</Flex> | ||
</Wrapper> | ||
) | ||
|
||
const Wrapper = styled(Flex)` | ||
display: flex; | ||
gap: 10px; | ||
padding: 36px; | ||
` | ||
|
||
const StyledText = styled(Text)` | ||
font-family: Barlow; | ||
font-size: 13px; | ||
font-weight: 400; | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
import { FC } from 'react' | ||
import { FormProvider, useForm } from 'react-hook-form' | ||
import { ClipLoader } from 'react-spinners' | ||
import styled from 'styled-components' | ||
import { Button } from '~/components/Button' | ||
import { Flex } from '~/components/common/Flex' | ||
import { TextInput } from '~/components/common/TextInput' | ||
import { requiredRule } from '~/constants' | ||
import { TAboutParams, postAboutData } from '~/network/fetchSourcesData' | ||
import { colors } from '~/utils/colors' | ||
|
||
type Props = { | ||
initialValues: TAboutParams | ||
} | ||
|
||
export const General: FC<Props> = ({ initialValues }) => { | ||
const form = useForm<TAboutParams>({ defaultValues: initialValues, mode: 'onSubmit' }) | ||
const { isSubmitting } = form.formState | ||
|
||
const onSubmit = form.handleSubmit(async (data) => { | ||
try { | ||
await postAboutData(data) | ||
} catch (error) { | ||
console.warn(error) | ||
} | ||
}) | ||
|
||
return ( | ||
<FormProvider {...form}> | ||
<StyledForm id="add-node-form" onSubmit={onSubmit}> | ||
<> | ||
<Flex> | ||
<Flex pt={20}> | ||
<TextInput | ||
id="cy-about-title-id" | ||
label="Graph Title" | ||
maxLength={50} | ||
name="title" | ||
placeholder="Type graph title here..." | ||
rules={{ | ||
...requiredRule, | ||
}} | ||
/> | ||
</Flex> | ||
<Flex pt={20}> | ||
<TextInput | ||
id="cy-about-id" | ||
label="Graph Description" | ||
maxLength={50} | ||
name="description" | ||
placeholder="Type graph description here..." | ||
rules={{ | ||
...requiredRule, | ||
}} | ||
/> | ||
</Flex> | ||
<Flex pt={20}> | ||
<TextInput | ||
id="cy-about-mission_statement-id" | ||
label="Mission Statement" | ||
maxLength={50} | ||
name="mission_statement" | ||
placeholder="Type mission statement here..." | ||
rules={{ | ||
...requiredRule, | ||
}} | ||
/> | ||
</Flex> | ||
<Flex pt={20}> | ||
<TextInput | ||
id="cy-about-search_term-id" | ||
label="Search Term" | ||
maxLength={50} | ||
name="search_term" | ||
placeholder="Type search term here..." | ||
rules={{ | ||
...requiredRule, | ||
}} | ||
/> | ||
</Flex> | ||
</Flex> | ||
|
||
<Flex my={36} py={24}> | ||
{isSubmitting ? ( | ||
<SubmitLoader> | ||
<ClipLoader color={colors.white} size={20} /> | ||
</SubmitLoader> | ||
) : ( | ||
<Button disabled={isSubmitting} id="add-node-submit-cta" kind="big" type="submit"> | ||
Save changes | ||
</Button> | ||
)} | ||
</Flex> | ||
</> | ||
</StyledForm> | ||
</FormProvider> | ||
) | ||
} | ||
|
||
const SubmitLoader = styled(Flex).attrs({ | ||
align: 'center', | ||
background: 'primaryButton', | ||
borderRadius: 8, | ||
justify: 'center', | ||
})` | ||
padding: 16px 24px; | ||
opacity: 0.5; | ||
` | ||
|
||
const StyledForm = styled.form` | ||
padding: 36px; | ||
` |
Oops, something went wrong.