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

Single page app #3

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 6 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
OPENAI_API_KEY="..."
TURSO_DB_URL=YOUR_DB_URL
TURSO_DB_AUTH_TOKEN=YOUR_DB_AUTH_TOKEN

//connect to the cloudflare api endpoint

API_URL=YOUR_API_URL
28 changes: 14 additions & 14 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout commit
uses: actions/checkout@v3
- name: Checkout commit
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install Dependencies
run: yarn install
- name: Install Dependencies
run: yarn install

- name: Lint
run: yarn lint
- name: Lint
run: yarn lint

- name: Formatting Check
run: npm run format-check
- name: Formatting Check
run: npm run format-check

- name: Type check
run: npm run type-check
- name: Type check
run: npm run type-check
3 changes: 1 addition & 2 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ jobs:
with:
# `github.event.pull_request.head.ref` is only available on `pull_request` triggers.
# Use your own, or keep the automatically infered branch name from `--auto`, when using different triggers.
command: eas update --auto --branch ${{ github.event.pull_request.head.ref }}

command: eas update --auto --branch ${{ github.event.pull_request.head.ref }}
2 changes: 1 addition & 1 deletion .github/workflows/update.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: update
on:
push:
push:
branches:
- release

Expand Down
5 changes: 1 addition & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@
"editor.formatOnSaveMode": "modifications",
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"cSpell.words": [
"chatbubble",
"Ionicons"
]
"cSpell.words": ["chatbubble", "Ionicons"]
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Ella
# vvsales

# TODOs

Expand All @@ -25,5 +25,5 @@ yarn run ios --clear
# Troubleshooting

```txt
watchman watch-del 'project location/Ella' ; watchman watch-project 'project location/Ella'
watchman watch-del 'project location/vvsales' ; watchman watch-project 'project location/vvsales'
```
30 changes: 11 additions & 19 deletions app.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"expo": {
"name": "ella",
"slug": "DrElla",
"name": "vvsales",
"slug": "vvsales",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/images/icon.png",
Expand All @@ -15,35 +15,27 @@
"assetBundlePatterns": ["**/*"],
"ios": {
"supportsTablet": true,
"bundleIdentifier": "com.technoculture.ella"
"bundleIdentifier": "com.technoculture.vvsales"
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/images/adaptive-icon.png",
"backgroundColor": "#ffffff"
},
"package": "com.technoculture.ella"
"package": "com.technoculture.vvsales",
"permissions": [
"android.permission.CAMERA",
"android.permission.RECORD_AUDIO",
"android.permission.CALL_PHONE"
]
},
"web": {
"bundler": "metro",
"output": "static",
"favicon": "./assets/images/favicon.png"
},
"plugins": [
"expo-router",
[
"expo-camera",
{
"cameraPermission": "Allow $(PRODUCT_NAME) to access your camera.",
"microphonePermission": "Allow $(PRODUCT_NAME) to access your mic."
}
],
[
"expo-document-picker",
{
"iCloudContainerEnvironment": "Production"
}
]
"expo-router"
],
"experiments": {
"typedRoutes": true
Expand All @@ -53,7 +45,7 @@
"origin": false
},
"eas": {
"projectId" :"dfde4001-b00b-4a77-a028-7d966b8f9e3d"
"projectId": "a463d91b-3ec0-4653-837a-93a87a5b687d"
}
},
"owner": "technoculture"
Expand Down
52 changes: 52 additions & 0 deletions app/(tabs)/_layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import FontAwesome from "@expo/vector-icons/FontAwesome";
import { Link, Tabs } from "expo-router";
import React from "react";
import { Pressable, useColorScheme } from "react-native";

import Colors from "../../constants/Colors";

/**
* You can explore the built-in icon families and icons on the web at https://icons.expo.fyi/
*/
function TabBarIcon(props: {
name: React.ComponentProps<typeof FontAwesome>["name"];
color: string;
}) {
return <FontAwesome size={28} className="mb-[-3]" {...props} />;
}

export default function TabLayout() {
const colorScheme = useColorScheme();

return (
<Tabs
screenOptions={{
tabBarActiveTintColor: Colors[colorScheme ?? "light"].tint,
}}
>
<Tabs.Screen
name="index"
options={{
title: "Tasks",
tabBarIcon: ({ color }) => <TabBarIcon name="code" color={color} />,
headerRight: () => (
<Link href="/inbox" asChild>
<Pressable>
{({ pressed }) => (
<FontAwesome
name="info-circle"
size={25}
color={Colors[colorScheme ?? "light"].text}
className={`mr-15 ${
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pressed ? "opacity-50" : "opacity-100"
}`}
/>
)}
</Pressable>
</Link>
),
}}
/>
</Tabs>
);
}
98 changes: 98 additions & 0 deletions app/(tabs)/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import React, { useState, useEffect, useCallback } from "react";
import { FlatList, TouchableOpacity, RefreshControl } from "react-native";
import RNImmediatePhoneCall from "react-native-immediate-phone-call";
import call from "react-native-phone-call";

import { Text, View } from "../../components/Themed";
import { sync } from "../../lib/db_helpers";

interface Task {
id: string;
name: string;
contactNumber: string;
trials: number;
city: string;
state: string;
}

export default function TabOneScreen() {
const [tasks, setTasks] = useState<Task[]>([]);
const [refreshing, setRefreshing] = useState(false);

const getTasks = async () => {
const tasks = await fetch("API_URL" + "/tasks");

Check warning on line 24 in app/(tabs)/index.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected string concatenation of literals
const json = await tasks.json();
return json;
};

const fetchData = useCallback(async () => {
const tasks = await getTasks();
setTasks(tasks);
}, []);

const updateTrials = async (taskId: string) => {
const updatedTasks = tasks.map((task) => {
if (task.id === taskId) {
return {
...task,
trials: task.trials + 1,
};
}
return task;
});
setTasks(updatedTasks);
};

const handleRefresh = useCallback(() => {
setRefreshing(true);
sync(setTasks);
setRefreshing(false);
}, []);

useEffect(() => {
const intervalId = setInterval(() => {
sync(setTasks);
}, 120000);
return () => clearInterval(intervalId);
}, []);

const handleCallPress = (contactNumber: string, taskId: string) => {
const args = {
number: contactNumber,
prompt: false,
};
updateTrials(taskId);
// RNImmediatePhoneCall.immediatePhoneCall(contactNumber);

call(args).catch(console.error);
};

return (
<View className="flex-1 items-center justify-center">
<FlatList
data={tasks}
keyExtractor={(item) => item.id}
renderItem={({ item }: { item: Task }) => (
<View>
<Text>{`Name: ${item.name}`}</Text>
<Text>{`Contact Number: ${item.contactNumber}`}</Text>
<Text>{`Trials: ${item.trials}`}</Text>
<Text>{`City: ${item.city}`}</Text>
<Text>{`State: ${item.state}`}</Text>
<Text>{`ID: ${item.id}`}</Text>
<TouchableOpacity
onPress={() => handleCallPress(item.contactNumber, item.id)}
>
<Text className="text-blue-500">Call</Text>
</TouchableOpacity>
<View className="border-b border-black mb-10" />
</View>
)}
refreshControl={
<RefreshControl refreshing={refreshing} onRefresh={handleRefresh} />
}
/>
</View>
);
}
78 changes: 0 additions & 78 deletions app/ChatCard.tsx

This file was deleted.

Loading
Loading