ramda#and JavaScript Examples
The following examples show how to use
ramda#and.
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: index.js From web with GNU General Public License v3.0 | 6 votes |
useExposureNotification = () => {
const riskLevel = useSelector(getNativeRiskLevel);
const previousRiskLevel = usePrevious(riskLevel);
const { isEnHigh, isEnMiddle } = useHealthStats();
const [occurredHighEn, setOccurredHighEn] = useState(false);
const [occurredMiddleEn, setOccurredMiddleEn] = useState(false);
useSkippingFirstUpdate(() => {
if (and(isEnHigh, notEquals(riskLevel, previousRiskLevel))) {
setOccurredHighEn(true);
}
if (and(isEnMiddle, notEquals(riskLevel, previousRiskLevel))) {
setOccurredMiddleEn(true);
}
}, [isEnHigh, riskLevel, previousRiskLevel]);
return { occurredHighEn, occurredMiddleEn };
}
Example #2
Source File: index.js From web with GNU General Public License v3.0 | 6 votes |
useLabTest = () => {
const subscriptionStatus = useSelector(getLabTestSubscriptionStatus);
const timeOfUpdatedSubscriptionStatus = useSelector(getTimeOfUpdatedSubscriptionStatus);
const previousSubscriptionStatus = usePrevious(subscriptionStatus);
const [signedUp, setSignedUp] = useState(false);
const isSubscriptionVerified = subscriptionStatus === 1;
const isSubscriptionConfirmed = subscriptionStatus === 2;
const isSubscriptionInProgress = isSubscriptionVerified || isSubscriptionConfirmed;
useSkippingFirstUpdate(() => {
if (and(isSubscriptionConfirmed, notEquals(subscriptionStatus, previousSubscriptionStatus))) {
setSignedUp(true);
}
}, [subscriptionStatus, previousSubscriptionStatus]);
return {
isSubscriptionVerified,
isSubscriptionConfirmed,
isSubscriptionInProgress,
signedUp,
timeOfUpdatedSubscriptionStatus
};
}
Example #3
Source File: index.js From web with GNU General Public License v3.0 | 6 votes |
useTriage = () => {
const {
noTor,
noEn,
isTorLow,
isTorMiddle,
isTorHighNoCovid,
isTorHigCovid,
isEnLow,
isEnMiddle,
isEnHigh
} = useHealthStats();
return {
isTriageTorLow: and(isTorLow, noEn),
isTriageTorMiddle: and(isTorMiddle, noEn),
isTriageTorHighNoCovid: and(isTorHighNoCovid, noEn),
isTriageTorHighCovid: and(isTorHigCovid, noEn),
isTriageEnLow: and(noTor, isEnLow) || and(isTorLow, isEnLow),
isTriageEnMiddle: and(isTorLow, isEnMiddle) || and(isTorMiddle, isEnMiddle) || and(noTor, isEnMiddle),
isTriageEnHigh:
and(isTorHighNoCovid, isEnMiddle) ||
and(isTorHigCovid, isEnMiddle) ||
and(isTorLow, isEnHigh) ||
and(isTorMiddle, isEnHigh) ||
and(isTorHighNoCovid, isEnHigh) ||
and(isTorHigCovid, isEnHigh) ||
and(noTor, isEnHigh),
isTriageTorMiddleEnLow: and(isTorMiddle, isEnLow),
isTriageTorHighNoCovidEnLow: and(isTorHighNoCovid, isEnLow),
isTriageTorHighCovidEnLow: and(isTorHigCovid, isEnLow)
};
}
Example #4
Source File: CallToActionHealthContainer.js From web with GNU General Public License v3.0 | 6 votes |
CallToActionHealthContainer = () => {
const { goTo } = useNavigation();
const { noEn, noTor } = useHealthStats();
if (and(noEn, noTor)) {
return null;
}
return <CallToActionHealth onClick={() => goTo(Routes.Diagnosis)} />;
}
Example #5
Source File: SignedForLabTestContainer.js From web with GNU General Public License v3.0 | 6 votes |
SignedForLabTestContainer = () => {
const { goTo } = useNavigation();
const { isSubscriptionConfirmed } = useLabTest();
const { isTriageEnMiddle, isTriageEnHigh } = useTriage();
const handleLabTestResult = () => goTo(Routes.LabTestResult);
const installPath = (() => {
if (isIOSWebView()) {
return 'https://apps.apple.com/pl/app/kwarantanna-domowa/id1502997499?l=pl';
}
return 'https://play.google.com/store/apps/details?id=pl.nask.droid.kwarantannadomowa';
})();
if (and(or(isTriageEnMiddle, isTriageEnHigh), isSubscriptionConfirmed)) {
return <SignedForLabTest installPath={installPath} handleLabTestResult={handleLabTestResult} />;
}
return null;
}
Example #6
Source File: ToggleButton.container.js From web with GNU General Public License v3.0 | 6 votes |
ToggleButtonContainer = ({ active, onClick }) => {
const { isTriageEnMiddle, isTriageEnHigh } = useTriage();
const color = (() => {
if (and(or(isTriageEnMiddle, isTriageEnHigh), not(active))) {
return Color.white;
}
return Color.primary;
})();
return <ToggleButton onClick={onClick} color={color} active={active} />;
}
Example #7
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 #8
Source File: CustomCallToActionButtonContainer.js From web with GNU General Public License v3.0 | 5 votes |
CustomCallToActionButtonContainer = () => {
const { goTo } = useNavigation();
const { isSubscriptionConfirmed } = useLabTest();
const { isCovidConfirmed, isCovidManual } = useHealthStats();
const {
isTriageTorLow,
isTriageTorMiddle,
isTriageTorHighNoCovid,
isTriageTorHighCovid,
isTriageEnLow,
isTriageEnMiddle,
isTriageEnHigh,
isTriageTorMiddleEnLow,
isTriageTorHighNoCovidEnLow,
isTriageTorHighCovidEnLow
} = useTriage();
const recommendationsText = <T i18nKey="result_analysis_text_26" />;
const recommendationsAction = component => () => goTo(Routes.Recommendations, { component });
const torText = <T i18nKey="result_analysis_text_4" />;
const torAction = () => goTo(Routes.Diagnosis);
const createData = (action, text) => ({ action, text });
const data = (() => {
if (isCovidConfirmed) {
return createData(recommendationsAction(RecommendationsComponents.SickApprove), recommendationsText);
}
if (isCovidManual) {
return createData(recommendationsAction(RecommendationsComponents.SickReported), recommendationsText);
}
if (isTriageTorLow) {
return null;
}
if (or(isTriageTorMiddle, isTriageTorMiddleEnLow)) {
return createData(recommendationsAction(RecommendationsComponents.RiskTestMiddle), recommendationsText);
}
if (or(isTriageTorHighNoCovid, isTriageTorHighNoCovidEnLow)) {
return createData(recommendationsAction(RecommendationsComponents.RiskTestHighNoCovid), recommendationsText);
}
if (or(isTriageTorHighCovid, isTriageTorHighCovidEnLow)) {
return createData(recommendationsAction(RecommendationsComponents.RiskTestHighCovid), recommendationsText);
}
if (isTriageEnLow) {
return null;
}
if (and(isTriageEnMiddle, isSubscriptionConfirmed)) {
return createData(recommendationsAction(RecommendationsComponents.ExposureMiddle), recommendationsText);
}
if (and(isTriageEnMiddle, not(isSubscriptionConfirmed))) {
return createData(recommendationsAction(RecommendationsComponents.ExposureMiddle), recommendationsText);
}
if (and(isTriageEnHigh, isSubscriptionConfirmed)) {
return createData(recommendationsAction(RecommendationsComponents.ExposureHighPinApprove), recommendationsText);
}
if (and(isTriageEnHigh, not(isSubscriptionConfirmed))) {
return createData(recommendationsAction(RecommendationsComponents.ExposureHigh), recommendationsText);
}
return createData(torAction, torText);
})();
if (data === null) {
return null;
}
return <CustomCallToActionButton text={data.text} action={data.action} />;
}
Example #9
Source File: ContentTextContainer.js From web with GNU General Public License v3.0 | 4 votes |
ContentTextContainer = ({ t }) => {
const { lastDate } = useFilledDiagnosis();
const { isSubscriptionConfirmed } = useLabTest();
const { isCovidConfirmed, isCovidManual } = useHealthStats();
const {
isTriageTorLow,
isTriageTorMiddle,
isTriageTorHighNoCovid,
isTriageTorHighCovid,
isTriageEnLow,
isTriageEnMiddle,
isTriageEnHigh,
isTriageTorMiddleEnLow,
isTriageTorHighNoCovidEnLow,
isTriageTorHighCovidEnLow
} = useTriage();
const translatedText = (() => {
if (isCovidConfirmed) {
return <T i18nKey="result_analysis_text_25" />;
}
if (isCovidManual) {
return <T i18nKey="result_analysis_text_27" />;
}
if (isTriageTorLow) {
return <T i18nKey="result_analysis_text_9" />;
}
if (isTriageTorMiddle) {
return (
<T
i18nKey="result_analysis_text_10"
variables={{ date: lastDate, currentState: t('result_analysis_variant_3') }}
/>
);
}
if (isTriageTorMiddleEnLow) {
return (
<T
i18nKey="result_analysis_text_38"
variables={{ date: lastDate, currentState: t('result_analysis_variant_3') }}
/>
);
}
if (isTriageTorHighNoCovid) {
return (
<T
i18nKey="result_analysis_text_12"
variables={{ date: lastDate, currentState: t('result_analysis_variant_4') }}
/>
);
}
if (isTriageTorHighNoCovidEnLow) {
return (
<T
i18nKey="result_analysis_text_39"
variables={{ date: lastDate, currentState: t('result_analysis_variant_4') }}
/>
);
}
if (isTriageTorHighCovid) {
return (
<T
i18nKey="result_analysis_text_23"
variables={{ date: lastDate, currentState: t('result_analysis_variant_4') }}
/>
);
}
if (isTriageTorHighCovidEnLow) {
return (
<T
i18nKey="result_analysis_text_40"
variables={{ date: lastDate, currentState: t('result_analysis_variant_4') }}
/>
);
}
if (isTriageEnLow) {
return <T i18nKey="result_analysis_text_14" />;
}
if (and(isTriageEnMiddle, isSubscriptionConfirmed)) {
return <T i18nKey="result_analysis_text_29" />;
}
if (and(isTriageEnMiddle, not(isSubscriptionConfirmed))) {
return <T i18nKey="result_analysis_text_15" />;
}
if (and(isTriageEnHigh, isSubscriptionConfirmed)) {
return <T i18nKey="result_analysis_text_37" />;
}
if (and(isTriageEnHigh, not(isSubscriptionConfirmed))) {
return <T i18nKey="result_analysis_text_19" />;
}
return <T i18nKey="result_analysis_text_3" />;
})();
return <ContentText translatedText={translatedText} />;
}