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 11 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
8 changes: 6 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
AIRTABLE_BASE_ID='your-API-key-here'
AIRTABLE_API_KEY='keyioENo5dwh9Czt9'
annieyro marked this conversation as resolved.
Show resolved Hide resolved
REACT_APP_AIRTABLE_API_KEY={AIRTABLE API KEY}
AIRTABLE_BASE_ID='app4fXK49bqcjDMEo'

AIRTABLE_EMAIL='your-airtable-email'
AIRTABLE_PASSWORD='your-airtable-password'

IMG_API_KEY='image-API-key-here'
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
.expo/*
node_modules/**/*

# Deprecated env file
# Deprecated env files
environment.js
.airtable-schema-generator.env
# Only used for manual
schemaRaw.json
# env files
.env.development
.env.production
.airtable-schema-generator.env


package-lock.json
*.DS_Store

Expand Down
34 changes: 10 additions & 24 deletions components/AuthTextField.js
Original file line number Diff line number Diff line change
@@ -1,54 +1,40 @@
import React from 'react';
import Colors from '../assets/Colors';
import { fieldStateColors } from '../lib/authUtils';
import {
InputNoticeContainer,
TextField,
TextFieldContainer
} from '../styled/auth';
import { InputNoticeContainer, TextField, TextFieldContainer } from '../styled/auth';
import { Caption } from './BaseComponents';

/**
* @prop
* */

