Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Airtable refactor, bug fixes, Auth overhaul #48

Merged
merged 45 commits into from
Apr 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
7ec5a16
Add material UI. Changing error states.
tommypoa Mar 23, 2020
130fb04
Error working, but working on better UI.
tommypoa Mar 23, 2020
bd89278
Update prettier rules to match clerk repo, and no longer conflict wit…
annieyro Mar 24, 2020
9118740
Update packages - upgrade generator version
annieyro Mar 24, 2020
59a5081
Update Airtable schema
annieyro Mar 25, 2020
c128f77
Refactor MapScreen and related components
annieyro Mar 25, 2020
d3cf863
Refactor News and related components
annieyro Mar 25, 2020
3915fb2
Clean up AppNavigator.js
annieyro Mar 25, 2020
1f57b24
Refactor Resources
annieyro Mar 25, 2020
f24205d
Replace getUser
annieyro Mar 25, 2020
b92ea4c
Refactor Rewards and related components.
annieyro Mar 25, 2020
c79e52d
Use constants/Rewards.js for reward point value
annieyro Mar 25, 2020
ae7b262
Error working with both signup and login. Styling not done.
tommypoa Mar 26, 2020
33e0f7a
Overhaul Signup
annieyro Mar 26, 2020
2d63467
Undo prettier width change and cleanup
annieyro Mar 26, 2020
18b1530
Add workspace-specific shared settings (format and run eslint on save)
annieyro Mar 27, 2020
61ed95b
Update prettier config
annieyro Mar 27, 2020
70f5fae
Update prettier config and run prettier on all ours
annieyro Mar 27, 2020
5a0f4e6
Update schema with changed fields
annieyro Mar 29, 2020
dce398c
Add workspace-specific color
annieyro Mar 29, 2020
eb8d9b3
Merge branch 'master' into annie/update-airtable
annieyro Mar 30, 2020
ab42e4b
Merge branch 'tommy/materialui_refactor' into annie/update-airtable
annieyro Mar 30, 2020
b34379f
Small fixes
annieyro Mar 30, 2020
b6d1f69
Merge branch 'master' into annie/update-airtable
annieyro Mar 31, 2020
129eb86
Add back filter for Clerk Training, enforce ordering on location upda…
annieyro Mar 31, 2020
91eb9f2
Update login code
annieyro Mar 31, 2020
88a8716
Bugfix
annieyro Mar 31, 2020
ec7f020
Remove .eslintignore
annieyro Mar 31, 2020
5c9f171
Bump version, run generator to update schema
annieyro Mar 31, 2020
086d8a6
Update schema again
annieyro Mar 31, 2020
0437200
Updated error message for login and added styling
annieyro Apr 1, 2020
371f4d9
Handle permissions on text change in Signup
annieyro Apr 1, 2020
4d6a718
Remove deprecated Airtable code in common.js
annieyro Apr 1, 2020
3470012
Support base change to development Airtable base
annieyro Apr 2, 2020
f3126ee
Add rewardDollarValue
annieyro Apr 2, 2020
8c0acca
Fix typo
annieyro Apr 2, 2020
ab6bd5f
Filter out clerk training in dev as well
annieyro Apr 2, 2020
e341af2
Cleanup .env.example
annieyro Apr 2, 2020
68da60c
Update login and logout
annieyro Apr 2, 2020
55a5608
Remove permissions from state and calculate in render. Update SignUp …
annieyro Apr 2, 2020
f6e80ee
Merge branch 'master' into annie/update-airtable
annieyro Apr 2, 2020
f0fa653
Update line widths
annieyro Apr 3, 2020
588542b
Display duplicate customer error
annieyro Apr 3, 2020
ac5e0eb
Merge branch 'master' of https://github.com/calblueprint/dccentralkit…
wangannie Apr 3, 2020
6214dd9
Merge branch 'annie/update-airtable' of https://github.com/calbluepri…
wangannie Apr 3, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
AIRTABLE_BASE_ID='your-base-id-here'
AIRTABLE_API_KEY='your-API-key-here'
AIRTABLE_BASE_ID='appYfW7a2loPD26Vg'

## Named to conform to airtable-schema-generator's expectations
REACT_APP_AIRTABLE_API_KEY='YOUR-API-KEY-HERE'

## Needed for airtable-schema-generator if using auto mode
AIRTABLE_EMAIL='YOUR-EMAIL-HERE'
AIRTABLE_PASSWORD='YOUR-PASSWORD-HERE'

IMG_API_KEY='image-API-key-here'
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

