Skip to content

Commit

Permalink
feat: pr changes done
Browse files Browse the repository at this point in the history
  • Loading branch information
MdTeach committed Oct 5, 2023
1 parent a4aea50 commit 697c9fa
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 368 deletions.
32 changes: 16 additions & 16 deletions packages/uiweb/src/lib/components/chat/CreateGroup/AddCriteria.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,7 @@ const AddCriteria = ({
setQuantity({ ...quantity, value: e.target.value });
};


const verifyAndDoNext = ()=>{

const _type = dropdownTypeValues[selectedTypeValue].value as 'PUSH' | 'GUILD'
const category:string = _type === "PUSH" ? (dropdownCategoryValues[_type] as DropdownValueType[])[
selectedCategoryValue
Expand Down Expand Up @@ -301,11 +299,10 @@ const AddCriteria = ({
// GUILD type
return {
id:guildId,
role:specificRoleId,
comparison:guildComparison,
role:guildComparison === 'specific' ? specificRoleId : "*",
}
}

}

const rule:Rule = {
Expand All @@ -315,9 +312,10 @@ const AddCriteria = ({
data: getData(_type, category),
}

// alert(JSON.stringify(rule))
entryCriteria.addNewRule(rule)

// alert(`${JSON.stringify(rule)}`)

if(handlePrevious){
handlePrevious()
}
Expand Down Expand Up @@ -364,19 +362,17 @@ const AddCriteria = ({
}
}else{
// guild condition
alert(`${JSON.stringify(oldValue.data)}`)
setGuildId((oldValue.data as GuildData).id)
setSpecificRoleId((oldValue.data as GuildData).role)
setGuildComparison((oldValue.data as GuildData).comparison)
setGuildComparison((oldValue.data as GuildData).comparison)
}

setSelectedTypeValue(
dropdownTypeValues.findIndex(obj => obj.value === oldValue.type)
)


// TODO: reverse the form fill
}
},[0])
},[])

return (
<Section
Expand Down Expand Up @@ -502,12 +498,16 @@ const AddCriteria = ({
setGuildComparison(newEl)}}
/>

<TextInput
labelName="Specific Role"
inputValue={specificRoleId}
onInputChange={(e: any) => setSpecificRoleId(e.target.value)}
placeholder="e.g. 4687"
/>
{guildComparison === "specific" &&
<TextInput
labelName="Specific Role"
inputValue={specificRoleId}
onInputChange={(e: any) => setSpecificRoleId(e.target.value)}
placeholder="e.g. 4687"
/>
}


</>
)}
<Button width="197px" onClick={verifyAndDoNext}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import { GroupTypeState } from './CreateGroupModal';

import { ThemeContext } from '../theme/ThemeProvider';
import useToast from '../reusables/NewToast';
import {ConditionType, CriteriaStateType, Rule, } from './Type'
import { OPERATOR_OPTIONS, OPERATOR_OPTIONS_INFO } from '../constants';
import {ConditionType, CriteriaStateType,} from './Type'
import ConditionsComponent from './ConditionsComponent';
import { OperatorContainer } from './OperatorContainer';

