Skip to content

Instantly share code, notes, and snippets.

View bogdanq's full-sized avatar
👀
hi!

Bogdan Shelomanov bogdanq

👀
hi!
View GitHub Profile
import React from 'react'
import { Text, View } from 'react-native'
import { createAppContainer } from 'react-navigation'
import { createBottomTabNavigator } from 'react-navigation-tabs'
import { createStackNavigator } from 'react-navigation-stack'
export const App = createAppContainer(
createStackNavigator({
Home: () => (
<View style={styles.container}>
@bogdanq
bogdanq / guard.js
Created July 28, 2020 07:12
Компонент скрытия роутов
const Guard = ({
guards = [],
redirect = "/",
exact = true,
component: Component,
pageTitle,
path,
}) => {
const { checkPermissions } = usePermissions();
const { loading } = useUser();
@bogdanq
bogdanq / checkRoles.js
Last active July 28, 2020 07:15
Хелперы для гардов
interface IUserContext {
user: User_user;
}
export function onlyAuth(context: IUserContext) {
return Boolean(context.user);
}
export function onlyAdAgent({ user }: IUserContext) {
if (user && user.roles) {
@bogdanq
bogdanq / useTableSelect.js
Last active January 31, 2023 21:19
Поддержка мультиселекта и одиночного выбора в таблице с подгрузкой данных из сервера
const getElementsPosition = () => {
console.log("ok")
const dimensions = [320, 480, 640, 960, 1200, 1400, 1600];
const nodes = [...document.querySelectorAll("[data-component-id]")];
const availableWidth = window.innerWidth;
const media = dimensions.find((d) => d >= availableWidth);
@bogdanq
bogdanq / ATM.js
Created June 23, 2023 11:10
Задачи собеседований, банкомат, atm
const atm = (sum, limits) => {
const nominals = Object.keys(limits)
.map(Number)
.sort((a, b) => a - b)
const balance = Object.entries(limits).reduce((acc, [key, value]) => acc + key * value, 0)
if (sum > balance) {
return 'Не достатоно денег'
}