24 changes: 12 additions & 12 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
module.exports = {
env: {
es6: true
es6: true,
},
extends: ['eslint:recommended', 'airbnb', 'plugin:prettier/recommended'],
parser: 'babel-eslint',
parserOptions: {
ecmaFeatures: {
jsx: true
jsx: true,
},
ecmaVersion: 2018,
sourceType: 'module'
sourceType: 'module',
},
plugins: ['react-native', 'prettier'],
rules: {
Expand All @@ -19,22 +19,22 @@ module.exports = {
paths: [
{
name: 'airtable',
message: 'Do not use the airtable module outside of airtable.js'
message: 'Do not use the airtable module outside of airtable.js',
},
{
name: './airtable',
message: 'Do not use airtable.js outside of request.js'
message: 'Do not use airtable.js outside of request.js',
},
{
name: '../../lib/airtable',
message: 'Do not use airtable.js outside of request.js'
message: 'Do not use airtable.js outside of request.js',
},
{
name: '../../../lib/airtable',
message: 'Do not use airtable.js outside of request.js'
}
]
}
message: 'Do not use airtable.js outside of request.js',
},
],
},
],
'no-underscore-dangle': ['error', { allowAfterThis: true }],
'no-use-before-define': ['error', { variables: false }],
Expand All @@ -47,6 +47,6 @@ module.exports = {
'valid-typeof': 'warn',
'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx'] }],
'prettier/prettier': ['error'],
'react/destructuring-assignment': ['enabled', 'never']
}
'react/destructuring-assignment': 'off',
},
};
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
.expo/*
node_modules/**/*

# Deprecated env file
# Deprecated env files
environment.js
.airtable-schema-generator.env

# Ignore schemaRaw.json (only used for manual mode)
schemaRaw.json

# env files
.env.development
.env.production
.airtable-schema-generator.env


package-lock.json
*.DS_Store

Expand Down
54 changes: 24 additions & 30 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
{
"files.associations": {
"*.js": "javascriptreact"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
},
"eslint.enable": true,
"eslint.options": {
"extensions": [
".js",
".jsx"
]
},
"eslint.validate": [
"javascript",
"javascriptreact"
],
"eslint.alwaysShowStatus": true,
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true,
"source.fixAll.eslint": true
},
"javascript.suggest.completeFunctionCalls": true,
"javascript.implicitProjectConfig.checkJs": true,
}
"files.associations": {
"*.js": "javascriptreact"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"eslint.enable": true,
"eslint.options": {
"extensions": [".js", ".jsx"]
},
"eslint.validate": ["javascript", "javascriptreact"],
"eslint.alwaysShowStatus": true,
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true,
"source.fixAll.eslint": true
},
"javascript.suggest.completeFunctionCalls": true,
"javascript.implicitProjectConfig.checkJs": true
}
45 changes: 18 additions & 27 deletions components/AuthTextField.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import React from 'react';
import { TextField } from 'react-native-materialui-textfield';
import Colors from '../constants/Colors';
import { fieldStateColors } from '../lib/authUtils';
import {
InputNoticeContainer,
TextField,
TextFieldContainer,
} from '../styled/auth';
import { TextFieldContainer } from '../styled/auth';
import { Caption } from './BaseComponents';

