Skip to content

Commit

Permalink
Hide range value from send notif page
Browse files Browse the repository at this point in the history
  • Loading branch information
0xNilesh committed Nov 6, 2023
1 parent c194bf6 commit 65bfae7
Showing 1 changed file with 4 additions and 44 deletions.
48 changes: 4 additions & 44 deletions src/components/SendNotifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ function SendNotifications() {
const [nfMedia, setNFMedia] = useState('');
const [nfMediaEnabled, setNFMediaEnabled] = useState(false);
const [nfInfo, setNFInfo] = useState('');
const [nfSettingType, setNFSettingType] = useState(null);
const [nfSettingIndex, setNFSettingIndex] = useState('');
const [delegateeOptions, setDelegateeOptions] = useState([]);
const [nfSliderValue, setNfSliderValue] = useState(0);

Expand All @@ -164,7 +164,7 @@ function SendNotifications() {
}, [channelDetailsFromBackend]);

const channelSettingsOptions = useMemo(() => {
const defaultOption = { label: 'Default', value: null, isRange: false };
const defaultOption = { label: 'Default', value: '', isRange: false };

if (channelSettings) {
const settingsOptions = channelSettings.map((setting) => ({
Expand Down Expand Up @@ -292,14 +292,6 @@ function SendNotifications() {
return validated;
};

const getIndex = () => {
if (nfSettingType === null) return undefined;
else if (channelSettings[nfSettingType - 1]?.type === 1)
return `${nfSettingType}-1`;
else if (channelSettings[nfSettingType - 1]?.type === 2)
return `${nfSettingType}-2-${nfSliderValue}`;
}

const handleSendMessage = async (e) => {
// Check everything in order
e.preventDefault();
Expand Down Expand Up @@ -414,7 +406,7 @@ function SendNotifications() {
body: amsg,
cta: acta,
img: aimg,
index: getIndex(),
index: nfSettingIndex,
},
recipients: notifRecipients, // recipient address
channel: channelAddressInCaip, // your channel address
Expand Down Expand Up @@ -858,44 +850,12 @@ function SendNotifications() {
<DropdownStyled
options={channelSettingsOptions}
onChange={(option) => {
setNFSettingType(option.value);
if(channelSettings[option.value - 1]?.type === 2) {
setNfSliderValue(channelSettings[option.value - 1]?.default);
}
setNFSettingIndex(String(option.value));
}}
value={channelSettingsOptions[0]}
/>
</DropdownStyledParent>
</Item>
{nfSettingType !== null && channelSettings[nfSettingType - 1]?.type === 2 && (
<Item
display="flex"
direction="column"
align="flex-start"
flex="1"
self="stretch"
margin="16px 0px 7px 0px"
>
<Label style={{ color: theme.color, fontWeight: isMobile ? "500" : "600", fontSize: isMobile ? "15px" : "14px", marginBottom: "7px" }}>
Range Value
</Label>
<Item
display="flex"
direction="row"
width="100%"
>
<InputSlider
onChange={({ x }) => setNfSliderValue(x)}
step={channelSettings[nfSettingType - 1]?.ticker || 1}
min={channelSettings[nfSettingType - 1]?.lowerLimit}
max={channelSettings[nfSettingType - 1]?.upperLimit}
defaultVal={channelSettings[nfSettingType - 1]?.default}
val={nfSliderValue}
/>
<SpanV2 color={theme.fontColor} fontSize="16px" fontWeight='500' textAlign="right" margin="0px 0px 0px 16px">{nfSliderValue}</SpanV2>
</Item>
</Item>
)}
</>
)}

Expand Down

0 comments on commit 65bfae7

Please sign in to comment.