const GROUP_TYPE_OPTIONS: Array<OptionDescription> = [
{
Expand Down Expand Up @@ -84,28 +84,13 @@ const AddConditionSection = ({

{/* todo - check later if this etire section can be optimised for define condtion page too */}
<Section flexDirection="column" gap="16px">
<OptionButtons
options={OPERATOR_OPTIONS}
selectedValue={criteriaState.entryRootCondition}
handleClick={(newEl: string) => {
criteriaState.setEntryRootCondition(newEl as ConditionType);
}}
/>
<Span fontSize="14px">
{
OPERATOR_OPTIONS_INFO[
criteriaState.entryRootCondition as keyof typeof OPERATOR_OPTIONS_INFO
].head
}
<Span color={theme.textColor?.modalSubHeadingText}>
{' '}
{
OPERATOR_OPTIONS_INFO[
criteriaState.entryRootCondition as keyof typeof OPERATOR_OPTIONS_INFO
].tail
}
</Span>
</Span>

<OperatorContainer
operator={criteriaState.entryRootCondition}
setOperator={(newEl: string) => {
criteriaState.setEntryRootCondition(newEl as ConditionType);
}}
/>

<ConditionsComponent
conditionData={[
Expand Down Expand Up @@ -204,7 +189,6 @@ export const CreateGroupType = ({
selectedValue={groupEncryptionType}
handleClick={(newEl: string) => {
setGroupEncryptionType(newEl);
console.log('we called it');
}}
/>

Expand All @@ -221,10 +205,6 @@ export const CreateGroupType = ({
criteriaState={entryCriteria}
handleNext={
()=>{
// add new condtion
// entryCriteria.


if(handleNext){
handleNext()
}
Expand Down
153 changes: 0 additions & 153 deletions packages/uiweb/src/lib/components/chat/CreateGroup/Criteria.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import { ModalHeaderProps } from './CreateGroupModal';
import { ThemeContext } from '../theme/ThemeProvider';
import { GatingRulesInformation } from './CreateGroupModal';
import useMediaQuery from '../../../hooks/useMediaQuery';
import OptionButtons from '../reusables/OptionButtons';
import { device } from '../../../config';
import { OPERATOR_OPTIONS, OPERATOR_OPTIONS_INFO } from '../constants';
import { OPERATOR_OPTIONS_INFO } from '../constants';
import ConditionsComponent from './ConditionsComponent';
import { OperatorContainer } from './OperatorContainer';
import { handleDefineCondition } from '../helpers/tokenGatedGroup';

export const DefineCondtion = ({
onClose,
Expand All @@ -33,17 +34,7 @@ export const DefineCondtion = ({
const isMobile = useMediaQuery(device.mobileL);

const verifyAndDoNext = ()=>{
if(entryCriteria.isCondtionUpdateEnabled()){
// handle update
entryCriteria.updateCondition()
}else{
// handle insertion
entryCriteria.addNewCondtion()
}

if(handlePrevious){
handlePrevious()
}
handleDefineCondition(entryCriteria, handlePrevious)
}

const getRules = ()=>{
Expand All @@ -53,6 +44,7 @@ export const DefineCondtion = ({
]
}

// set state for edit condition
useEffect(()=>{
if(entryCriteria.isCondtionUpdateEnabled()){
entryCriteria.setEntryRuleTypeCondition(
Expand All @@ -65,7 +57,7 @@ export const DefineCondtion = ({
])
}
}
},[0])
},[])


return (
Expand All @@ -81,30 +73,12 @@ export const DefineCondtion = ({
/>
{isCriteriaAdded && (
<Section flexDirection="column" gap="16px">
<OptionButtons
options={OPERATOR_OPTIONS}
selectedValue={
entryCriteria.entryRuleTypeCondition
}
handleClick={(newEl: string) => {
<OperatorContainer
operator={entryCriteria.entryRuleTypeCondition}
setOperator={(newEl: string) => {
entryCriteria.setEntryRuleTypeCondition(newEl as keyof typeof OPERATOR_OPTIONS_INFO);
}}
/>
<Span fontSize="14px">
{
OPERATOR_OPTIONS_INFO[
entryCriteria.entryRuleTypeCondition as keyof typeof OPERATOR_OPTIONS_INFO
].head
}
<Span color={theme.textColor?.modalSubHeadingText}>
{' '}
{
OPERATOR_OPTIONS_INFO[
entryCriteria.entryRuleTypeCondition as keyof typeof OPERATOR_OPTIONS_INFO
].tail
}
</Span>
</Span>{' '}
<ConditionsComponent
conditionData={getRules()}
deleteFunction={(idx)=>{
Expand Down
Loading

0 comments on commit 697c9fa

Please sign in to comment.