function AuthTextField({
fieldType,
color,
value,
onBlurCallback,
onFocusCallback,
changeTextCallback
}) {
function AuthTextField({ fieldType, errorMsg, color, value, onBlurCallback, onFocusCallback, changeTextCallback }) {
return (
<TextFieldContainer>
<Caption color={color}>{fieldType}</Caption>
<TextField
onBlur={onBlurCallback}
onFocus={onFocusCallback}
autoCapitalize={'words'}
autoCapitalize="words"
placeholder={fieldType}
autoCorrect={false}
onChangeText={changeTextCallback}
value={value}
borderColor={color}
returnKeyType={'done'}
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>
{/* Name */}
{color !== fieldStateColors.ERROR && 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' && (
{color === fieldStateColors.ERROR && <Caption color={color}>{errorMsg}</Caption>}
{/* {color === fieldStateColors.ERROR && fieldType === 'Password' && (
<Caption color={color}>Must be 8-20 characters long</Caption>
)}
)} */}
</InputNoticeContainer>
</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
4 changes: 2 additions & 2 deletions components/product/ProductCard.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { Image } from 'react-native';
import { ButtonContainer, Body } from '../BaseComponents';
import { ColumnContainer } from '../../styled/shared';
import { Body, ButtonContainer } from '../BaseComponents';

/**
* @prop
Expand All @@ -19,7 +19,7 @@ function ProductCard({ product, store, navigation }) {
}>
<ColumnContainer>
<Image
source={{ uri: product.image }}
source={{ uri: product.imageUrl }}
style={{ height: 86, width: 86, borderRadius: 12 }}
/>
<Body>{product.name}</Body>
Expand Down
48 changes: 19 additions & 29 deletions components/rewards/PointsHistory.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,32 @@
import React from 'react';
import { Button, ScrollView, StyleSheet, Text, View } from 'react-native';
import { ScrollView, View } from 'react-native';
import { Overline } from '../BaseComponents';
import Transaction from './Transaction';

/**
* @prop
* */

const styles = StyleSheet.create({
signOutButton: {
fontSize: 20,
paddingVertical: 15
}
});

function PointsHistory({ transactions, user, updates, navigation }) {
// Only display if transactions have mounted
function PointsHistory({ transactions }) {
// TODO @kennethlien fix spacing at line 44
if (transactions) {
return (

return (
<View>
<View>
<View>
<ScrollView>
<Overline style={{ marginTop: 24 }}>Recent Transactions</Overline>
{transactions.map(transaction => (
<Transaction
key={transaction.id}
date={transaction.date}
points={transaction.points}
storeName={transaction.storeName}
/>
))}
</ScrollView>
</View>
<ScrollView>
<Overline style={{ marginTop: 24 }}>Recent Transactions</Overline>
{transactions.map(transaction => (
<Transaction
key={transaction.id}
date={transaction.date}
points={transaction.points}
storeName={transaction.storeName}
/>
))}
</ScrollView>
</View>
);
}
// else return
return <View />;
</View>
);
}

export default React.memo(PointsHistory);
42 changes: 17 additions & 25 deletions components/rewards/RewardsHome.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,45 @@
import React from 'react';
import { View, ScrollView } from 'react-native';
import { Body, Overline, Title } from '../BaseComponents';
import {
RewardsProgressContainer,
AvailiableRewardsContainer
} from '../../styled/rewards';
import { ScrollView, View } from 'react-native';
import { ProgressBar } from 'react-native-paper';
import RewardsCard from './RewardsCard';
import Colors from '../../assets/Colors';
import { AvailiableRewardsContainer, RewardsProgressContainer } from '../../styled/rewards';
import { Body, Overline, Title } from '../BaseComponents';
import RewardsCard from './RewardsCard';

/**
* @prop
* */

function createList(N) {
let list = [];
for (var i = 1; i <= N; i++) {
function createList(n) {
const list = [];
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) % rewardPointValue;
return (
<View>
<ScrollView>
<RewardsProgressContainer>
<Overline style={{ marginTop: 24, marginBottom: 15 }}>
REWARD PROGRESS
</Overline>
<Title style={{ marginBottom: 2 }}>
{parseInt(user.points) % 1000} / 1000
</Title>
<Overline style={{ marginTop: 24, marginBottom: 15 }}>Reward Progress</Overline>
<Title style={{ marginBottom: 2 }}>{`${pointsToNext} / ${rewardPointValue}`}</Title>
<ProgressBar
style={{ height: 20, 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 $5 reward
</Body>
<Overline style={{ marginBottom: 8 }}>
AVAILIABLE REWARDS ({Math.floor(parseInt(user.points) / 1000)})
</Overline>
<Overline style={{ marginBottom: 8 }}>Available Rewards ({Math.floor(rewardsAvailable)}</Overline>
</RewardsProgressContainer>
<AvailiableRewardsContainer>
{createList(Math.floor(parseInt(user.points) / 1000)).map(a => (
<RewardsCard></RewardsCard>
{createList(Math.floor(rewardsAvailable)).map(i => (
<RewardsCard key={i} />
))}
</AvailiableRewardsContainer>
</ScrollView>
Expand Down
47 changes: 11 additions & 36 deletions components/store/StoreCard.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
import { FontAwesome5 } from '@expo/vector-icons';
import React from 'react';
import { View } from 'react-native';
import Colors from '../../assets/Colors';
import { InLineContainer } from '../../styled/shared';
import {
SpaceAroundRowContainer,
SpaceBetweenRowContainer
} from '../../styled/shared';
import {
StoreCardContainer,
EBTStatusBar,
DividerBar
} from '../../styled/store';
import { InLineContainer, SpaceAroundRowContainer, SpaceBetweenRowContainer } from '../../styled/shared';
import { DividerBar, EBTStatusBar, StoreCardContainer } from '../../styled/store';
import { Body, Caption, Title } from '../BaseComponents';
import StoreProductButton from './StoreProductButton';

Expand All @@ -20,13 +11,13 @@ import StoreProductButton from './StoreProductButton';
* */

function StoreCard({ store, callBack, seeProduct }) {
const { name, hours, address, distance, ebt, rewards } = store;
const { storeName, storeHours, address, distance, snapOrEbtAccepted, rewardsAccepted } = store;
return (
<StoreCardContainer>
<SpaceBetweenRowContainer>
<SpaceAroundRowContainer>
<Title color={Colors.activeText}>{name}</Title>
{ebt && (
<Title color={Colors.activeText}>{storeName}</Title>
{snapOrEbtAccepted && (
<EBTStatusBar>
<FontAwesome5 name="check" size={10} color={Colors.darkerGreen} />
<Caption color={Colors.darkerGreen}> EBT</Caption>
Expand All @@ -38,35 +29,19 @@ function StoreCard({ store, callBack, seeProduct }) {
<Caption style={{ marginBottom: 4 }} color={Colors.secondaryText}>
{distance} miles away
</Caption>
{rewards && (
{rewardsAccepted && (
<InLineContainer style={{ alignItems: 'center' }}>
<FontAwesome5
name="star"
solid
size={16}
color={Colors.primaryGreen}
/>
<Body color={Colors.primaryGreen}>
Earn and redeem Healthy Rewards here
</Body>
<FontAwesome5 name="star" solid size={16} color={Colors.primaryGreen} />
<Body color={Colors.primaryGreen}>Earn and redeem Healthy Rewards here</Body>
</InLineContainer>
)}
<InLineContainer style={{ alignItems: 'center' }}>
<FontAwesome5
name="directions"
size={16}
color={Colors.secondaryText}
/>
<FontAwesome5 name="directions" size={16} color={Colors.secondaryText} />
<Body color={Colors.secondaryText}> {address}</Body>
</InLineContainer>
<InLineContainer style={{ alignItems: 'center' }}>
<FontAwesome5
name="clock"
solid
size={16}
color={Colors.secondaryText}
/>
<Body color={Colors.secondaryText}> {hours}</Body>
<FontAwesome5 name="clock" solid size={16} color={Colors.secondaryText} />
<Body color={Colors.secondaryText}> {storeHours}</Body>
</InLineContainer>
<DividerBar />
</StoreCardContainer>
Expand Down
5 changes: 2 additions & 3 deletions components/store/StoreProductButton.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import React from 'react';
import { FilledButtonContainer, ButtonLabel } from '../BaseComponents';
import Colors from '../../assets/Colors';
import { ButtonLabel, FilledButtonContainer } from '../BaseComponents';

/**
* @prop
* */

function StoreProductButton({ callBack }) {
// const { name, hours, address, distance, ebt } = store;
return (
<FilledButtonContainer
width="130px"
height="35px"
color={Colors.primaryOrange}
onPress={callBack}>
<ButtonLabel color="#fff">See Products</ButtonLabel>
<ButtonLabel color={Colors.lightest}>See Products</ButtonLabel>
</FilledButtonContainer>
);
}
Expand Down
3 changes: 3 additions & 0 deletions constants/Rewards.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const rewardDollarValue = 5;

export const rewardPointValue = 1500;
annieyro marked this conversation as resolved.
Show resolved Hide resolved
Loading