The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
feat: add new object standard available section (#2111)
Ujwal Kumar598fda8f45ba
diff --git a/front/src/modules/settings/data-model/constants/mockObjects.ts b/front/src/modules/settings/data-model/constants/mockObjects.tsindex 5d42ac39efc..bf1543809ec 100644--- a/front/src/modules/settings/data-model/constants/mockObjects.ts+++ b/front/src/modules/settings/data-model/constants/mockObjects.ts@@ -8,6 +8,7 @@ import {IconHeadphones,IconLink,IconLuggage,+ IconMouse2,IconPlane,IconTarget,IconUser,@@ -37,6 +38,21 @@ export const activeObjectItems = [},];+export const standardObjects = [+ {+ name: 'Users',+ Icon: IconMouse2,+ fields: 6,+ description: 'Individuals who interact with your website',+ },+ {+ name: 'Users',+ Icon: IconMouse2,+ fields: 8,+ description: 'Individuals who interact with your website',+ },+];+export const disabledObjectItems = [{name: 'Travels',diff --git a/front/src/modules/settings/data-model/new-object/components/SettingsNewObjectType.tsx b/front/src/modules/settings/data-model/new-object/components/SettingsNewObjectType.tsxindex 6b04370583a..0b6f0ad787a 100644--- a/front/src/modules/settings/data-model/new-object/components/SettingsNewObjectType.tsx+++ b/front/src/modules/settings/data-model/new-object/components/SettingsNewObjectType.tsx@@ -4,6 +4,7 @@ import styled from '@emotion/styled';import { IconBox, IconDatabase, IconFileCheck } from '@/ui/display/icon';import { SettingsObjectTypeCard } from './SettingsObjectTypeCard';+import { SettingsStandardObjects } from './SettingsStandardObjects';export type NewObjectType = 'Standard' | 'Custom' | 'Remote';@@ -16,6 +17,7 @@ const StyledContainer = styled.div`display: flex;flex-direction: row;gap: ${({ theme }) => theme.spacing(2)};+ margin-bottom: ${({ theme }) => theme.spacing(8)};width: 100%;`;@@ -25,47 +27,50 @@ export const SettingsNewObjectType = ({}: SettingsNewObjectTypeProps) => {const theme = useTheme();return (- <StyledContainer>- <SettingsObjectTypeCard- title="Standard"- color="blue"- selected={selectedType === 'Standard'}- prefixIcon={- <IconFileCheck- size={theme.icon.size.lg}- stroke={theme.icon.stroke.sm}- color={theme.font.color.tertiary}- />- }- onClick={() => onTypeSelect?.('Standard')}- />- <SettingsObjectTypeCard- title="Custom"- color="orange"- selected={selectedType === 'Custom'}- prefixIcon={- <IconBox- size={theme.icon.size.lg}- stroke={theme.icon.stroke.sm}- color={theme.font.color.tertiary}- />- }- onClick={() => onTypeSelect?.('Custom')}- />- <SettingsObjectTypeCard- title="Remote"- soon- disabled- color="green"- selected={selectedType === 'Remote'}- prefixIcon={- <IconDatabase- size={theme.icon.size.lg}- stroke={theme.icon.stroke.sm}- color={theme.font.color.tertiary}- />- }- />- </StyledContainer>+ <>+ <StyledContainer>+ <SettingsObjectTypeCard+ title={'Standard'}+ color="blue"+ selected={selectedType === 'Standard'}+ prefixIcon={+ <IconFileCheck+ size={theme.icon.size.lg}+ stroke={theme.icon.stroke.sm}+ color={theme.font.color.tertiary}+ />+ }+ onClick={() => onTypeSelect?.('Standard')}+ />+ <SettingsObjectTypeCard+ title="Custom"+ color="orange"+ selected={selectedType === 'Custom'}+ prefixIcon={+ <IconBox+ size={theme.icon.size.lg}+ stroke={theme.icon.stroke.sm}+ color={theme.font.color.tertiary}+ />+ }+ onClick={() => onTypeSelect?.('Custom')}+ />+ <SettingsObjectTypeCard+ title="Remote"+ soon+ disabled+ color="green"+ selected={selectedType === 'Remote'}+ prefixIcon={+ <IconDatabase+ size={theme.icon.size.lg}+ stroke={theme.icon.stroke.sm}+ color={theme.font.color.tertiary}+ />+ }+ />+ </StyledContainer>+ {selectedType === 'Standard' && <SettingsStandardObjects />}+ </>);};diff --git a/front/src/modules/settings/data-model/new-object/components/SettingsStandardObjects.tsx b/front/src/modules/settings/data-model/new-object/components/SettingsStandardObjects.tsxnew file mode 100644index 00000000000..31e1c2b4ee9--- /dev/null+++ b/front/src/modules/settings/data-model/new-object/components/SettingsStandardObjects.tsx@@ -0,0 +1,107 @@+import { useState } from 'react';+import { useTheme } from '@emotion/react';+import styled from '@emotion/styled';++import { H2Title } from '@/ui/display/typography/components/H2Title';+import { Table } from '@/ui/layout/table/components/Table';+import { TableCell } from '@/ui/layout/table/components/TableCell';+import { TableHeader } from '@/ui/layout/table/components/TableHeader';+import { TableRow } from '@/ui/layout/table/components/TableRow';++import { standardObjects } from '../../constants/mockObjects';++const StyledTableRow = styled(TableRow)<{+ selectedRows?: number[];+ rowNumber?: number;+}>`+ align-items: center;+ background: ${({ selectedRows, rowNumber, theme }) =>+ selectedRows?.includes(rowNumber!)+ ? theme.accent.quaternary+ : theme.background.primary};+ grid-template-columns: 36px 132px 240px 98.7px;+`;++const StyledCheckboxCell = styled(TableCell)`+ padding: 0 ${({ theme }) => theme.spacing(2)} 0+ ${({ theme }) => theme.spacing(1)};+`;++const StyledNameTableCell = styled(TableCell)`+ gap: ${({ theme }) => theme.spacing(1)};+`;++const StyledDescriptionCell = styled.div<{+ align?: 'left' | 'center' | 'right';+}>`+ color: ${({ theme }) => theme.font.color.secondary};+ justify-content: ${({ align }) =>+ align === 'right'+ ? 'flex-end'+ : align === 'center'+ ? 'center'+ : 'flex-start'};+ overflow: hidden;+ padding: 0 ${({ theme }) => theme.spacing(2)};+ padding: 0 ${({ theme }) => theme.spacing(2)};+ text-align: ${({ align }) => align ?? 'left'};+ text-overflow: ellipsis;+ white-space: nowrap;+`;++const StyledTable = styled(Table)`+ display: grid;+ gap: ${({ theme }) => theme.spacing(2)};+`;++export const SettingsStandardObjects = () => {+ const theme = useTheme();+ const [selectedRows, setSelectedRows] = useState<number[]>([]);++ return (+ <>+ <H2Title+ title="Available"+ description="Select one or several standard objects to activate below"+ />+ <StyledTable>+ <StyledTableRow>+ <TableHeader></TableHeader>+ <TableHeader>Name</TableHeader>+ <TableHeader>Description</TableHeader>+ <TableHeader align="right">Fields</TableHeader>+ </StyledTableRow>+ {standardObjects.map((object, rowNumber) => (+ <StyledTableRow+ selectedRows={selectedRows}+ rowNumber={rowNumber}+ onClick={() => {+ const indexOfRowClicked = selectedRows.indexOf(rowNumber);+ if (indexOfRowClicked === -1) {+ setSelectedRows([...selectedRows, rowNumber]);+ } else {+ const newSelectedRows = [...selectedRows];+ newSelectedRows.splice(indexOfRowClicked, 1);+ setSelectedRows(newSelectedRows);+ }+ }}+ key={object.name}+ >+ <StyledCheckboxCell>+ <input+ type="checkbox"+ checked={selectedRows.includes(rowNumber)}+ />+ </StyledCheckboxCell>+ <StyledNameTableCell>+ <object.Icon size={theme.icon.size.md} />+ {object.name}+ </StyledNameTableCell>+ <StyledDescriptionCell>{object.description}</StyledDescriptionCell>+ <TableCell align="right">{object.fields}</TableCell>+ </StyledTableRow>+ ))}+ </StyledTable>+ </>+ );+};diff --git a/front/src/modules/ui/display/icon/index.ts b/front/src/modules/ui/display/icon/index.tsindex a8cc30e09e5..982e32b9a96 100644--- a/front/src/modules/ui/display/icon/index.ts+++ b/front/src/modules/ui/display/icon/index.ts@@ -65,6 +65,7 @@ export {IconMap,IconMinus,IconMoneybag,+ IconMouse2,IconNotes,IconNumbers,IconPencil,