Skip to content

Commit

Permalink
fix: update checkout
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjobando committed Nov 23, 2020
1 parent c5511b5 commit afad414
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions app/generated/graphql.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3162,7 +3162,7 @@ export type InsertStoreItemMutation = (
);

export type PurchaseStoreItemsMutationVariables = Exact<{
itemBarcodes: Array<Scalars['String']>;
items: Array<Scalars['String']>;
orderId: Scalars['uuid'];
}>;

Expand Down Expand Up @@ -3800,9 +3800,9 @@ export type InsertStoreItemMutationHookResult = ReturnType<typeof useInsertStore
export type InsertStoreItemMutationResult = Apollo.MutationResult<InsertStoreItemMutation>;
export type InsertStoreItemMutationOptions = Apollo.BaseMutationOptions<InsertStoreItemMutation, InsertStoreItemMutationVariables>;
export const PurchaseStoreItemsDocument = gql`
mutation PurchaseStoreItems($itemBarcodes: [String!]!, $orderId: uuid!) {
mutation PurchaseStoreItems($items: [String!]!, $orderId: uuid!) {
update_StoreItem(
where: {barcodeId: {_in: $itemBarcodes}}
where: {id: {_in: $items}}
_set: {purchased: true, orderId: $orderId}
) {
affected_rows
Expand All @@ -3824,7 +3824,7 @@ export type PurchaseStoreItemsMutationFn = Apollo.MutationFunction<PurchaseStore
* @example
* const [purchaseStoreItemsMutation, { data, loading, error }] = usePurchaseStoreItemsMutation({
* variables: {
* itemBarcodes: // value for 'itemBarcodes'
* items: // value for 'items'
* orderId: // value for 'orderId'
* },
* });
Expand Down
4 changes: 2 additions & 2 deletions app/src/graphql/mutations/PurchaseStoreItems.graphql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mutation PurchaseStoreItems($itemBarcodes: [String!]!, $orderId: uuid!) {
update_StoreItem(where: { barcodeId: { _in: $itemBarcodes } }, _set: { purchased: true, orderId: $orderId }) {
mutation PurchaseStoreItems($items: [String!]!, $orderId: uuid!) {
update_StoreItem(where: { id: { _in: $items } }, _set: { purchased: true, orderId: $orderId }) {
affected_rows
}
}
6 changes: 3 additions & 3 deletions app/src/screens/Auth/Checkout/CheckoutScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const CheckoutScreen = () => {
*/
const checkoutItems = async () => {
if (userId) {
const itemBarcodes = cartData.map(cartItem => cartItem.StoreItem.barcodeId);
const items = cartData.map(cartItem => cartItem.StoreItem.id);

let orderData: UserOrderInfoFragment | undefined;

Expand All @@ -94,7 +94,7 @@ export const CheckoutScreen = () => {
orderData = res.data.insert_UserOrder_one;

if (orderData) {
await purchaseItemsMutation({ variables: { itemBarcodes, orderId: orderData.id } });
await purchaseItemsMutation({ variables: { items, orderId: orderData.id } });
await clearCartMutation({ variables: { userId } });
await navigation.navigate('ReceiptScreen', { orderData });
}
Expand Down Expand Up @@ -141,7 +141,7 @@ export const CheckoutScreen = () => {
<CheckoutHeaderText>Order Total</CheckoutHeaderText>
<CheckoutPaymentDetailsContainer>
<CheckoutText>Sub-total:</CheckoutText>
<CheckoutText2>${subtotal}</CheckoutText2>
<CheckoutText2>${subtotal.toFixed(2)}</CheckoutText2>
</CheckoutPaymentDetailsContainer>
<CheckoutPaymentDetailsContainer>
<CheckoutText>Sales Tax:</CheckoutText>
Expand Down
2 changes: 1 addition & 1 deletion app/src/screens/Auth/Checkout/ReceiptScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const ReceiptScreen = ({ route }: ReceiptScreenProps) => {
<CheckoutHeaderText>Order Total</CheckoutHeaderText>
<CheckoutPaymentDetailsContainer>
<CheckoutText>Sub-total:</CheckoutText>
<CheckoutText2>${subtotal}</CheckoutText2>
<CheckoutText2>${subtotal.toFixed(2)}</CheckoutText2>
</CheckoutPaymentDetailsContainer>
<CheckoutPaymentDetailsContainer>
<CheckoutText>Sales Tax:</CheckoutText>
Expand Down

0 comments on commit afad414

Please sign in to comment.