/**
Expand All @@ -14,42 +10,37 @@ import { Caption } from './BaseComponents';

function AuthTextField({
fieldType,
color,
value,
onBlurCallback,
onFocusCallback,
changeTextCallback,
error,
onBlurCallback = null,
}) {
return (
<TextFieldContainer>
<Caption color={color}>{fieldType}</Caption>
<TextField
onBlur={onBlurCallback}
onFocus={onFocusCallback}
onBlur={onBlurCallback ? () => onBlurCallback(value) : null}
autoCapitalize="words"
placeholder={fieldType}
autoCorrect={false}
label={fieldType}
labelTextStyle={{ fontFamily: 'poppins-regular' }}
lineWidth={1.75}
activeLineWidth={1.75}
onChangeText={changeTextCallback}
value={value}
borderColor={color}
baseColor={Colors.activeText}
tintColor={Colors.primaryGreen}
error={error}
errorColor={Colors.error}
returnKeyType="done"
keyboardType={fieldType === 'Phone Number' ? 'numeric' : 'default'}
maxLength={fieldType === 'Phone Number' ? 10 : null}
secureTextEntry={fieldType === 'Password'}
/>
<InputNoticeContainer>
{fieldType === 'Name' && (
<Caption color={Colors.secondaryText}>
Note: this is how clerks will greet you!
</Caption>
)}
{color === fieldStateColors.ERROR && fieldType === 'Phone Number' && (
<Caption color={color}>Must be a valid phone number</Caption>
)}
{color === fieldStateColors.ERROR && fieldType === 'Password' && (
<Caption color={color}>Must be 8-20 characters long</Caption>
)}
</InputNoticeContainer>
{fieldType === 'Name' && !error && (
<Caption color={Colors.activeText}>
Note: this is how clerks will greet you!
</Caption>
)}
</TextFieldContainer>
);
}
Expand Down
2 changes: 1 addition & 1 deletion components/news/NewsItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class NewsItem extends React.Component {
}>
<Card>
<DateContainer>
<DateText>{this.props.newsItem.date.toDateString()}</DateText>
<DateText>{this.props.newsItem.postDate.toDateString()}</DateText>
</DateContainer>
<ContentContainer>
<DateText>{this.props.newsItem.title}</DateText>
Expand Down
5 changes: 3 additions & 2 deletions components/product/ProductCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Colors from '../../constants/Colors';
import { displayDollarValue } from '../../lib/common';
import { ColumnContainer, RowContainer } from '../../styled/shared';
import { Body, ButtonContainer, Caption } from '../BaseComponents';

/**
* @prop
* */
Expand All @@ -20,7 +21,7 @@ function ProductCard({ product, store, navigation, displayPoints }) {
}>
<ColumnContainer>
<Image
source={{ uri: product.image }}
source={{ uri: product.imageUrl }}
style={{ height: 86, width: 86, borderRadius: 12 }}
/>
<Body>{product.name}</Body>
Expand All @@ -29,7 +30,7 @@ function ProductCard({ product, store, navigation, displayPoints }) {
)}
<RowContainer>
<Caption color={Colors.secondaryText}>
{displayDollarValue(product.customerCost)} ea
{`${displayDollarValue(product.customerCost)} ea`}
</Caption>
{displayPoints && (
<Caption color={Colors.secondaryText}>
Expand Down
2 changes: 1 addition & 1 deletion components/product/ProductInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Body, Caption, Title } from '../BaseComponents';
* */

function ProductInfo({ product }) {
const { name, id, category, points, customerCost } = product;
const { name, points, customerCost } = product;
return (
<ProductInfoContainer>
<Title>{name}</Title>
Expand Down
5 changes: 2 additions & 3 deletions components/rewards/PointsHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import { FlatList, View } from 'react-native';
import Colors from '../../constants/Colors';
import { Body, Overline } from '../BaseComponents';
import Transaction from './Transaction';

/**
* @prop
* */

function PointsHistory({ transactions, user, updates, navigation }) {
// Only display if transactions have mounted
// TODO @kennethlien fix spacing at line 44
function PointsHistory({ transactions }) {
return (
<View>
<FlatList
Expand Down
9 changes: 7 additions & 2 deletions components/rewards/RewardsCard.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import Colors from '../../constants/Colors';
import { rewardDollarValue, rewardPointValue } from '../../constants/Rewards';
import {
RewardDescriptionContainer,
RewardsCardContainer,
Expand All @@ -17,8 +18,12 @@ class RewardsCard extends React.Component {
circleColor={Colors.lightest}
/>
<RewardDescriptionContainer>
<Subhead color={Colors.darkerGreen}>$5 Reward</Subhead>
<Caption color={Colors.darkerGreen}>1000 points</Caption>
<Subhead color={Colors.darkerGreen}>
{`$${rewardDollarValue} Reward`}
</Subhead>
<Caption color={Colors.darkerGreen}>
{`${rewardPointValue} points`}
</Caption>
</RewardDescriptionContainer>
</RewardsCardContainer>
);
Expand Down
21 changes: 12 additions & 9 deletions components/rewards/RewardsHome.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react';
import { FlatList, ScrollView, View } from 'react-native';
import { ProgressBar } from 'react-native-paper';
import Colors from '../../constants/Colors';
import { rewardDollarValue, rewardPointValue } from '../../constants/Rewards';
import {
AvailableRewardsContainer,
RewardsProgressContainer,
Expand All @@ -14,23 +15,25 @@ import RewardsCard from './RewardsCard';
* @prop
* */

function createList(N) {
function createList(n) {
const list = [];
for (let i = 1; i <= N; i++) {
for (let i = 1; i <= n; i += 1) {
list.push(i);
}
return list;
}

function RewardsHome({ user }) {
function RewardsHome({ customer }) {
const rewardsAvailable = parseInt(customer.points, 10) / rewardPointValue;
const pointsToNext = parseInt(customer.points, 10) % rewardPointValue;
return (
<ScrollView style={{ marginLeft: 16, paddingRight: 16 }}>
<RewardsProgressContainer>
<Overline style={{ marginTop: 24, marginBottom: 12 }}>
Reward Progress
</Overline>
<Title style={{ marginBottom: 2 }}>
{parseInt(user.points) % 1000} / 1000
{`${pointsToNext} / ${rewardPointValue}`}
</Title>
<ProgressBar
style={{
Expand All @@ -39,20 +42,20 @@ function RewardsHome({ user }) {
borderRadius: 20,
marginBottom: 15,
}}
progress={(parseInt(user.points) % 1000) / 1000}
progress={pointsToNext / rewardPointValue}
color={Colors.primaryGreen}
/>
<Body style={{ marginBottom: 28 }}>
Earn {`${1000 - (parseInt(user.points) % 1000)}`} points to unlock
your next $5 reward.
{`Earn ${rewardPointValue -
pointsToNext} points to unlock your next $${rewardDollarValue} reward`}
</Body>
<Overline style={{ marginBottom: 8 }}>
Available Rewards ({Math.floor(parseInt(user.points) / 1000)})
{`Available Rewards (${Math.floor(rewardsAvailable)})`}
</Overline>
</RewardsProgressContainer>
<AvailableRewardsContainer>
<FlatList
data={createList(Math.floor(parseInt(user.points) / 1000))}
data={createList(Math.floor(rewardsAvailable))}
renderItem={() => <RewardsCard />}
annieyro marked this conversation as resolved.
Show resolved Hide resolved
keyExtractor={(item, index) => index.toString()}
numColumns={2}
Expand Down
Loading