diff --git a/backend/README.md b/backend/README.md index 8bddbe5..3f10392 100644 --- a/backend/README.md +++ b/backend/README.md @@ -1,6 +1,6 @@ # Instructions for Starting Express Backend -- Create a postgres database, then go to database.js -- Modify database name, username, and password for Sequelize +- Follow instructions in .env.template and rename to .env +- OPTIONAL: Run node seed.js in terminal - Run npm install in terminal - Run npm run start in terminal diff --git a/backend/seed.js b/backend/seed.js index f19dc3a..b5ad860 100644 --- a/backend/seed.js +++ b/backend/seed.js @@ -3,6 +3,14 @@ import path from "path"; import { fileURLToPath } from "url"; import bcrypt from "bcrypt"; import { User } from "./models/user.js"; +import { Stock } from "./models/stock.js"; +import { Like } from "./models/like.js"; +import { Dislike } from "./models/dislike.js"; +import { Follow } from "./models/follow.js"; +import { Friend } from "./models/friend.js"; +import { Comment } from "./models/comment.js"; +import { Post } from "./models/post.js"; +import { PostComment } from "./models/postComment.js"; import { sequelize } from "./database.js"; const filename = fileURLToPath(import.meta.url); @@ -12,9 +20,88 @@ const userData = JSON.parse( fs.readFileSync(path.resolve(dirname, "./seeders/users.json"), "utf8") ); +const stockData = JSON.parse( + fs.readFileSync(path.resolve(dirname, "./seeders/stocks.json"), "utf8") +); + +const generateRandomStockComment = (numUsers, numStocks) => { + const contentOptions = [ + "Great company!", + "Interesting stock to watch.", + "Not sure about this one.", + "Seems like a solid investment.", + "I've heard mixed reviews.", + "High risk, high reward.", + "Definitely worth considering.", + "Not on my radar.", + "Hoping for good earnings." + ]; + + return { + content: + contentOptions[Math.floor(Math.random() * contentOptions.length)], + UserId: Math.floor(Math.random() * numUsers) + 1, + StockId: Math.floor(Math.random() * numStocks) + 1 + }; +}; + +const generateFixedPosts = (numUsers) => { + const postsData = [ + { + title: "Analyzing Market Trends", + content: `As the stock market continues to experience volatility, it's crucial for investors to stay informed about the latest market trends and shifts. In this post, I'll delve into the factors driving recent market movements and share insights on potential investment opportunities. From macroeconomic indicators to sector-specific developments, we'll explore the key drivers shaping the market landscape.`, + UserId: Math.floor(Math.random() * numUsers) + 1 + }, + { + title: "Strategies for Portfolio Diversification", + content: `Portfolio diversification is a cornerstone of effective risk management in investing. In this article, I'll discuss various strategies for achieving a well-diversified portfolio. From asset allocation and sector exposure to geographic diversification, we'll explore practical steps to reduce risk and enhance potential returns.`, + UserId: Math.floor(Math.random() * numUsers) + 1 + }, + { + title: "Evaluating Earnings Reports", + content: `Earnings reports play a crucial role in stock analysis and decision-making. In this comprehensive guide, I'll walk you through the process of evaluating earnings reports, including key metrics such as revenue, earnings per share (EPS), and profit margins. We'll also discuss the importance of forward guidance and how earnings reports can impact stock prices.`, + UserId: Math.floor(Math.random() * numUsers) + 1 + }, + { + title: "Navigating Volatile Markets", + content: `Market volatility is an inherent part of investing, and understanding how to navigate turbulent markets is essential for long-term success. In this post, I'll share strategies for managing investments during periods of heightened volatility. From setting stop-loss orders to identifying opportunities amid market swings, we'll explore ways to stay resilient in the face of uncertainty.`, + UserId: Math.floor(Math.random() * numUsers) + 1 + }, + { + title: "The Role of Interest Rates in Stock Valuation", + content: `Interest rates exert a significant influence on stock valuations and market dynamics. In this insightful article, I'll delve into the relationship between interest rates and stock prices. We'll explore how changes in interest rates impact different sectors, the concept of discount rates in valuation models, and considerations for investors in a changing rate environment.`, + UserId: Math.floor(Math.random() * numUsers) + 1 + }, + { + title: "Identifying Promising Growth Stocks", + content: `Identifying growth stocks with strong potential is a goal for many investors. In this post, I'll outline a systematic approach to identifying promising growth stocks. From assessing revenue growth and market share expansion to analyzing competitive advantages, we'll cover the key criteria to consider when evaluating stocks for long-term growth.`, + UserId: Math.floor(Math.random() * numUsers) + 1 + } + ]; + + return postsData; +}; + +const generateRandomPostComment = (numUsers, numPosts) => { + const contents = [ + "Great post! Thanks for sharing your insights.", + "I found this analysis very informative.", + "Interesting perspective. I agree with your points.", + "Could you elaborate more on this topic?", + "I have a different viewpoint on this issue.", + "Looking forward to your next post!" + ]; + + return { + content: contents[Math.floor(Math.random() * contents.length)], + UserId: Math.floor(Math.random() * numUsers) + 1, + PostId: Math.floor(Math.random() * numPosts) + 1 + }; +}; + const seedDatabase = async () => { try { - await sequelize.sync({ alter: true }); + await sequelize.sync({ force: true }); const usersWithHashedPasswords = await Promise.all( userData.map(async (user) => { @@ -23,8 +110,124 @@ const seedDatabase = async () => { }) ); - await User.bulkCreate(usersWithHashedPasswords); + const createdUsers = await User.bulkCreate(usersWithHashedPasswords); console.log("User data has been seeded!"); + + const createdStocks = await Stock.bulkCreate(stockData); + console.log("Stock data has been seeded!"); + + const postsData = generateFixedPosts(createdUsers.length); + + const createdPosts = await Post.bulkCreate(postsData); + console.log("Post data has been seeded!"); + + const numPostCommentsToGenerate = 100; + const postCommentsData = Array.from( + { length: numPostCommentsToGenerate }, + () => + generateRandomPostComment( + createdUsers.length, + createdPosts.length + ) + ); + + await PostComment.bulkCreate(postCommentsData); + console.log("PostComment data has been seeded!"); + + const numCommentsToGenerate = 300; + const commentsData = Array.from({ length: numCommentsToGenerate }, () => + generateRandomStockComment( + createdUsers.length, + createdStocks.length + ) + ); + + await Comment.bulkCreate(commentsData); + console.log("Comment data has been seeded!"); + + const likeRelationships = []; + const dislikeRelationships = []; + const followRelationships = []; + const friendRelationships = []; + + createdUsers.forEach((user) => { + const numStocksToLike = Math.floor( + Math.random() * (createdStocks.length + 1) + ); + const numStocksToDislike = Math.floor( + Math.random() * (createdStocks.length + 1) + ); + const numStocksToFollow = Math.floor( + Math.random() * (createdStocks.length + 1) + ); + const numFriends = Math.floor( + Math.random() * (createdUsers.length + 1) + ); + + const randomStocks = [...createdStocks]; + const randomUsers = [...createdUsers]; + + for (let i = randomStocks.length - 1; i > 0; i--) { + const j = Math.floor(Math.random() * (i + 1)); + [randomStocks[i], randomStocks[j]] = [ + randomStocks[j], + randomStocks[i] + ]; + } + + for (let i = randomUsers.length - 1; i > 0; i--) { + const j = Math.floor(Math.random() * (i + 1)); + [randomUsers[i], randomUsers[j]] = [ + randomUsers[j], + randomUsers[i] + ]; + } + + const stocksToLike = randomStocks.slice(0, numStocksToLike); + const stocksToDislike = randomStocks.slice(0, numStocksToDislike); + const stocksToFollow = randomStocks.slice(0, numStocksToFollow); + const friends = randomUsers.slice(0, numFriends); + + stocksToLike.forEach((stock) => { + likeRelationships.push({ + UserId: user.id, + StockId: stock.id + }); + }); + + stocksToDislike.forEach((stock) => { + dislikeRelationships.push({ + UserId: user.id, + StockId: stock.id + }); + }); + + stocksToFollow.forEach((stock) => { + followRelationships.push({ + UserId: user.id, + StockId: stock.id + }); + }); + + friends.forEach((friend) => { + friendRelationships.push({ + UserId1: user.id, + UserId2: friend.id + }); + }); + }); + + await Like.bulkCreate(likeRelationships); + console.log("Like relationships have been seeded!"); + + await Dislike.bulkCreate(dislikeRelationships); + console.log("Dislike relationships have been seeded!"); + + await Follow.bulkCreate(followRelationships); + console.log("Follow relationships have been seeded!"); + + await Friend.bulkCreate(friendRelationships); + console.log("Friend relationships have been seeded!"); } catch (error) { console.error("Error seeding data:", error); } finally { diff --git a/backend/seeders/stocks.json b/backend/seeders/stocks.json new file mode 100644 index 0000000..2090168 --- /dev/null +++ b/backend/seeders/stocks.json @@ -0,0 +1,194 @@ +[ + { + "ticker": "META", + "name": "Meta Platforms Inc.", + "description": "Meta Platforms, Inc. develops products that enable people to connect and share with friends and family through mobile devices, PCs, virtual reality headsets, wearables and home devices around the world. The company is headquartered in Menlo Park, California.", + "sector": "Technology", + "price": 312.83, + "logo": "https://static2.finnhub.io/file/publicdatany/finnhubimage/stock_logo/FB.svg" + }, + { + "ticker": "GOOG", + "name": "Alphabet Inc Class C", + "description": "Alphabet Inc. is an American multinational conglomerate headquartered in Mountain View, California. It was created through a restructuring of Google on October 2, 2015, and became the parent company of Google and several former Google subsidiaries. The two co-founders of Google remained as controlling shareholders, board members, and employees at Alphabet. Alphabet is the world's fourth-largest technology company by revenue and one of the world's most valuable companies.", + "sector": "Technology", + "price": 131.6899, + "logo": "https://static2.finnhub.io/file/publicdatany/finnhubimage/stock_logo/GOOG.svg" + }, + { + "ticker": "AAPL", + "name": "Apple Inc", + "description": "Apple Inc. is an American multinational technology company that specializes in consumer electronics, computer software, and online services. Apple is the world's largest technology company by revenue (totalling $274.5 billion in 2020) and, since January 2021, the world's most valuable company. As of 2021, Apple is the world's fourth-largest PC vendor by unit sales, and fourth-largest smartphone manufacturer. It is one of the Big Five American information technology companies, along with Amazon, Google, Microsoft, and Facebook.", + "sector": "Technology", + "price": 178.51, + "logo": "https://static2.finnhub.io/file/publicdatany/finnhubimage/stock_logo/AAPL.svg" + }, + { + "ticker": "AMZN", + "name": "Amazon.com Inc", + "description": "Amazon.com, Inc. is an American multinational technology company which focuses on e-commerce, cloud computing, digital streaming, and artificial intelligence. It is one of the Big Five companies in the U.S. information technology industry, along with Google, Apple, Microsoft, and Facebook. The company has been referred to as one of the most influential economic and cultural forces in the world, as well as the world's most valuable brand.", + "sector": "Trade & Services", + "price": 142.25, + "logo": "https://static2.finnhub.io/file/publicdatany/finnhubimage/stock_logo/AMZN.svg" + }, + { + "ticker": "TSLA", + "name": "Tesla Inc", + "description": "Tesla, Inc. is an American electric vehicle and clean energy company based in Palo Alto, California. Tesla's current products include electric cars, battery energy storage from home to grid-scale, solar panels and solar roof tiles, as well as other related products and services. In 2020, Tesla had the highest sales in the plug-in and battery electric passenger car segments, capturing 16% of the plug-in market (which includes plug-in hybrids) and 23% of the battery-electric (purely electric) market. Through its subsidiary Tesla Energy, the company develops and is a major installer of solar photovoltaic energy generation systems in the United States. Tesla Energy is also one of the largest global suppliers of battery energy storage systems, with 3 GWh of battery storage supplied in 2020.", + "sector": "Manufacturing", + "price": 250.35, + "logo": "https://static2.finnhub.io/file/publicdatany/finnhubimage/stock_logo/TSLA.svg" + }, + { + "ticker": "MSFT", + "name": "Microsoft Corporation", + "description": "Microsoft Corporation is an American multinational technology company which produces computer software, consumer electronics, personal computers, and related services. Its best known software products are the Microsoft Windows line of operating systems, the Microsoft Office suite, and the Internet Explorer and Edge web browsers. Its flagship hardware products are the Xbox video game consoles and the Microsoft Surface lineup of touchscreen personal computers. Microsoft ranked No. 21 in the 2020 Fortune 500 rankings of the largest United States corporations by total revenue; it was the world's largest software maker by revenue as of 2016. It is considered one of the Big Five companies in the U.S. information technology industry, along with Google, Apple, Amazon, and Facebook.", + "sector": "Technology", + "price": 330.11, + "logo": "https://static2.finnhub.io/file/publicdatany/finnhubimage/stock_logo/MSFT.svg" + }, + { + "ticker": "M", + "name": "Macy’s Inc", + "description": "Macy's, Inc., an omnichannel retail organization, operates stores, websites, and mobile apps under the Macy's, Bloomingdale's and bluemercury brands. The company is headquartered in New York, New York.", + "sector": "Trade & Services", + "price": 16.04, + "logo": "https://static2.finnhub.io/file/publicdatany/finnhubimage/stock_logo/M.svg" + }, + { + "ticker": "MS", + "name": "Morgan Stanley", + "description": "Morgan Stanley is an American multinational investment bank and financial services company headquartered at 1585 Broadway in the Morgan Stanley Building, Midtown Manhattan, New York City.", + "sector": "Finance", + "price": 89.08, + "logo": "https://static2.finnhub.io/file/publicdatany/finnhubimage/stock_logo/MS.svg" + }, + { + "ticker": "JPM", + "name": "JPMorgan Chase & Co", + "description": "JPMorgan Chase & Co. is an American multinational investment bank and financial services holding company headquartered in New York City. JPMorgan Chase is incorporated in Delaware. As a Bulge Bracket bank, it is a major provider of various investment banking and financial services. It is one of America's Big Four banks, along with Bank of America, Citigroup, and Wells Fargo. JPMorgan Chase is considered to be a universal bank and a custodian bank. The J.P. Morgan brand is used by the investment banking, asset management, private banking, private wealth management, and treasury services divisions.", + "sector": "Finance", + "price": 156.76, + "logo": "https://static2.finnhub.io/file/publicdatany/finnhubimage/stock_logo/JPM.svg" + }, + { + "ticker": "PYPL", + "name": "PayPal Holdings Inc", + "description": "PayPal Holdings, Inc. is an American company operating an online payments system in the majority of countries that support online money transfers, and serves as an electronic alternative to traditional paper methods like checks and money orders. The company operates as a payment processor for online vendors, auction sites, and many other commercial users, for which it charges a fee.", + "sector": "Trade & Services", + "price": 64.42, + "logo": "https://static2.finnhub.io/file/publicdatany/finnhubimage/stock_logo/PYPL.svg" + }, + { + "ticker": "NFLX", + "name": "Netflix Inc", + "description": "Netflix, Inc. is an American over-the-top content platform and production company headquartered in Los Gatos, California. Netflix was founded in 1997 by Reed Hastings and Marc Randolph in Scotts Valley, California. The company's primary business is a subscription-based streaming service offering online streaming from a library of films and television series, including those produced in-house.", + "sector": "Trade & Services", + "price": 440.76, + "logo": "https://static2.finnhub.io/file/publicdatany/finnhubimage/stock_logo/NFLX.svg" + }, + { + "ticker": "QCOM", + "name": "Qualcomm Incorporated", + "description": "Qualcomm is an American multinational corporation headquartered in San Diego, California, and incorporated in Delaware. It creates semiconductors, software, and services related to wireless technology. It owns patents critical to the 5G, 4G, CDMA2000, TD-SCDMA and WCDMA mobile communications standards.", + "sector": "Manufacturing", + "price": 119.34, + "logo": "https://static2.finnhub.io/file/publicdatany/finnhubimage/stock_logo/QCOM.svg" + }, + { + "ticker": "Z", + "name": "Zillow Group Inc Class C", + "description": "Zillow Group, Inc., a digital real estate company, operates real estate brands on mobile apps and websites in the United States. The company is headquartered in Seattle, Washington.", + "sector": "Trade & Services", + "price": 55.99, + "logo": "https://static2.finnhub.io/file/publicdatany/finnhubimage/stock_logo/ZG.svg" + }, + { + "ticker": "ZM", + "name": "Zoom Video Communications Inc", + "description": "Zoom Video Communications, Inc. provides a premier video communications platform in the Americas, Asia Pacific, Europe, the Middle East, and Africa. The company is headquartered in San Jose, California.", + "sector": "Technology", + "price": 68.66, + "logo": "https://static2.finnhub.io/file/publicdatany/finnhubimage/stock_logo/ZM.svg" + }, + { + "ticker": "AM", + "name": "Antero Midstream Partners LP", + "description": "Antero Midstream Corporation owns, operates and develops midstream energy infrastructure. The company is headquartered in Denver, Colorado.", + "sector": "Energy & Transportation", + "price": 11.97, + "logo": "https://static2.finnhub.io/file/publicdatany/finnhubimage/stock_logo/AM.svg" + }, + { + "ticker": "D", + "name": "Dominion Energy Inc", + "description": "Dominion Energy, Inc., commonly referred to as Dominion, is an American power and energy company headquartered in Richmond, Virginia that supplies electricity in parts of Virginia, North Carolina, and South Carolina and supplies natural gas to parts of Utah, West Virginia, Ohio, Pennsylvania, North Carolina, South Carolina, and Georgia. Dominion also has generation facilities in Indiana, Illinois, Connecticut, and Rhode Island.", + "sector": "Energy & Transportation", + "price": 49.14, + "logo": "https://static2.finnhub.io/file/publicdatany/finnhubimage/stock_logo/D.svg" + }, + { + "ticker": "MC", + "name": "Moelis & Co", + "description": "Moelis & Company is an investment banking advisory firm in the United States, Europe, and internationally. The company is headquartered in New York, New York.", + "sector": "Finance", + "price": 48.45, + "logo": "https://static2.finnhub.io/file/publicdatany/finnhubimage/stock_logo/MC.svg" + }, + { + "ticker": "K", + "name": "Kellogg Company", + "description": "The Kellogg Company, doing business as Kellogg's, is an American multinational food manufacturing company headquartered in Battle Creek, Michigan, United States.", + "sector": "Manufacturing", + "price": 64.81, + "logo": "https://static2.finnhub.io/file/publicdatany/finnhubimage/stock_logo/K.svg" + }, + { + "ticker": "CVS", + "name": "CVS Health Corp", + "description": "CVS Health (previously CVS Corporation and CVS Caremark Corporation) is an American healthcare company that owns CVS Pharmacy, a retail pharmacy chain; CVS Caremark, a pharmacy benefits manager; Aetna, a health insurance provider, among many other brands. The company's headquarters is in Woonsocket, Rhode Island.", + "sector": "Trade & Services", + "price": 73.91, + "logo": "https://static2.finnhub.io/file/publicdatany/finnhubimage/stock_logo/CVS.svg" + }, + { + "ticker": "WMT", + "name": "Walmart Inc", + "description": "Walmart Inc. is an American multinational retail corporation that operates a chain of hypermarkets, discount department stores, and grocery stores from the United States, headquartered in Bentonville, Arkansas. It also owns and operates Sam's Club retail warehouses.", + "sector": "Trade & Services", + "price": 160.49, + "logo": "https://static2.finnhub.io/file/publicdatany/finnhubimage/stock_logo/WMT.svg" + }, + { + "ticker": "YOU", + "name": "Clear Secure Inc", + "description": "Clear Secure, Inc. is focused on operating as a holding company for Alclear Holdings LLC providing a member-centric secure identity platform using biometric data in the United States. The company is headquartered in New York, New York.", + "sector": "Technology", + "price": 23.39, + "logo": "https://static2.finnhub.io/file/publicdatany/finnhubimage/stock_logo/950802031546.svg" + }, + { + "ticker": "BOX", + "name": "Box Inc", + "description": "Box, Inc. provides a cloud content management platform that enables organizations of various sizes to manage and share their content from anywhere and on any device. The company is headquartered in Redwood City, California.", + "sector": "Technology", + "price": 31.12, + "logo": "https://static2.finnhub.io/file/publicdatany/finnhubimage/stock_logo/BOX.svg" + }, + { + "ticker": "V", + "name": "Visa Inc. Class A", + "description": "Visa Inc. is an American multinational financial services corporation headquartered in Foster City, California, United States. It facilitates electronic funds transfers throughout the world, most commonly through Visa-branded credit cards, debit cards and prepaid cards. Visa is one of the world's most valuable companies.", + "sector": "Trade & Services", + "price": 241.51, + "logo": "https://static2.finnhub.io/file/publicdatany/finnhubimage/stock_logo/V.svg" + }, + { + "ticker": "C", + "name": "Citigroup Inc", + "description": "Citigroup Inc. is an American multinational investment bank and financial services corporation headquartered in New York City. The company was formed by the merger of banking giant Citicorp and financial conglomerate Travelers Group in 1998; Travelers was subsequently spun off from the company in 2002. Citigroup owns Citicorp, the holding company for Citibank, as well as several international subsidiaries. Citigroup is incorporated in Delaware.", + "sector": "Finance", + "price": 45.765, + "logo": "https://static2.finnhub.io/file/publicdatany/finnhubimage/stock_logo/C.svg" + } +] diff --git a/backend/seeders/users.json b/backend/seeders/users.json index 628b4eb..7af6a12 100644 --- a/backend/seeders/users.json +++ b/backend/seeders/users.json @@ -1,142 +1,142 @@ [ { - "fullName": "John Doe", - "username": "johndoe", - "email": "john.doe@example.com", - "password": "password123", + "fullName": "John Smith", + "username": "johnsmith", + "email": "johnsmith@example.com", + "password": "meta123", "picture": "https://t3.ftcdn.net/jpg/00/64/67/52/360_F_64675209_7ve2XQANuzuHjMZXP3aIYIpsDKEbF5dD.jpg" }, { - "fullName": "Jane Smith", - "username": "janesmith", - "email": "jane.smith@example.com", - "password": "password456", + "fullName": "Jane Johnson", + "username": "janejohnson", + "email": "janejohnson@example.com", + "password": "meta123", "picture": "https://t3.ftcdn.net/jpg/00/64/67/52/360_F_64675209_7ve2XQANuzuHjMZXP3aIYIpsDKEbF5dD.jpg" }, { - "fullName": "Michael Johnson", - "username": "michaeljohnson", - "email": "michael.johnson@example.com", - "password": "password789", + "fullName": "Michael Brown", + "username": "michaelbrown", + "email": "michaelbrown@example.com", + "password": "meta123", "picture": "https://t3.ftcdn.net/jpg/00/64/67/52/360_F_64675209_7ve2XQANuzuHjMZXP3aIYIpsDKEbF5dD.jpg" }, { - "fullName": "Emily Brown", - "username": "emilybrown", - "email": "emily.brown@example.com", - "password": "password012", + "fullName": "Emily Lee", + "username": "emilylee", + "email": "emilylee@example.com", + "password": "meta123", "picture": "https://t3.ftcdn.net/jpg/00/64/67/52/360_F_64675209_7ve2XQANuzuHjMZXP3aIYIpsDKEbF5dD.jpg" }, { - "fullName": "William Lee", - "username": "williamlee", - "email": "william.lee@example.com", - "password": "password345", + "fullName": "William Wilson", + "username": "williamwilson", + "email": "williamwilson@example.com", + "password": "meta123", "picture": "https://t3.ftcdn.net/jpg/00/64/67/52/360_F_64675209_7ve2XQANuzuHjMZXP3aIYIpsDKEbF5dD.jpg" }, { - "fullName": "Olivia Wilson", - "username": "oliviawilson", - "email": "olivia.wilson@example.com", - "password": "password678", + "fullName": "Olivia Taylor", + "username": "oliviataylor", + "email": "oliviataylor@example.com", + "password": "meta123", "picture": "https://t3.ftcdn.net/jpg/00/64/67/52/360_F_64675209_7ve2XQANuzuHjMZXP3aIYIpsDKEbF5dD.jpg" }, { - "fullName": "James Anderson", - "username": "jamesanderson", - "email": "james.anderson@example.com", - "password": "password901", + "fullName": "James Martinez", + "username": "jamesmartinez", + "email": "jamesmartinez@example.com", + "password": "meta123", "picture": "https://t3.ftcdn.net/jpg/00/64/67/52/360_F_64675209_7ve2XQANuzuHjMZXP3aIYIpsDKEbF5dD.jpg" }, { - "fullName": "Sophia Martinez", - "username": "sophiamartinez", - "email": "sophia.martinez@example.com", - "password": "password234", + "fullName": "Sophia Clark", + "username": "sophiaclark", + "email": "sophiaclark@example.com", + "password": "meta123", "picture": "https://t3.ftcdn.net/jpg/00/64/67/52/360_F_64675209_7ve2XQANuzuHjMZXP3aIYIpsDKEbF5dD.jpg" }, { - "fullName": "Benjamin Taylor", - "username": "benjamintaylor", - "email": "benjamin.taylor@example.com", - "password": "password567", + "fullName": "Benjamin Hernandez", + "username": "benjaminhernandez", + "email": "benjaminhernandez@example.com", + "password": "meta123", "picture": "https://t3.ftcdn.net/jpg/00/64/67/52/360_F_64675209_7ve2XQANuzuHjMZXP3aIYIpsDKEbF5dD.jpg" }, { - "fullName": "Isabella Clark", - "username": "isabellaclark", - "email": "isabella.clark@example.com", - "password": "password890", + "fullName": "Isabella Anderson", + "username": "isabellaanderson", + "email": "isabellaanderson@example.com", + "password": "meta123", "picture": "https://t3.ftcdn.net/jpg/00/64/67/52/360_F_64675209_7ve2XQANuzuHjMZXP3aIYIpsDKEbF5dD.jpg" }, { - "fullName": "Ethan Hernandez", - "username": "ethanhernandez", - "email": "ethan.hernandez@example.com", - "password": "password123", + "fullName": "Ethan Moore", + "username": "ethanmoore", + "email": "ethanmoore@example.com", + "password": "meta123", "picture": "https://t3.ftcdn.net/jpg/00/64/67/52/360_F_64675209_7ve2XQANuzuHjMZXP3aIYIpsDKEbF5dD.jpg" }, { - "fullName": "Mia Moore", - "username": "miamoore", - "email": "mia.moore@example.com", - "password": "password456", + "fullName": "Mia Martin", + "username": "miamartin", + "email": "miamartin@example.com", + "password": "meta123", "picture": "https://t3.ftcdn.net/jpg/00/64/67/52/360_F_64675209_7ve2XQANuzuHjMZXP3aIYIpsDKEbF5dD.jpg" }, { - "fullName": "Alexander Martin", - "username": "alexandermartin", - "email": "alexander.martin@example.com", - "password": "password789", + "fullName": "Alexander Hall", + "username": "alexanderhall", + "email": "alexanderhall@example.com", + "password": "meta123", "picture": "https://t3.ftcdn.net/jpg/00/64/67/52/360_F_64675209_7ve2XQANuzuHjMZXP3aIYIpsDKEbF5dD.jpg" }, { - "fullName": "Ava Hall", - "username": "avahall", - "email": "ava.hall@example.com", - "password": "password012", + "fullName": "Ava Allen", + "username": "avaallen", + "email": "avaallen@example.com", + "password": "meta123", "picture": "https://t3.ftcdn.net/jpg/00/64/67/52/360_F_64675209_7ve2XQANuzuHjMZXP3aIYIpsDKEbF5dD.jpg" }, { - "fullName": "Daniel Allen", - "username": "danielallen", - "email": "daniel.allen@example.com", - "password": "password345", + "fullName": "Daniel Young", + "username": "danielyoung", + "email": "danielyoung@example.com", + "password": "meta123", "picture": "https://t3.ftcdn.net/jpg/00/64/67/52/360_F_64675209_7ve2XQANuzuHjMZXP3aIYIpsDKEbF5dD.jpg" }, { - "fullName": "Camila Young", - "username": "camilayoung", - "email": "camila.young@example.com", - "password": "password678", + "fullName": "Camila Rodriguez", + "username": "camilarodriguez", + "email": "camilarodriguez@example.com", + "password": "meta123", "picture": "https://t3.ftcdn.net/jpg/00/64/67/52/360_F_64675209_7ve2XQANuzuHjMZXP3aIYIpsDKEbF5dD.jpg" }, { - "fullName": "Matthew Rodriguez", - "username": "matthewrodriguez", - "email": "matthew.rodriguez@example.com", - "password": "password901", + "fullName": "Matthew King", + "username": "matthewking", + "email": "matthewking@example.com", + "password": "meta123", "picture": "https://t3.ftcdn.net/jpg/00/64/67/52/360_F_64675209_7ve2XQANuzuHjMZXP3aIYIpsDKEbF5dD.jpg" }, { - "fullName": "Luna King", - "username": "lunaking", - "email": "luna.king@example.com", - "password": "password234", + "fullName": "Luna Scott", + "username": "lunascott", + "email": "lunascott@example.com", + "password": "meta123", "picture": "https://t3.ftcdn.net/jpg/00/64/67/52/360_F_64675209_7ve2XQANuzuHjMZXP3aIYIpsDKEbF5dD.jpg" }, { - "fullName": "David Scott", - "username": "davidscott", - "email": "david.scott@example.com", - "password": "password567", + "fullName": "David Wright", + "username": "davidwright", + "email": "davidwright@example.com", + "password": "meta123", "picture": "https://t3.ftcdn.net/jpg/00/64/67/52/360_F_64675209_7ve2XQANuzuHjMZXP3aIYIpsDKEbF5dD.jpg" }, { - "fullName": "Ella Wright", - "username": "ellawright", - "email": "ella.wright@example.com", - "password": "password890", + "fullName": "Ella Martinez", + "username": "ellamartinez", + "email": "ellamartinez@example.com", + "password": "meta123", "picture": "https://t3.ftcdn.net/jpg/00/64/67/52/360_F_64675209_7ve2XQANuzuHjMZXP3aIYIpsDKEbF5dD.jpg" } ] diff --git a/frontend/README.md b/frontend/README.md index 8dd3105..1eca920 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -1,5 +1,5 @@ # Instructions for Starting React Frontend -- Add API keys to .env.template and rename to .env +- Follow instructions in .env.template and rename to .env - Run npm install in terminal - Run npm run dev in terminal diff --git a/frontend/src/components/ChatRoom/ChatRoom.css b/frontend/src/components/ChatRoom/ChatRoom.css index c5c6286..13d2897 100644 --- a/frontend/src/components/ChatRoom/ChatRoom.css +++ b/frontend/src/components/ChatRoom/ChatRoom.css @@ -14,6 +14,7 @@ width: 20%; margin-left: 20px; margin-top: 20px; + margin-bottom: 20px; } .friends-card { diff --git a/frontend/src/components/Home/Home.jsx b/frontend/src/components/Home/Home.jsx index b7f8148..fe246dd 100644 --- a/frontend/src/components/Home/Home.jsx +++ b/frontend/src/components/Home/Home.jsx @@ -32,12 +32,14 @@ export default function Home() { setStocks(response.data.stocksYouFollow); setStocksView(true); } else { + dispatch(setLoading(false)); Swal.fire({ icon: "info", title: "Get Started with Stock Zone", text: "Follow any stock to get started." }); setNewsView(true); + return; } } diff --git a/frontend/src/components/StockCarousel/StockCarousel.css b/frontend/src/components/StockCarousel/StockCarousel.css index 1aa57bc..217d00b 100644 --- a/frontend/src/components/StockCarousel/StockCarousel.css +++ b/frontend/src/components/StockCarousel/StockCarousel.css @@ -25,3 +25,7 @@ .carousel-info p { margin: 0px; } + +.no-stocks { + margin: 0 auto; +} diff --git a/frontend/src/components/StockCarousel/StockCarousel.jsx b/frontend/src/components/StockCarousel/StockCarousel.jsx index bfa8c69..1252ed7 100644 --- a/frontend/src/components/StockCarousel/StockCarousel.jsx +++ b/frontend/src/components/StockCarousel/StockCarousel.jsx @@ -52,11 +52,11 @@ export default function StockCarousel() { <> {stocksNotFound ? (
There are no stocks currently in the database, search for a - stock to gain access to the table. + stock to gain access to the carousel.
) : null} diff --git a/frontend/src/components/StockData/StockData.jsx b/frontend/src/components/StockData/StockData.jsx index d7c96dd..ff6c3ea 100644 --- a/frontend/src/components/StockData/StockData.jsx +++ b/frontend/src/components/StockData/StockData.jsx @@ -84,6 +84,20 @@ export default function StockData() { const overviewData = overviewResponse.data; const logoData = logoResponse.data; + if (Object.keys(overviewData).length === 0) { + dispatch(setLoading(false)); + Swal.fire({ + icon: "error", + title: "Stock Not Found", + text: "The stock ticker you entered does not correspond to any existing company." + }).then((result) => { + if (result.isConfirmed) { + navigate("/search"); + } + }); + return; + } + if (overviewData.Note != null) { dispatch(setLoading(false)); Swal.fire({