ramda#ifElse JavaScript Examples
The following examples show how to use
ramda#ifElse.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExposureNotificationContactDetection.container.js From web with GNU General Public License v3.0 | 6 votes |
ExposureNotificationContactDetectionContainer = () => {
const { goTo } = useNavigation();
const { onClose } = useModalContext();
const { occurredHighEn, occurredMiddleEn } = useExposureNotification();
const handleReceiveLabTest = () => {
onClose();
goTo(Routes.LabTest);
};
const handleBack = () => {
onClose();
goTo(Routes.Home);
};
const resolveData = () => {
if (occurredHighEn) {
return { color: Color.red, icon: <EnHighIcon /> };
}
if (occurredMiddleEn) {
return { color: Color.info, icon: <EnMiddleIcon /> };
}
return { color: Color.white, icon: null };
};
const renderComponent = () => (
<ExposureNotificationContactDetection
data={resolveData()}
handleReceiveLabTest={handleReceiveLabTest}
handleBack={handleBack}
/>
);
const renderEmptyView = () => null;
return ifElse(() => or(occurredHighEn, occurredMiddleEn), renderComponent, renderEmptyView)();
}
Example #2
Source File: RatingAppContainer.js From web with GNU General Public License v3.0 | 6 votes |
RatingAppContainer = () => {
const dispatch = useDispatch();
const showRatingApp = useShowRatingApp();
const handleLikeApp = () => {
dispatch(rateApplication(true));
};
const handleDislikeApp = () => {
dispatch(rateApplication(false));
};
const handleClose = () => {
dispatch(rateApplicationShowed()).then(() => {
const days30AfterNow = addDays(getTimestamp(), 30);
dispatch(setShowingRateApplication(days30AfterNow));
});
};
const renderComponent = () => (
<RatingApp handleYes={handleLikeApp} handleNo={handleDislikeApp} handleClose={handleClose} />
);
const renderEmptyView = () => null;
return ifElse(() => showRatingApp, renderComponent, renderEmptyView)();
}
Example #3
Source File: rendering.js From web with GNU General Public License v3.0 | 5 votes |
renderWhen = (pred, fn, otherwise = always(null)) =>
ifElse(pred, fn, otherwise)
Example #4
Source File: CallToActionPinContainer.js From web with GNU General Public License v3.0 | 5 votes |
CallToActionPinContainer = () => {
const { goTo } = useNavigation();
const { isCovidConfirmed } = useHealthStats();
const {
areEnableAllServices,
handleEnableServices,
receivedServicesMarker
} = useSupportExposureNotificationTracing();
const [pressed, setPressed] = useState(false);
const handlePressed = ifElse(
() => areEnableAllServices,
() => goTo(Routes.UploadHistoricalData),
handleEnableServices
);
const handleChangeServices = ifElse(
() => and(areEnableAllServices, pressed),
() => goTo(Routes.UploadHistoricalData),
() => setPressed(false)
);
useEffect(() => {
if (not(pressed)) {
return;
}
handlePressed();
// eslint-disable-next-line
}, [pressed]);
useEffect(() => {
handleChangeServices();
// eslint-disable-next-line
}, [receivedServicesMarker]);
if (isCovidConfirmed) {
return null;
}
return <CallToActionPin onClick={() => setPressed(true)} />;
}
Example #5
Source File: helpers.js From sdk with MIT License | 5 votes |
ownProp = ifElse(has, prop, always(void 0))