-
Notifications
You must be signed in to change notification settings - Fork 63
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 #448 from l3vels/feat/settings-on-integrations
Feat/settings on integrations
- Loading branch information
Showing
21 changed files
with
429 additions
and
18 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,35 @@ | ||
import withRenderModal from 'hocs/withRenderModal' | ||
|
||
import Modal from 'share-ui/components/Modal/Modal' | ||
import { useModal } from 'hooks' | ||
|
||
import ToolView from 'pages/Toolkit/ToolView' | ||
import { useToolView } from 'pages/Toolkit/ToolView/useToolView' | ||
import { StyledModalBody } from './ToolkitModal' | ||
import SettingView from 'pages/Settings/SettingView' | ||
|
||
type LlmSettingsModalProps = { | ||
data: { | ||
settingsSlug: string | ||
} | ||
} | ||
|
||
const LlmSettingsModal = ({ data }: LlmSettingsModalProps) => { | ||
const { closeModal } = useModal() | ||
|
||
const { configsData } = useToolView({}) | ||
|
||
if (!configsData) return <div /> | ||
|
||
return ( | ||
<> | ||
<Modal onClose={() => closeModal('llm-settings-modal')} show backgroundColor='light'> | ||
<StyledModalBody> | ||
<SettingView settingSlug={data.settingsSlug} /> | ||
</StyledModalBody> | ||
</Modal> | ||
</> | ||
) | ||
} | ||
|
||
export default withRenderModal('llm-settings-modal')(LlmSettingsModal) |
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,113 @@ | ||
import FormikTextField from 'components/TextFieldFormik' | ||
import { SETTINGS_FIELDS, useSettingView } from './useSettingView' | ||
import { FormikProvider } from 'formik' | ||
import { StyledSectionWrapper } from 'pages/Home/homeStyle.css' | ||
import { | ||
StyledButtonWrapper, | ||
StyledFieldsWrapper, | ||
StyledImg, | ||
StyledInnerWrapper, | ||
StyledMainTextWrapper, | ||
StyledTextWrapper, | ||
} from 'pages/Toolkit/ToolView/ToolView' | ||
import { ButtonPrimary } from 'components/Button/Button' | ||
import Button from 'share-ui/components/Button/Button' | ||
import Loader from 'share-ui/components/Loader/Loader' | ||
import { t } from 'i18next' | ||
import { settingLogos } from '../constants' | ||
import TypographySecondary from 'components/Typography/Secondary' | ||
import Typography from 'share-ui/components/typography/Typography' | ||
import TypographyPrimary from 'components/Typography/Primary' | ||
import { useModal } from 'hooks' | ||
|
||
const SettingView = ({ | ||
settingSlug, | ||
hideInfo, | ||
hideForm, | ||
}: { | ||
settingSlug: string | ||
hideInfo?: boolean | ||
hideForm?: boolean | ||
}) => { | ||
const { closeModal } = useModal() | ||
|
||
const fields = SETTINGS_FIELDS?.find((setting: any) => setting.slug === settingSlug)?.configs | ||
const name = SETTINGS_FIELDS?.find((setting: any) => setting.slug === settingSlug)?.title | ||
const { formik, isLoading, handleSubmit } = useSettingView({ fields }) | ||
|
||
const filteredLogos = settingLogos.find((setting: any) => setting.settingName === name) | ||
const logoSrc = filteredLogos?.logoSrc || '' | ||
|
||
const onHandleSubmit = async () => { | ||
await handleSubmit(formik?.values) | ||
closeModal('llm-settings-modal') | ||
} | ||
return ( | ||
<FormikProvider value={formik}> | ||
<StyledSectionWrapper> | ||
<StyledInnerWrapper> | ||
{!hideInfo && ( | ||
<> | ||
<StyledImg src={logoSrc} alt='' /> | ||
<StyledTextWrapper> | ||
<TypographySecondary | ||
value={t('by')} | ||
type={Typography.types.LABEL} | ||
size={Typography.sizes.xss} | ||
/> | ||
|
||
<TypographySecondary | ||
value={t('l3')} | ||
type={Typography.types.LABEL} | ||
size={Typography.sizes.xss} | ||
style={{ textDecoration: 'underline' }} | ||
/> | ||
</StyledTextWrapper> | ||
<StyledMainTextWrapper> | ||
<TypographyPrimary | ||
value={name} | ||
type={Typography.types.LABEL} | ||
size={Typography.sizes.lg} | ||
/> | ||
{/* <TypographySecondary | ||
value={description} | ||
type={Typography.types.LABEL} | ||
size={Typography.sizes.md} | ||
/> */} | ||
</StyledMainTextWrapper> | ||
</> | ||
)} | ||
|
||
{!hideForm && ( | ||
<StyledFieldsWrapper> | ||
{fields?.map((field: any) => { | ||
return ( | ||
<FormikTextField | ||
key={field.key} | ||
name={field.key} | ||
placeholder='' | ||
label={field.label} | ||
/> | ||
) | ||
})} | ||
</StyledFieldsWrapper> | ||
)} | ||
|
||
{!hideForm && ( | ||
<StyledButtonWrapper> | ||
<ButtonPrimary | ||
onClick={onHandleSubmit} | ||
disabled={isLoading} | ||
size={Button.sizes?.MEDIUM} | ||
> | ||
{isLoading ? <Loader size={22} /> : t('save')} | ||
</ButtonPrimary> | ||
</StyledButtonWrapper> | ||
)} | ||
</StyledInnerWrapper> | ||
</StyledSectionWrapper> | ||
</FormikProvider> | ||
) | ||
} | ||
|
||
export default SettingView |
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 @@ | ||
export { default } from './SettingView' |
Oops, something went wrong.