diff --git a/.DS_Store b/.DS_Store
deleted file mode 100644
index 845bb196f..000000000
Binary files a/.DS_Store and /dev/null differ
diff --git a/.babelrc b/.babelrc
deleted file mode 100644
index e3a9f43d4..000000000
--- a/.babelrc
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "presets": ["next/babel"]
- }
-
\ No newline at end of file
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
deleted file mode 100644
index 391ed7a9c..000000000
--- a/.github/workflows/codeql-analysis.yml
+++ /dev/null
@@ -1,66 +0,0 @@
-name: "CodeQL"
-
-on:
- push:
- branches: [main]
- pull_request:
- # The branches below must be a subset of the branches above
- branches: [main]
- schedule:
- - cron: '0 21 * * 0'
-
-jobs:
- analyze:
- name: Analyze
- runs-on: ubuntu-latest
-
- strategy:
- fail-fast: false
- matrix:
- # Override automatic language detection by changing the below list
- # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
- language: ['javascript']
- # Learn more...
- # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
-
- steps:
- - name: Checkout repository
- uses: actions/checkout@v2
- with:
- # We must fetch at least the immediate parents so that if this is
- # a pull request then we can checkout the head.
- fetch-depth: 2
-
- # If this run was triggered by a pull request event, then checkout
- # the head of the pull request instead of the merge commit.
- - run: git checkout HEAD^2
- if: ${{ github.event_name == 'pull_request' }}
-
- # Initializes the CodeQL tools for scanning.
- - name: Initialize CodeQL
- uses: github/codeql-action/init@v1
- with:
- languages: ${{ matrix.language }}
- # If you wish to specify custom queries, you can do so here or in a config file.
- # By default, queries listed here will override any specified in a config file.
- # Prefix the list here with "+" to use these queries and those in the config file.
- # queries: ./path/to/local/query, your-org/your-repo/queries@main
-
- # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
- # If this step fails, then you should remove it and run the build manually (see below)
- - name: Autobuild
- uses: github/codeql-action/autobuild@v1
-
- # ℹ️ Command-line programs to run using the OS shell.
- # 📚 https://git.io/JvXDl
-
- # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
- # and modify them (or add more) to build your code if your project
- # uses a compiled language
-
- #- run: |
- # make bootstrap
- # make release
-
- - name: Perform CodeQL Analysis
- uses: github/codeql-action/analyze@v1
\ No newline at end of file
diff --git a/.github/workflows/deta.yml b/.github/workflows/deta.yml
deleted file mode 100644
index 4e5946756..000000000
--- a/.github/workflows/deta.yml
+++ /dev/null
@@ -1,15 +0,0 @@
-name: Push to Space
-on: push
-
-jobs:
- push-to-space:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v3
- - name: Deta Space Deployment Github Action
- uses: neobrains/space-deployment-github-action@v0.5
- with:
- access_token: ${{ secrets.ACCESS_TOKEN }}
- project_id: ${{ secrets.PROJECT_ID }}
- space_push: true
- list_on_discovery: true
\ No newline at end of file
diff --git a/.github/workflows/nextjs.yml b/.github/workflows/nextjs.yml
deleted file mode 100644
index 5357cf874..000000000
--- a/.github/workflows/nextjs.yml
+++ /dev/null
@@ -1,96 +0,0 @@
-# Sample workflow for building and deploying a Next.js site to GitHub Pages
-#
-# To get started with Next.js see: https://nextjs.org/docs/getting-started
-#
-name: Deploy Next.js site to Pages
-
-on:
- # Runs on pushes targeting the default branch
- push:
- branches: ["main"]
-
- # Allows you to run this workflow manually from the Actions tab
- workflow_dispatch:
-
-# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
-permissions:
- contents: read
- pages: write
- id-token: write
-
-# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
-# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
-concurrency:
- group: "pages"
- cancel-in-progress: false
-
-jobs:
- # Build job
- build:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout
- uses: actions/checkout@v3
- - name: Detect package manager
- id: detect-package-manager
- run: |
- if [ -f "${{ github.workspace }}/yarn.lock" ]; then
- echo "manager=yarn" >> $GITHUB_OUTPUT
- echo "command=install" >> $GITHUB_OUTPUT
- echo "runner=yarn" >> $GITHUB_OUTPUT
- exit 0
- elif [ -f "${{ github.workspace }}/package.json" ]; then
- echo "manager=npm" >> $GITHUB_OUTPUT
- echo "command=ci" >> $GITHUB_OUTPUT
- echo "runner=npx --no-install" >> $GITHUB_OUTPUT
- exit 0
- else
- echo "Unable to determine package manager"
- exit 1
- fi
- - name: Setup Node
- uses: actions/setup-node@v3
- with:
- node-version: "16"
- cache: ${{ steps.detect-package-manager.outputs.manager }}
- - name: Setup Pages
- uses: actions/configure-pages@v3
- with:
- # Automatically inject basePath in your Next.js configuration file and disable
- # server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized).
- #
- # You may remove this line if you want to manage the configuration yourself.
- static_site_generator: next
- - name: Restore cache
- uses: actions/cache@v3
- with:
- path: |
- .next/cache
- # Generate a new cache whenever packages or source files change.
- key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
- # If source files changed but packages didn't, rebuild from a prior cache.
- restore-keys: |
- ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
- - name: Install dependencies
- run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
- - name: Build with Next.js
- run: ${{ steps.detect-package-manager.outputs.runner }} next build
- - name: Static HTML export with Next.js
- run: ${{ steps.detect-package-manager.outputs.runner }} next export
- - name: Upload artifact
- uses: actions/upload-pages-artifact@v1
- with:
- path: ./out
-
- # Deployment job
- deploy:
- environment:
- name: github-pages
- url: ${{ steps.deployment.outputs.page_url }}
- runs-on: ubuntu-latest
- needs: build
- steps:
- - name: Deploy to GitHub Pages
- id: deployment
- uses: actions/deploy-pages@v2
-
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index dae8c0c35..000000000
--- a/.gitignore
+++ /dev/null
@@ -1,45 +0,0 @@
-# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
-
-# dependencies
-/node_modules
-/.pnp
-.pnp.js
-.env
-
-# testing
-/coverage
-.env
-.venv
-/.venv
-venv
-/venv
-
-# next.js
-/.next/
-/out/
-
-# production
-/build
-
-# misc
-.DS_Store
-*.pem
-
-# debug
-npm-debug.log*
-yarn-debug.log*
-yarn-error.log*
-.pnpm-debug.log*
-
-# local env files
-.env*.local
-.env
-/.env
-
-# vercel
-.vercel
-
-# typescript
-*.tsbuildinfo
-next-env.d.ts
-TODOs.md
diff --git a/.gitkeep b/.gitkeep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/.vercelignore b/.vercelignore
deleted file mode 100644
index 9e5bfb42d..000000000
--- a/.vercelignore
+++ /dev/null
@@ -1 +0,0 @@
-api
\ No newline at end of file
diff --git a/.vscode/settings.json b/.vscode/settings.json
deleted file mode 100644
index 7a1fb42c6..000000000
--- a/.vscode/settings.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "jira-plugin.workingProject": "",
- "liveServer.settings.port": 5501,
- "solidity.defaultCompiler": "localFile",
- "solidity.compileUsingRemoteVersion": "v0.8.11+commit.d7f03943"
-}
\ No newline at end of file
diff --git a/App.py b/App.py
new file mode 100644
index 000000000..7796cb2d1
--- /dev/null
+++ b/App.py
@@ -0,0 +1,40 @@
+from flask import Flask, request, jsonify
+import lightkurve as lk
+import logging
+import numpy as np
+
+app = Flask(__name__)
+
+@app.route('/lightcurve/summary', methods=['POST'])
+def get_lightcurve_summary():
+
+ try:
+ request_data = request.get_json()
+ if not request_data or 'tic_id' not in request_data:
+ return jsonify({'error': 'Missing required field "tic_id"'}), 400
+
+ tic_id = request_data['tic_id']
+ if not tic_id.startswith("TIC "):
+ return jsonify({'error': 'Invalid TIC ID format'}), 400
+
+ lightcurve_data = lk.search_lightcurve(tic_id).download()
+ if lightcurve_data is None:
+ return jsonify({'error': 'No light curve found'}), 404
+
+ flux_values = lightcurve_data.flux.value
+ statistics_summary = {
+ 'mean': float(np.mean(flux_values)),
+ 'median': float(np.median(flux_values)),
+ 'standard_deviation': float(np.std(flux_values)),
+ 'peak_to_peak': float(np.ptp(flux_values)),
+ 'interquartile_range': float(np.percentile(flux_values, 75) - np.percentile(flux_values, 25)),
+ }
+
+ return jsonify(statistics_summary)
+
+ except Exception as e:
+ logging.error(f"Error processing request: {str(e)}")
+ return jsonify({'error': str(e)}), 500
+
+if __name__ == '__main__':
+ app.run(debug=True)
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 000000000..edead2359
--- /dev/null
+++ b/README.md
@@ -0,0 +1,23 @@
+# Lightcurve Summary API
+
+This Flask application provides an API endpoint to fetch and summarize light curve data for a given TIC ID from the TESS (Transiting Exoplanet Survey Satellite) data using the `lightkurve` Python library.
+
+## Features
+
+- Fetch light curve data using a TIC ID.
+- Calculate statistical summaries of the light curve data including mean, median, standard deviation, peak-to-peak, and interquartile range.
+
+## Requirements
+
+- Flask
+- lightkurve
+- numpy
+
+## Installation
+
+Clone the repository and install the required packages:
+
+
+
+
+
diff --git a/Spacefile b/Spacefile
deleted file mode 100644
index c3a79a098..000000000
--- a/Spacefile
+++ /dev/null
@@ -1,7 +0,0 @@
-# Spacefile Docs: https://go.deta.dev/docs/spacefile/v0
-v: 0
-micros:
- - name: client
- src: ./
- engine: next
- primary: true
diff --git a/capacitor.config.ts b/capacitor.config.ts
deleted file mode 100644
index cea7fe844..000000000
--- a/capacitor.config.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { CapacitorConfig } from '@capacitor/cli';
-
-const config: CapacitorConfig = {
- appId: 'space.starsailors.app',
- appName: 'Star Sailors',
- webDir: 'out',
- server: {
- androidScheme: 'https'
- }
-};
-
-export default config;
\ No newline at end of file
diff --git a/components/Avatar.tsx b/components/Avatar.tsx
deleted file mode 100644
index 23d81c84b..000000000
--- a/components/Avatar.tsx
+++ /dev/null
@@ -1,11 +0,0 @@
-export default function Avatar({size, url}) {
- let width = 'w-12';
- if (size === 'lg') {
- width = 'w-24 md:w-36';
- }
- return (
-
{/* Match this with the `avatar_url` inside Supabase storage. Delivered via CDN */}
-

-
- );
-}
\ No newline at end of file
diff --git a/components/Blocks/DetectedAnomalies.tsx b/components/Blocks/DetectedAnomalies.tsx
deleted file mode 100644
index 074a215f4..000000000
--- a/components/Blocks/DetectedAnomalies.tsx
+++ /dev/null
@@ -1,100 +0,0 @@
-import React from "react";
-
-export default function DetectedAnomaliesBlock() {
- return (
-
-
-
-
-
Detected Anomolies
-
-
-
Exoplanets
-
Black Holes
-
-
Meteors
-
Asteroids
-
Unidentified
-
-
-
12
-
11
-
10
-
8
-
5
-
2
-
-
-
-
-
- );
-};
-
-export const CurrentSilfur: React.FC = () => {
- return (
-
-
-
- Current Balance
-
-
- 19,750
- Silfur
-
-
- );
- };
-
-export function MobilePlanetTest () {
- return (
-
-
-
-
-
-

-
-

-
ETHERON
-
-
-
-
-
Day Length
-
12 Earth hours
-
-
-
Avg Temperature
-
60°C to 90°C
-
-
-
-
-

-

-
- )
-}
\ No newline at end of file
diff --git a/components/Blocks/HomePlanetStats.tsx b/components/Blocks/HomePlanetStats.tsx
deleted file mode 100644
index dc89c7f1f..000000000
--- a/components/Blocks/HomePlanetStats.tsx
+++ /dev/null
@@ -1,98 +0,0 @@
-import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react";
-import React, { useEffect, useState } from "react";
-
-export default function HomePlanetStats() {
- const supabase = useSupabaseClient();
- const session = useSession();
-
- const [homePlanetData, setHomePlanetData] = useState(null);
-
- useEffect(() => {
- const fetchPlanetData = async () => {
- if (!session) {
- return;
- };
-
- try {
- const { data, error } = await supabase
- .from('basePlanets')
- .select('*')
- // .eq('id', 1)
- .single();
-
- if (data) {
- setHomePlanetData(data);
- };
-
- if (error) {
- throw error;
- }
-
- console.log(data);
- } catch (error: any) {
- console.error(error.message);
- };
- };
- }, [session]);
-
- // if (!homePlanetData) {
- // return null;
- // }
-
- // const { content, avatar_url, type, deepnote, cover, ticId, temperatureEq, smaxis, mass } = homePlanetData;
-
- return (
-
-
-
-
-
-
-
-
-
-
-
Day Length
-
12 Earth hours
-
-
-
Avg Temperature
-
60°C to 90°C
-
-
-
-
-
-
-
- );
-};
\ No newline at end of file
diff --git a/components/Card.tsx b/components/Card.tsx
deleted file mode 100644
index ffb393c76..000000000
--- a/components/Card.tsx
+++ /dev/null
@@ -1,35 +0,0 @@
-export default function Card({children,noPadding}) {
- let classes = 'bg-white shadow-sm shadow-gray-300 rounded-3xl mb-5';
- if (!noPadding) {
- classes += ' p-4';
- }
- return (
-
- {children}
-
- );
-}
-
-export function ProfileCard({children,noPadding}) {
- let classes = 'bg-white shadow-md shadow-gray-300 rounded-md mb-5 mx-6 w-full';
- if (!noPadding) {
- classes += ' p-4';
- }
- return (
-
- {children}
-
- );
-}
-
-export function createPlanetCard({children,noPadding}) {
- let classes = 'bg-white shadow-md shadow-gray-300 rounded-md mb-5 mx-60';
- if (!noPadding) {
- classes += ' p-4';
- }
- return (
-
- {children}
-
- );
-}
\ No newline at end of file
diff --git a/components/Content/ClassificationFeed.tsx b/components/Content/ClassificationFeed.tsx
deleted file mode 100644
index dbfda21cd..000000000
--- a/components/Content/ClassificationFeed.tsx
+++ /dev/null
@@ -1,414 +0,0 @@
-import React, { useEffect, useState } from "react";
-import { useSession, useSupabaseClient, SupabaseClient } from "@supabase/auth-helpers-react";
-import CardForum, { CommentItem } from "./DiscussCard";
-
-export default function ClassificationFeed({ custommaxWidth = '85%' }) {
- const supabase: SupabaseClient = useSupabaseClient();
- const session = useSession();
-
- const [posts, setPosts] = useState([]);
- // const [profile, setProfile] = useState(null);
- const [planetPosts, setPlanetPosts] = useState([]);
-
- useEffect(() => {
- fetchPosts();
- }, []);
-
- useEffect(() => {
- if (planetPosts.length > 0) {
- console.log("Comments: ", planetPosts.flatMap((post) => post.comments));
- }
- }, []);
-
- async function fetchPosts() {
- const postsResponse = await supabase
- .from("posts_duplicates")
- .select(
- "id, content, created_at, planets2, planetsss(id, temperature), profiles(id, avatar_url, full_name, username)"
- )
- .order('created_at', { ascending: false });
-
- const postIds = postsResponse.data.map((post) => post.id);
- const commentsResponse = await supabase
- .from("comments")
- .select("id, content, created_at, profiles(id, avatar_url, username), post_id") // Add the closing parenthesis for profiles select
- .in("post_id", postIds)
- .order("created_at", { ascending: true });
-
- const commentsByPostId: { [postId: number]: Comment[] } = commentsResponse.data.reduce((acc, comment) => {
- const postId = comment.post_id;
- if (!acc[postId]) {
- acc[postId] = [];
- }
- acc[postId].push(comment);
- return acc;
- }, {});
-
- // const postsWithComments: Post[] = postsResponse.data.map((post) => ({
- const postsWithComments = postsResponse.data.map((post) => ({
- ...post,
- comments: commentsByPostId[post.id] || [],
- }));
-
- setPosts(postsWithComments);
- }
-
- return (
-
- {posts.map((post) => (
- -
-
-
- ))}
-
- );
-};
-
-export function MultiClassificationFeed({ custommaxWidth = '85%' }) {
- const supabase: SupabaseClient = useSupabaseClient();
- const session = useSession();
-
- const [posts, setPosts] = useState([]);
- const [planetPosts, setPlanetPosts] = useState([]);
-
- useEffect(() => {
- fetchPosts();
- }, []);
-
- useEffect(() => {
- if (planetPosts.length > 0) {
- console.log("Comments: ", planetPosts.flatMap((post) => post.comments));
- }
- }, []);
-
- async function fetchPosts() {
- const postsResponse = await supabase
- .from("posts_duplicates")
- .select(
- "id, content, created_at, planets2, planetsss(id, temperature), profiles(id, avatar_url, full_name, username)"
- )
- .order('created_at', { ascending: false });
-
- const roverImagePostsResponse = await supabase
- .from("contentROVERIMAGES")
- .select("id, content, created_at")
- .order('created_at', { ascending: false });
-
- const combinedPosts = [...postsResponse.data, ...roverImagePostsResponse.data];
-
- const sortedPosts = combinedPosts.sort((a: { created_at: string }, b: { created_at: string }) =>
- new Date(b.created_at).getTime() - new Date(a.created_at).getTime()
- );
-
- setPosts(sortedPosts);
- }
-
- return (
-
- {posts.map((post) => (
- -
-
-
- ))}
-
- );
-}
-
-export function ClassificationFeedDemo() {
- return (
-
-
-
-
-
-
-
-

-
-
-
-

-
-
-
-
-
-
-
As seen in the jupyter snippet where the period is set (which can be observed in the binned data, allowing us to phase fold the dips to showcase a potential/likely transit event), we have a consistent dipping occur over a period of ~30 days, with a similar amount of light being blocked out each time. This body is likely to be extremely close to its parent star and as such will likely be tidally locked.
-
-
-
-
-
-
That is quite the discovery you have made there sir!
-
-
-
-
-
-
-

-
-
-
-
-
-
Thankyou, i cannot believe i am speaking with the real Benjamin Franklin!
-
-
-
-
-
-
-
-

-
-
-
-
-
-
-
-
-
-
-
-
-

-
-
-
-
-
-
-
- )
-}
-
-export function ClassificationFeedForIndividualPlanet(planetId, backgroundColorSet) {
- const supabase: SupabaseClient = useSupabaseClient();
- const session = useSession();
-
- const [posts, setPosts] = useState([]);
- // const [profile, setProfile] = useState(null);
- const [planetPosts, setPlanetPosts] = useState([]);
-
- useEffect(() => {
- fetchPosts();
- }, []);
-
- useEffect(() => {
- if (planetPosts.length > 0) {
- console.log("Comments: ", planetPosts.flatMap((post) => post.comments));
- }
- }, []);
-
- async function fetchPosts() {
- try {
- const postsResponse = await supabase
- .from("classifications")
- // .select("id, content, created_at, author, anomaly, basePlanets, profiles(id, avatar_url, full_name, username)")
- .select("id, created_at, content, anomaly, media, profiles(id, avatar_url, full_name, username)")
- .eq('anomaly', planetId.planetId.id)
- .order('created_at', { ascending: false });
-
- if (postsResponse.error || !postsResponse.data) {
- console.error("Error fetching posts:", postsResponse.error);
- return;
- }
-
- const postIds = postsResponse.data.map((post) => post.id);
-
- const commentsResponse = await supabase
- .from("comments")
- .select("id, content, created_at, profiles(id, avatar_url, username), post_id")
- .in("post_id", postIds)
- .order("created_at", { ascending: true });
-
- const commentsByPostId = commentsResponse.data.reduce((acc, comment) => {
- const postId = comment.post_id;
- if (!acc[postId]) {
- acc[postId] = [];
- }
- acc[postId].push(comment);
- return acc;
- }, {});
-
- const postsWithComments = postsResponse.data.map((post) => ({
- ...post,
- comments: commentsByPostId[post.id] || [],
- }));
-
- setPosts(postsWithComments);
- // console.log(posts);
- } catch (error) {
- console.error("Error fetching posts:", error.message);
- }
- }
-
- return (
-
- {posts.map((post) => (
- <>
-
-
{post.planetId}
- >
- ))}
-
- );
-};
-
-export function ClassificationFeedForIndividualPlanetDuplicates(planetId) {
- const supabase: SupabaseClient = useSupabaseClient();
- const session = useSession();
-
- const [posts, setPosts] = useState([]);
- // const [profile, setProfile] = useState(null);
- const [planetPosts, setPlanetPosts] = useState([]);
-
- useEffect(() => {
- fetchPosts();
- }, []);
-
- useEffect(() => {
- if (planetPosts.length > 0) {
- console.log("Comments: ", planetPosts.flatMap((post) => post.comments));
- }
- }, []);
-
- async function fetchPosts() {
- try {
- const postsResponse = await supabase
- .from("posts_duplicates")
- .select(
- "id, anomaly, content, created_at, planets2, planetsss(id, temperature), profiles(id, avatar_url, full_name, username)"
- )
- // .eq('anomaly', planetId) // 'planets2', planetId
- .order('created_at', { ascending: false });
-
- if (postsResponse.error || !postsResponse.data) {
- console.error("Error fetching posts:", postsResponse.error);
- return;
- }
-
- const postIds = postsResponse.data.map((post) => post.id);
-
- const commentsResponse = await supabase
- .from("comments")
- .select("id, content, created_at, profiles(id, avatar_url, username), post_id")
- .in("post_id", postIds)
- .order("created_at", { ascending: true });
-
- const commentsByPostId = commentsResponse.data.reduce((acc, comment) => {
- const postId = comment.post_id;
- if (!acc[postId]) {
- acc[postId] = [];
- }
- acc[postId].push(comment);
- return acc;
- }, {});
-
- const postsWithComments = postsResponse.data.map((post) => ({
- ...post,
- comments: commentsByPostId[post.id] || [],
- }));
-
- setPosts(postsWithComments);
- console.log(posts);
- } catch (error) {
- console.error("Error fetching posts:", error.message);
- }
- }
-
- return (
-
- {posts.map((post) => (
- <>
-
-
{post.planetId}
- >
- ))}
-
- );
-};
\ No newline at end of file
diff --git a/components/Content/Classify/AnomalyPostFormCard.tsx b/components/Content/Classify/AnomalyPostFormCard.tsx
deleted file mode 100644
index 2112f3693..000000000
--- a/components/Content/Classify/AnomalyPostFormCard.tsx
+++ /dev/null
@@ -1,195 +0,0 @@
-import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react";
-import { useRouter } from "next/router";
-import { useEffect, useState } from "react";
-import { ClimbingBoxLoader } from "react-spinners";
-
-export default function PostFormCardAnomalyTag({ onPost, planetId }) {
- const supabase = useSupabaseClient();
- const session = useSession();
-
- const [content, setContent] = useState('');
- const profile = session?.user?.id;
- const [avatar_url, setAvatarUrl] = useState(null);
- const [uploads, setUploads] = useState([]);
- const [isUploading, setIsUploading] = useState(false);
- /* const [userExperience, setUserExperience] = useState();
- const [hasRequiredItem, setHasRequiredItem] = useState(false); */
-
- const router = useRouter();
- const anomalytId = router.query.id;
-
- // Check if user has items to make post -> not required functionality yet
-
- // Create the publication
- async function createPost() {
- // Will add an identifier to determine the number of posts mentioning the planet, as that will affect the classification rating
-
- supabase
- .from("classifications")
- .insert({
- author: profile,
- content,
- media: uploads,
- // planets2: planetId,
- anomaly: planetId, // Set this to multiple anomaly types/foreign key options
- }).then(response => {
- if (!response.error) {
- alert(`Post ${content} created`);
- setContent('');
- // setUploads([]);
- if ( onPost ) {
- onPost();
- }
- }
- });
-
- // .then (update user experience/currency)
- }
-
- /* Get user avatar & other data
- useEffect(() => {
- supabase
- .from('profiles')
- .select(`avatatar_url`)
- .eq("id", profile)
- .then((result) => {
- setAvatarUrl(result?.data[0]?.avatatar_url);
- });
- }, [session]); */
-
- // Function to add media to the publication
- async function addMedia ( e ) {
- const files = e.target.files;
- if (files.length > 0) {
- setIsUploading(true);
- for (const file of files) {
- const fileName = Date.now() + session?.user?.id + file.name;
- const result = await supabase.storage
- .from('media')
- .upload(fileName, file);
-
- if (result.data) {
- const url = process.env.NEXT_PUBLIC_SUPABASE_URL + '/storage/v1/object/public/media/' + result.data.path;
- setUploads(prevUploads => [...prevUploads, url]);
- } else {
- console.log(result);
- }
- }
- setIsUploading(false);
- };
- };
-
- // Frontend output
- return (
-
-
- {/*
-

-
*/}
-
-
- )
-}
-
-export function PostFormCardAnomalyTagOldSchema({ onPost, planetId }) {
- const supabase = useSupabaseClient();
- const session = useSession();
-
- const [content, setContent] = useState('');
- const profile = session?.user?.id;
- const [avatar_url, setAvatarUrl] = useState(null);
- /* const [uploads, setUploads] = useState([]);
- const [isUploading, setIsUploading] = useState(false);
- const [userExperience, setUserExperience] = useState();
- const [hasRequiredItem, setHasRequiredItem] = useState(false); */
-
- const router = useRouter();
- const anomalytId = router.query.id;
-
- // Check if user has items to make post -> not required functionality yet
-
- // Create the publication
- async function createPost() {
- // Will add an identifier to determine the number of posts mentioning the planet, as that will affect the classification rating
-
- supabase
- .from("posts_duplicates")
- .insert({
- author: profile,
- content,
- // media: uploads
- // planets2: planetId,
- anomaly: planetId, // Set this to multiple anomaly types/foreign key options
- }).then(response => {
- if (!response.error) {
- alert(`Post ${content} created`);
- setContent('');
- // setUploads([]);
- if ( onPost ) {
- onPost();
- }
- }
- });
-
- // .then (update user experience/currency)
- }
-
- /* Get user avatar & other data
- useEffect(() => {
- supabase
- .from('profiles')
- .select(`avatatar_url`)
- .eq("id", profile)
- .then((result) => {
- setAvatarUrl(result?.data[0]?.avatatar_url);
- });
- }, [session]); */
-
- // Function to add media to the publication
-
- // Frontend output
- return (
- <>
-
- {/*
-

-
*/}
-
- >
- )
-}
\ No newline at end of file
diff --git a/components/Content/CreatePostForm.tsx b/components/Content/CreatePostForm.tsx
deleted file mode 100644
index 767e1b874..000000000
--- a/components/Content/CreatePostForm.tsx
+++ /dev/null
@@ -1,186 +0,0 @@
-import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react";
-import { Button } from "../ui/Button";
-import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "../ui/Card";
-import { Form, FormControl, FormField, FormItem, FormMessage } from "../ui/Form";
-import { Textarea } from "../ui/TextArea";
-import { useToast } from "../ui/use-toast";
-import { zodResolver } from "@hookform/resolvers/zod";
-import { VenetianMask } from "lucide-react";
-import React, { useContext, useEffect, useState} from "react";
-import { useForm } from "react-hook-form";
-import { UserContext } from "../../context/UserContext";
-import { useRouter } from "next/router";
-import { Avatar, AvatarFallback } from "../ui/Avatar";
-import { AvatarImage } from "@radix-ui/react-avatar";
-
-type TProps = {
- category_id: "1" | "2",
- openCreateMenu: boolean;
- setOpenCreateMenu: (value: React.SetStateAction) => void;
- setCreatedPost: (value: React.SetStateAction) => void;
-};
-
-export default function CreatePostForm ( { planetId2 } ) { // category_id
- const supabase = useSupabaseClient();
- const session = useSession();
-
- const [postContent, setPostContent] = useState('')
- const profile = useContext(UserContext);
- const [username, setUsername] = useState('');
-
- const [uploads, SetUploads] = useState('');
- const [isUploading, setIsUploading] = useState(false);
- const [avatar_url, setAvatarUrl] = useState(null);
- const [userExperience, setUserExperience] = useState();
- // const [hasRequiredItem, setHasRequiredItem] = useState(false);
-
- function createPost() {
- supabase
- .from('posts_duplicates')
- .insert({
- author: session?.user?.id,
- content: postContent,
- media: uploads,
- planets2: planetId2,
- }).then(async response => {
- if (!response.error) {
- await supabase.from('inventoryPLANETS').insert([
- {
- planet_id: planetId2,
- owner_id: session?.user?.id,
- },
- ]);
-
- setPostContent('');
- }
- })
- };
-
- useEffect(() => {
- supabase
- .from('profiles')
- .select(`avatar_url, experience, username`)
- .eq('id', session?.user?.id)
- .then(result => {
- setAvatarUrl(result?.data[0]?.avatar_url);
- setUsername(result?.data[0]?.username);
- });
- }, [session]);
-
- // async function addMedia ( e ) {
- // const files = e.target.files;
- // if (files.length > 0) {
- // setIsUploading(true);
- // for (const file of files) { // To-Do: List of user's photos from the image gallery in wb3-10
- // const fileName = Date.now() + session?.user?.id + file.name; // Generate a random string to make the file unique
- // const result = await supabase.storage
- // .from('media') // Upload the file/media
- // .upload(fileName, file);
-
- // if (result.data) {
- // const url = process.env.NEXT_PUBLIC_SUPABASE_URL + '/storage/v1/object/public/media/' + result.data.path;
- // SetUploads(prevUploads => [...prevUploads, url]); // Add the most recently uploaded image to an array of images that are in state
- // } else {
- // console.log(result);
- // }
- // }
- // setIsUploading(false);
- // }
- // }
-
- const form = useForm({
- defaultValues: {
- content: "",
- },
- });
-
- return (
- <>
-
-
- {/* */}
- {username}
- {/* */}
-
-
- {/*
-
- */}
-