repo_name
stringlengths
5
122
path
stringlengths
3
232
text
stringlengths
6
1.05M
skimah/skimah
packages/ds-csv/src/csv.ts
import JSONRecords from "@skimah/ds-json"; import { csvParse } from "d3-dsv"; export interface Config { /** * The path of the csv file that should be loaded */ filepath?: string; /** * CSV text that should be used in lieu of a file */ records?: string; } export default class CSVRecords extends JS...
skimah/skimah
packages/ds-faker/test/faker.test.ts
import { generate, SkimahConfig } from "@skimah/api"; import { graphql } from "graphql"; import SampleSource from "../src/faker"; const typeDefs = ` type Manager @datasource(name: "sample") { id: ID firstName: String @named(as: "FirstName_name_firstName") lastName: String @named(as: "LastName_name_lastNa...
skimah/skimah
packages/ds-faker/src/faker.ts
import { Attribute, Datasource, Model, MutationModel, MutationResponse, QueryModel, Criteria } from "@skimah/api"; import JSONRecords from "@skimah/ds-json"; import faker from "faker"; export interface Config { /** * Maximum number of records to be generated for each type */ recordMaximum: numb...
skimah/skimah
packages/api/src/types.ts
import { GraphQLResolveInfo, GraphQLSchema } from "graphql"; import { InterfaceTypeComposer, ObjectTypeComposer, SchemaComposer } from "graphql-compose"; /** * @internal */ export type AttributeType = "String" | "Float" | "Int" | "Boolean" | "ID"; /** * @internal */ export type GraphqlResolver = ( parent:...
skimah/skimah
packages/api/test/resolvers/update.test.ts
<gh_stars>1-10 import generate from "../../src/generate"; import { Datasource } from "../../src/types"; import { graphql } from "graphql"; const typeDefs = ` type User { userid: ID age: Int height: Float avatar: Avatar @relation } type Avatar { id: ID url: Stri...
skimah/skimah
packages/api/src/response.ts
import { getPluralName, ObjectTypeComposer, SchemaComposer } from "graphql-compose"; /** @internal */ export default (tc: ObjectTypeComposer, composer: SchemaComposer<any>) => { const typeName = tc.getTypeName(); const pluralNames = getPluralName(typeName); composer.getOrCreateOTC(`${typeName}MutationResp...
skimah/skimah
packages/api/src/orderby.ts
/** * This will generate an input OrderBy with _OrderBy enum for each model type in the * type definition * * e.g * type User { * name: String * age: Float * } * * This model will generate * * UserOrderBy { * name: _OrderBy * age: _OrderBy * } */ import { InputTypeComposerFieldConfigDefinition,...
skimah/skimah
packages/api/src/resolvers/update.ts
import { getPluralName } from "graphql-compose"; import { parseResolveInfo, ResolveTree } from "graphql-parse-resolve-info"; import { ResolverDefinition } from "./index"; import createCreation from "../models/creation"; import { argsToCriteria } from "../models/selection"; /** * @internal * @param definition */ ex...
skimah/skimah
packages/api/test/models/selection.test.ts
import { graphql } from "graphql"; import generate from "../../src/generate"; import { QueryModel, Datasource } from "../../src/types"; const typeDefs = ` type User { userid: ID email: String username: String age: Int videos: [Video] @relation(field: "publisher") } ...
skimah/skimah
packages/api/src/models/base.ts
<reponame>skimah/skimah import { ComposeNamedOutputType, DirectiveArgs, ObjectTypeComposerFieldConfig, schemaComposer, unwrapOutputTC } from "graphql-compose"; import { Attribute, AttributeType, DefinedType, Model, Relation, RelationCondition } from "../types"; const isFieldUnique = ( /* eslint...
skimah/skimah
packages/api/test/response.test.ts
import generate from "../src/generate"; import { Datasource } from "../src/types"; const typeDefs = ` type User { userid: Int @unique firstName: String lastName: String emails: [String] } `; describe("Schema Mutation", () => { const defaultSource: Datasource = { select: j...
skimah/skimah
packages/api/test/input.test.ts
<filename>packages/api/test/input.test.ts import { Datasource } from "../src/types"; import generate from "../src/generate"; const typeDefs = ` type User { userid: Int @unique firstName: String lastName: String emails: [String] profile: Profile @relation(field: "user", isOw...
skimah/skimah
packages/api/src/resolvers/find.ts
import { getPluralName } from "graphql-compose"; import { parseResolveInfo, ResolveTree } from "graphql-parse-resolve-info"; import createSelection from "../models/selection"; import { ResolverDefinition } from "./index"; import { RelationCondition } from "../types"; /** * @internal * Creates a find{Type}s resolver ...
skimah/skimah
packages/ds-faker/src/index.ts
export { default } from "./faker"; export { Config } from "./faker";
skimah/skimah
packages/api/src/resolvers/delete.ts
<gh_stars>1-10 import { getPluralName } from "graphql-compose"; import { parseResolveInfo, ResolveTree } from "graphql-parse-resolve-info"; import createSelection, { argsToCriteria } from "../models/selection"; import { ResolverDefinition } from "./index"; /** * @internal * Delete model resolver * * @summary * Th...
skimah/skimah
packages/ds-csv/src/index.ts
export { default } from "./csv"; export { Config } from "./csv";
skimah/skimah
example/index.ts
<filename>example/index.ts import { generate } from "@skimah/api"; import CsvSource from "@skimah/ds-csv"; import JsonSource from "@skimah/ds-json"; import { graphql } from "graphql"; const users = new CsvSource({ records: `id,user_name 1,james `, }); const tasks = new JsonSource({ records: [ { id...
skimah/skimah
packages/api/test/orderby.test.ts
import { schemaComposer, ObjectTypeComposer } from "graphql-compose"; import addOrderby from "../src/orderby"; const typeDefs = ` type User { userid: Int firstName: String lastName: String } `; describe("Schema Orderby", () => { test("confirms order by", () => { const ts = schema...
skimah/skimah
packages/api/src/inputs.ts
import { DirectiveArgs, ObjectTypeComposer, SchemaComposer } from "graphql-compose"; /** @internal */ export default (tc: ObjectTypeComposer, composer: SchemaComposer<any>) => { const itc = composer.getOrCreateITC(`${tc.getTypeName()}Input`, itc => { itc.merge(tc.getITC()); }); for (const [fieldName, ...
skimah/skimah
packages/ds-json/src/json.ts
<reponame>skimah/skimah import { Attribute, Criteria, CriteriaFilter, Datasource, Model, MutationModel, MutationResponse, QueryModel } from "@skimah/api"; import sift from "./sift"; export interface Config { /** * The path of the csv file that should be loaded */ filepath?: string; /** ...
skimah/skimah
packages/api/src/models/utils.ts
import { ResolveTree } from "graphql-parse-resolve-info"; import { Attribute, Model, Relation } from "../types"; interface ModelArg { baseModel: Model; models: { [key: string]: Model }; tree: ResolveTree; } /** * Convert a graphql selectionSet to * */ export const graphFieldsToModel = ({ tree, baseModel,...
jwworth/typescript-node-module-starter
__tests__/index.test.ts
<reponame>jwworth/typescript-node-module-starter import { exampleFunction } from '../src/index'; test('exampleFunction/1', () => { expect(exampleFunction('Jake')).toMatch('Hello, Jake!'); });
luucasfarias/desafio_ceuma
managerapi-ui/src/app/students/student-search/student-search.component.ts
import { Component, OnInit, ViewChild } from '@angular/core'; import { StudentService, StudentFilter } from '../student.service'; import { LazyLoadEvent, ConfirmationService } from 'primeng/primeng'; import { ToastyService } from 'ng2-toasty'; import { ErrorHandlerService } from 'app/core/error-handler.service'; import...
luucasfarias/desafio_ceuma
managerapi-ui/src/app/courses/courses.service.ts
import { Injectable } from '@angular/core'; import 'rxjs/add/operator/toPromise'; import { Course } from 'app/core/model'; import * as moment from 'moment'; import { AuthHttp } from 'angular2-jwt'; import { environment } from 'environments/environment'; @Injectable() export class CoursesService { courseUrl: string...
luucasfarias/desafio_ceuma
managerapi-ui/src/app/courses/course-form/course-form.component.ts
<reponame>luucasfarias/desafio_ceuma<filename>managerapi-ui/src/app/courses/course-form/course-form.component.ts import { Component, OnInit } from '@angular/core'; import { CoursesService } from '../courses.service'; import { ToastyService } from 'ng2-toasty'; import { ConfirmationService } from 'primeng/primeng'; impo...
luucasfarias/desafio_ceuma
managerapi-ui/src/app/app-rounting.module.ts
<gh_stars>0 import { RouterModule, Routes } from '@angular/router'; import { NgModule } from '@angular/core'; import { CardComponent } from './core/card/card.component'; import { StudentSearchComponent } from './students/student-search/student-search.component'; import { StudentFormComponent } from './students/student-...
luucasfarias/desafio_ceuma
managerapi-ui/src/app/security/security.module.ts
<filename>managerapi-ui/src/app/security/security.module.ts<gh_stars>0 import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { LoginComponent } from './login/login.component'; import { InputTextModule, ButtonModule } from 'primeng/primeng'; import { FormsModule } from '@angula...
luucasfarias/desafio_ceuma
managerapi-ui/src/app/security/login/login.component.ts
import { Component, OnInit } from '@angular/core'; import { AuthService } from '../auth.service'; import { ErrorHandlerService } from 'app/core/error-handler.service'; import { Router } from '@angular/router'; @Component({ selector: 'app-login', templateUrl: './login.component.html', styleUrls: ['./login.compone...
luucasfarias/desafio_ceuma
managerapi-ui/src/app/core/model.ts
export class Address { public_place: string; house_number: string; complement: string; neighborhood: string; cep: string; city: string; state: string; } export class Course { id: number; name: string; dateRegister: Date; workload: string; } export class Student { id: number; name: string; ...
luucasfarias/desafio_ceuma
managerapi-ui/src/app/courses/courses.module.ts
import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; import { DialogModule, InputTextModule, ButtonModule, DataTableModule, TooltipModule } from 'primeng/primeng'; import { BrowserAnimationsModule } from '@angular/platform-browser/animat...
luucasfarias/desafio_ceuma
managerapi-ui/src/environments/environment.prod.ts
<reponame>luucasfarias/desafio_ceuma export const environment = { production: true, // Adding url de servidor de prodution apiURL: 'https://ceuma-api.com' };
luucasfarias/desafio_ceuma
managerapi-ui/src/app/app.module.ts
import { AppComponent } from './app.component'; import { HttpModule } from '@angular/http'; import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { CoreModule } from './core/core.module...
luucasfarias/desafio_ceuma
managerapi-ui/src/app/security/auth.service.ts
import { Injectable } from '@angular/core'; import { Http, Headers } from '@angular/http'; import 'rxjs/add/operator/toPromise'; import { JwtHelper } from 'angular2-jwt'; import { environment } from 'environments/environment'; @Injectable() export class AuthService { [x: string]: any; urlTokenJWT: string; jwtP...
luucasfarias/desafio_ceuma
managerapi-ui/src/app/students/student.service.ts
<gh_stars>0 import { Injectable } from '@angular/core'; import { URLSearchParams } from '@angular/http'; import 'rxjs/add/operator/toPromise'; import { Student } from 'app/core/model'; import { AuthHttp } from 'angular2-jwt'; import { environment } from 'environments/environment'; export class StudentFilter { nameS...
luucasfarias/desafio_ceuma
managerapi-ui/src/app/core/core.module.ts
import { CommonModule } from '@angular/common'; import { NgModule, LOCALE_ID } from '@angular/core'; import { ToastyModule } from 'ng2-toasty'; import { ConfirmDialogModule, ConfirmationService } from 'primeng/primeng'; import { NavbarComponent } from './navbar/navbar.component'; import { ErrorHandlerService } from '...
luucasfarias/desafio_ceuma
managerapi-ui/src/app/students/students.module.ts
import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { StudentSearchComponent } from './student-search/student-search.component'; import { FormsModule } from '@angular/forms'; import { InputTextModule, ButtonModule, DataTableModule, TooltipModule, DialogModule, DropdownMo...
luucasfarias/desafio_ceuma
managerapi-ui/src/app/courses/course-search/course-search.component.ts
<gh_stars>0 import { Component, OnInit } from '@angular/core'; import { CoursesService } from '../courses.service'; import { ToastyService } from 'ng2-toasty'; import { ConfirmationService } from 'primeng/primeng'; import { ErrorHandlerService } from 'app/core/error-handler.service'; import { Course } from 'app/core/mo...
luucasfarias/desafio_ceuma
managerapi-ui/src/app/students/student-form/student-form.component.ts
import { Component, OnInit } from '@angular/core'; import { CoursesService } from 'app/courses/courses.service'; import { ErrorHandlerService } from 'app/core/error-handler.service'; import { Student } from 'app/core/model'; import { FormControl } from '@angular/forms'; import { StudentService } from '../student.servic...
luucasfarias/desafio_ceuma
managerapi-ui/src/app/core/not-authorized.component.ts
import { Component, OnInit } from '@angular/core'; @Component({ selector: 'app-page-not-found', template: ` <div class="container"> <div class="ui-g-12"> <a routerLink="/home" class="back">Voltar</a> </div> <h1 class="text-center">Acesso negado!</h1> </div> `, styles: [] }) e...
luucasfarias/desafio_ceuma
managerapi-ui/src/app/core/error-handler.service.ts
<gh_stars>0 import { Injectable } from '@angular/core'; import { Response } from '@angular/http'; import { ToastyService } from 'ng2-toasty'; import { Router } from '@angular/router'; import { NotAuthenticatedError } from 'app/security/ceuma-http'; @Injectable() export class ErrorHandlerService { constructor(privat...
vishwanathovi/portfolio
src/pages/index.tsx
import * as React from 'react'; import Helmet from 'react-helmet'; import { Intro } from 'components/intro/Intro'; import { Highlight } from 'components/intro/Highlight'; import { Button } from 'components/button/Button'; import { FooterSpaceFiller } from 'components/footer-filler/FooterSpaceFiller'; import { BulletSe...
vishwanathovi/portfolio
src/components/footer/Footer.tsx
<gh_stars>0 import * as React from 'react'; import { Container } from 'components/container/Container'; const siteLogo = require('assets/images/vishwa.png'); import s from './Footer.scss'; interface ISocial { icon: React.ReactNode; to: string; } interface IFooterProps { logo: React.ReactNode; social: ISocia...
vishwanathovi/portfolio
src/components/bullet-section/BulletSection.tsx
import * as React from 'react'; import { Container } from 'components/container/Container'; import { Row } from 'components/row/Row'; import s from './BulletSection.scss'; interface IBlockTextProps { heading: string; bullets: any; bullet: object; } export const BulletSection = ({ heading, bullets }: IBlockTe...
vishwanathovi/portfolio
src/components/footer-filler/FooterSpaceFiller.tsx
import * as React from 'react'; import s from './FooterSpaceFiller.scss'; export const FooterSpaceFiller = () => ( <div className={s.footer_space_filler}></div> );
arvitaly/freeport-es6
__tests__/freeport-test.ts
<gh_stars>0 import freeport from "./.."; describe("FreePort", () => { it("get port", async () => { const port = await freeport(); expect(port > 0).toBeTruthy(); }); });
arvitaly/freeport-es6
index.ts
<filename>index.ts import { AddressInfo, createServer } from "net"; export default async () => { return new Promise<number>((resolve, reject) => { const server = createServer(); let port: number; server.once("listening", () => { const address = server.address() as AddressInfo; port = address.p...
ericloureiro/schedules-challenge
client/src/types/utils.ts
<filename>client/src/types/utils.ts import { ReactNode } from 'react'; /* eslint-disable @typescript-eslint/no-explicit-any */ export type WithChildren<P = {}> = P & { children?: ReactNode; }; export type None = null | undefined; export type EmptyObject = Record<string, never>; export type ObjectOfAny = Record<st...
ericloureiro/schedules-challenge
client/src/hooks/useQueryData.ts
import constate from 'constate'; import { useState } from 'react'; import { getAllLogs } from 'src/api/logs'; import { getAllSchedules, toggleSchedule } from 'src/api/schedules'; import { LogsList } from 'src/types/logs'; import { Schedule, SchedulesList } from 'src/types/schedules'; type State = { selectedSchedule?...
ericloureiro/schedules-challenge
client/src/types/schedules.ts
<reponame>ericloureiro/schedules-challenge import { Interval } from 'src/types/interval'; export type Schedule = { id: number; name: string; description: string; isRetired: boolean; tasksCount: number; startPoint: string; endPoint: string; dayOfWeek: number; dayOfMonth: number; startDate: string; ...
ericloureiro/schedules-challenge
client/src/types/status.ts
export type Status = 'Pending' | 'Running' | 'Terminated' | 'Completed' | 'Exception';
ericloureiro/schedules-challenge
client/src/tests/customRender.tsx
<reponame>ericloureiro/schedules-challenge import React from 'react'; import { render } from '@testing-library/react'; import { ReactElement } from 'react'; import { renderHook } from '@testing-library/react-hooks'; import { QueryDataProvider } from 'src/hooks/useQueryData'; import { WithChildren } from 'src/types/util...
ericloureiro/schedules-challenge
client/src/constants/common.ts
export const HEADER_HEIGHT = 108;
ericloureiro/schedules-challenge
client/src/api/__tests__/fetch.spec.ts
<gh_stars>0 import { fetchApi } from 'src/api/fetch'; import { BASE_URL } from 'src/constants/config'; describe('fetch', () => { const mockUrl = ''; it('should return response as Object', async () => { fetchMock.once(JSON.stringify({}), { url: BASE_URL }); const response = await fetchApi<Object>(mockUrl)...
ericloureiro/schedules-challenge
client/src/tests/factories/interval.ts
import range from 'lodash.range'; import { Interval } from 'src/types/interval'; // TODO: add randomness to Interval enum // const interval = (): Interval => getRandomEnumValue(Status); const interval = (): Interval => 'Day'; const IntervalFactory = { create: () => interval(), createMany: (count = 5) => range(cou...
ericloureiro/schedules-challenge
client/src/components/LogsList.tsx
<reponame>ericloureiro/schedules-challenge<gh_stars>0 import { Grid } from '@mui/material'; import React from 'react'; import PaddedTypography from 'src/components-shared/PaddedTypography'; import LogCard from 'src/components/LogCard'; import { LogsList as LogListType } from 'src/types/logs'; import { Schedule } from '...
ericloureiro/schedules-challenge
client/src/tests/factories/schedules.ts
import { Schedule } from 'src/types/schedules'; import faker from '@faker-js/faker'; import range from 'lodash.range'; import IntervalFactory from 'src/tests/factories/interval'; const scheduleBody = (params = {}): Schedule => ({ id: faker.datatype.number(), dayOfWeek: faker.datatype.number(), dayOfMonth: faker....
ericloureiro/schedules-challenge
client/src/tests/factories/logs.ts
import faker from '@faker-js/faker'; import range from 'lodash.range'; import StatusFactory from 'src/tests/factories/status'; import { Log } from 'src/types/logs'; const logBody = (params = {}): Log => ({ id: faker.datatype.number(), scheduleId: faker.datatype.number(), serverName: faker.commerce.productName(),...
ericloureiro/schedules-challenge
client/src/api/__tests__/schedules.spec.ts
import { getAllSchedules, toggleSchedule } from 'src/api/schedules'; import { SCHEDULES } from 'src/constants/api'; import { BASE_URL } from 'src/constants/config'; import SchedulesFactory from 'src/tests/factories/schedules'; import { mockSchedules } from 'src/tests/mocks'; describe('schedules', () => { it('should ...
ericloureiro/schedules-challenge
client/src/App.tsx
import React, { useEffect, useState } from 'react'; import ScrollableGrid from 'src/components-shared/ScrollableGrid'; import { useQueryDataContext } from 'src/hooks/useQueryData'; import PaddedTypography from 'src/components-shared/PaddedTypography'; import LogsList from 'src/components/LogsList'; import SchedulesList...
ericloureiro/schedules-challenge
client/src/tests/factories/status.ts
import { Status } from 'src/types/status'; import range from 'lodash.range'; // TODO: add randomness to Status enum // const statusBody = (): Status => getRandomEnumValue(Status); const statusBody = (): Status => 'Completed'; const StatusFactory = { create: () => statusBody(), createMany: (count = 5) => range(cou...
ericloureiro/schedules-challenge
client/src/api/__tests__/logs.spec.ts
import { getAllLogs } from 'src/api/logs'; import { SCHEDULE_LOGS } from 'src/constants/api'; import { BASE_URL } from 'src/constants/config'; import { mockLogs } from 'src/tests/mocks'; describe('logs', () => { it('should GET all logs', async () => { fetchMock.once(JSON.stringify(mockLogs), { url: BASE_URL + '/...
ericloureiro/schedules-challenge
client/src/components-shared/ScrollableGrid.tsx
import styled from '@emotion/styled'; import { Grid } from '@mui/material'; import { HEADER_HEIGHT } from 'src/constants/common'; const ScrollableGrid = styled(Grid)({ maxHeight: `calc(100vh - ${HEADER_HEIGHT}px)`, justifyContent: 'center', overflow: 'auto', }); export default ScrollableGrid;
ericloureiro/schedules-challenge
client/src/styles.ts
import styled from '@emotion/styled'; import { Grid } from '@mui/material'; const grey = '#282c34'; export const AppContainer = styled(Grid)` overflow: hidden; height: 100vh; width: 100vw; background-color: ${grey}; `;
ericloureiro/schedules-challenge
client/src/components/ScheduleCard.tsx
import styled from '@emotion/styled'; import { Card, CardActionArea, CardActions, CardContent, CardHeader, Chip, Divider, IconButton, Stack, Typography, } from '@mui/material'; import StarBorderIcon from '@mui/icons-material/StarBorder'; import StarIcon from '@mui/icons-material/Star'; import React,...
ericloureiro/schedules-challenge
client/src/components-shared/PaddedTypography.tsx
import styled from '@emotion/styled'; import { Typography } from '@mui/material'; const PaddedTypography = styled(Typography)({ padding: 16, }); export default PaddedTypography;
ericloureiro/schedules-challenge
client/src/components/LogCard.tsx
<gh_stars>0 import styled from '@emotion/styled'; import { Card, CardActions, CardContent, Chip, Typography } from '@mui/material'; import React from 'react'; import { ChipColor } from 'src/types/colors'; import { Log } from 'src/types/logs'; import { Status } from 'src/types/status'; type Props = { log: Log; }; co...
ericloureiro/schedules-challenge
client/src/types/logs.ts
import { Status } from 'src/types/status'; export type Log = { id: number; startTime: string; endTime: string; status: Status; serverName: string; scheduleId: number; }; export type LogsList = Log[];
ericloureiro/schedules-challenge
client/src/components/__tests__/SchedulesList.spec.tsx
import React from 'react'; import SchedulesList from 'src/components/SchedulesList'; import { render } from 'src/tests/customRender'; import SchedulesFactory from 'src/tests/factories/schedules'; const mockSelectSchedule = jest.fn(); const mockToggleScheduleRetire = jest.fn(); const mockSchedules = SchedulesFactory.cr...
ericloureiro/schedules-challenge
client/jest.config.ts
<filename>client/jest.config.ts import type { Config } from '@jest/types'; const config: Config.InitialOptions = { verbose: true, setupFilesAfterEnv: ['<rootDir>/src/tests/setup.tsx'], moduleDirectories: ['node_modules', 'src'], moduleFileExtensions: ['ts', 'tsx', 'js'], rootDir: './', testEnvironment: 'js...
ericloureiro/schedules-challenge
client/src/tests/utils.ts
<reponame>ericloureiro/schedules-challenge<filename>client/src/tests/utils.ts export const getRandomEnum = <T extends object>(anEnum: T): T[keyof T] => { const enumValues = Object.keys(anEnum) .filter((key) => typeof anEnum[key as keyof typeof anEnum] === 'number') .map((key) => key); const randomIndex = M...
ericloureiro/schedules-challenge
client/src/components/SearchInput.tsx
import { TextField } from '@mui/material'; import React from 'react'; import throttle from 'lodash/throttle'; type Props = { label: string; onChange: (term: string) => void; }; const SearchInput = (props: Props) => { const { onChange, label } = props; const searchTermDebounce = throttle(onChange, 1500); c...
ericloureiro/schedules-challenge
client/src/utils/__tests__/isEmpty.spec.ts
import isEmpty from 'src/utils/isEmpty'; describe('isEmpty', () => { it('return true with empty object', () => { expect(isEmpty({})).toEqual(true); }); it('return true with empty array', () => { expect(isEmpty([])).toEqual(true); }); it('return true with null or undefined', () => { expect(isEmp...
ericloureiro/schedules-challenge
client/src/hooks/__tests__/useQueryData.spec.ts
import { act } from 'react-test-renderer'; import { useQueryDataContext } from 'src/hooks/useQueryData'; import { renderHook } from 'src/tests/customRender'; import { mockLogs, mockSchedules } from 'src/tests/mocks'; import { Schedule } from 'src/types/schedules'; const mockGetAllLogs = jest.fn(() => Promise.resolve(m...
ericloureiro/schedules-challenge
client/src/api/fetch.ts
<reponame>ericloureiro/schedules-challenge<filename>client/src/api/fetch.ts import { BASE_URL } from 'src/constants/config'; export const fetchApi = async <T>(params: string, init?: RequestInit) => { const response = await fetch(BASE_URL + params, init); if (!response.ok) throw Error(response.statusText); cons...
ericloureiro/schedules-challenge
client/src/types/declarations/theme.d.ts
<reponame>ericloureiro/schedules-challenge<gh_stars>0 import { Theme } from '@material-ui/core'; declare module '@material-ui/styles' { interface DefaultTheme extends Theme {} } declare module '@material-ui/core/styles' { interface Theme extends DefaultTheme { status: { danger: string; }; } // a...
ericloureiro/schedules-challenge
client/src/components/SchedulesList.tsx
<filename>client/src/components/SchedulesList.tsx import { Grid } from '@mui/material'; import React, { useMemo } from 'react'; import PaddedTypography from 'src/components-shared/PaddedTypography'; import ScheduleCard from 'src/components/ScheduleCard'; import { Schedule, SchedulesList as SchedulesListType } from 'src...
ericloureiro/schedules-challenge
client/src/api/logs.ts
import { fetchApi } from 'src/api/fetch'; import { SCHEDULE_LOGS } from 'src/constants/api'; import { LogsList } from 'src/types/logs'; export const getAllLogs = () => fetchApi<LogsList>(SCHEDULE_LOGS);
ericloureiro/schedules-challenge
client/src/types/interval.ts
<gh_stars>0 export type Interval = 'Never' | 'Once' | 'Hour' | 'Day' | 'Week' | 'Month' | 'Year' | 'Minute' | 'Second';
ericloureiro/schedules-challenge
client/src/components/__tests__/ScheduleCard.spec.tsx
<filename>client/src/components/__tests__/ScheduleCard.spec.tsx import React from 'react'; import ScheduleCard from 'src/components/ScheduleCard'; import { render } from 'src/tests/customRender'; import SchedulesFactory from 'src/tests/factories/schedules'; import { fireEvent } from '@testing-library/react'; describe(...
ericloureiro/schedules-challenge
client/src/tests/mocks.ts
import LogsFactory from 'src/tests/factories/logs'; import SchedulesFactory from 'src/tests/factories/schedules'; export const mockLogs = LogsFactory.createMany(5); export const mockSchedules = SchedulesFactory.createMany(5);
ericloureiro/schedules-challenge
client/src/constants/api.ts
export const SCHEDULE_LOGS = 'scheduleLogs'; export const SCHEDULES = 'schedules';
ericloureiro/schedules-challenge
client/src/api/schedules.ts
<reponame>ericloureiro/schedules-challenge<filename>client/src/api/schedules.ts<gh_stars>0 import { fetchApi } from 'src/api/fetch'; import { SCHEDULES } from 'src/constants/api'; import { Schedule, SchedulesList } from 'src/types/schedules'; export const getAllSchedules = () => fetchApi<SchedulesList>(SCHEDULES); ex...
ericloureiro/schedules-challenge
client/src/utils/isEmpty.ts
<filename>client/src/utils/isEmpty.ts import { Empty, ObjectOfAny } from 'src/types/utils'; const isEmpty = (value: unknown): value is Empty => { if (value == null) { return true; } if (Array.isArray(value) && value.length === 0) { return true; } if (typeof value === 'object' && Object.keys(value a...
matthewpwilson/refarch-kc-ui
server/test/ProblemProducer.ts
// A class to send a problem to the bluewaterProblem topic import * as domain from '../routes/fleetDomain'; import AppConfig from '../config/AppConfig'; const kafka = require('kafka-node'); var Producer = kafka.Producer; declare const Buffer; export default class ProblemProducer { config:AppConfig; producer:...
khoadaxne15/LastProject
src/redux/actions/userActions.ts
<reponame>khoadaxne15/LastProject import actionCreatorFactory from "typescript-fsa"; import { User } from "../reducers/userReducer"; const factory = actionCreatorFactory("USER"); // insert in profile array export const registerUser = factory<RegisterUserPayload>("REGISTER_USER"); export type RegisterUserPayload = st...
khoadaxne15/LastProject
src/components/product/ProductFeatured.tsx
import React from "react"; import Skeleton, { SkeletonTheme } from "react-loading-skeleton"; import { useHistory } from "react-router-dom"; import { Product } from "../../redux"; import { ImageLoader } from "../common"; export const ProductFeatured: React.FC<ProductFeaturedProps> = ({ product }) => { const history ...
khoadaxne15/LastProject
src/redux/actions/filterActions.ts
<filename>src/redux/actions/filterActions.ts<gh_stars>0 import actionCreatorFactory from "typescript-fsa"; import { Filter } from "../reducers"; const factory = actionCreatorFactory("FILTER"); export const setTextFilter = factory<SetTextFilterPayload>("SET_TEXT_FILTER"); export type SetTextFilterPayload = string; e...
khoadaxne15/LastProject
src/components/product/ProductGrid.tsx
import React from "react"; import { useBasket } from "../../hooks"; import { Product } from "../../redux"; import { ProductItem } from "./ProductItem"; export const ProductGrid: React.FC<ProductGridProps> = ({ products }) => { const { addToBasket, isItemOnBasket } = useBasket(); return ( <div className="pro...
khoadaxne15/LastProject
src/redux/actions/miscActions.ts
import actionCreatorFactory from "typescript-fsa"; const factory = actionCreatorFactory("MISC"); export const setLoading = factory<SetLoadingPayload>("LOADING"); export type SetLoadingPayload = boolean; export const setAuthenticating = factory<SetAuthenticatingPayload>("IS_AUTHENTICATING"); export type SetAuthenticat...
khoadaxne15/LastProject
src/components/common/Badge.tsx
import React from "react"; export const Badge: React.FC<BadgeProps> = ({ count, children }) => ( <div className="badge"> {children} {count >= 1 && <span className="badge-count">{count}</span>} </div> ); type BadgeProps = { count: number; children: React.ReactNode | React.ReactNode[]; };
khoadaxne15/LastProject
src/constants/routes.ts
export const HOME = "/"; export const SHOP = "/shop"; export const FEATURED_PRODUCTS = "/featured"; export const RECOMMENDED_PRODUCTS = "/recommended"; export const ACCOUNT = "/account"; export const ACCOUNT_EDIT = "/account/edit"; export const ADMIN_DASHBOARD = "/admin/dashboard"; export const ADMIN_PRODUCTS = "/admin...
khoadaxne15/LastProject
src/routers/ClientRoute.tsx
import React from "react"; import { connect } from "react-redux"; import { Redirect, Route } from "react-router-dom"; import { ADMIN_DASHBOARD, SIGNIN } from "../constants"; import { AppState } from "../redux"; const _ClientRoute: React.FC<ClientRouteProps> = ({ isAuth, role, component: Component, ...rest }) => ( <...
khoadaxne15/LastProject
src/views/account/components/index.ts
<reponame>khoadaxne15/LastProject<filename>src/views/account/components/index.ts export * from "./UserAccountTab"; export * from "./UserAvatar"; export * from "./UserOrdersTab"; export * from "./UserTab"; export * from "./UserWishListTab";
khoadaxne15/LastProject
src/components/common/SearchBar.tsx
import { SearchOutlined } from "@ant-design/icons"; import React, { useRef, useState } from "react"; import { useDispatch, useSelector } from "react-redux"; import { useHistory } from "react-router-dom"; import { AppState, clearRecentSearch, FilterState, removeSelectedRecent } from "../../redux"; export const SearchB...
khoadaxne15/LastProject
src/views/auth/signin/index.tsx
<reponame>khoadaxne15/LastProject import { ArrowRightOutlined, LoadingOutlined } from "@ant-design/icons"; import { Field, Form, Formik } from "formik"; import React, { useEffect } from "react"; import { useDispatch, useSelector } from "react-redux"; import { Link } from "react-router-dom"; import * as Yup from "yup"...
khoadaxne15/LastProject
src/components/basket/BasketItem.tsx
import { CloseOutlined } from "@ant-design/icons"; import React from "react"; import { useDispatch } from "react-redux"; import { Link } from "react-router-dom"; import { displayMoney } from "../../helpers"; import { Product, removeFromBasket } from "../../redux"; import { ImageLoader } from "../common"; import { Bas...
khoadaxne15/LastProject
src/redux/reducers/authReducer.ts
<filename>src/redux/reducers/authReducer.ts import { AnyAction } from "typescript-fsa"; import { signIn, signOut } from "../actions"; export type AuthState = { id: string; role: string; provider?: string; } | null; export function authReducer(state: AuthState | undefined, action: AnyAction): AuthState { if (...
khoadaxne15/LastProject
src/components/common/PriceRange/Tick.tsx
import React from "react"; export const Tick: React.FC<TickProps> = ({ tick, count, format }) => ( <div> <div style={{ position: "absolute", marginTop: 17, width: 1, height: 5, backgroundColor: "rgb(200,200,200)", left: `${tick.percent}%`, }} /> ...
khoadaxne15/LastProject
src/App.tsx
import React, { StrictMode } from "react"; import { Provider } from "react-redux"; import { Store } from "redux"; import { Persistor } from "redux-persist"; import { PersistGate } from "redux-persist/integration/react"; import { Preloader } from "./components"; import { AppState } from "./redux"; import { AppRouter } ...
khoadaxne15/LastProject
src/hooks/index.ts
<filename>src/hooks/index.ts export * from "./useBasket"; export * from "./useDidMount"; export * from "./useDocumentTitle"; export * from "./useFeaturedProducts"; export * from "./useFileHandler"; export * from "./useModal"; export * from "./useProduct"; export * from "./useRecommendedProducts"; export * from "./useSc...