Skip to content

Commit

Permalink
domain change
Browse files Browse the repository at this point in the history
  • Loading branch information
aadhavanpl committed Sep 12, 2023
1 parent 3510a09 commit 17b4d88
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 50 deletions.
6 changes: 3 additions & 3 deletions lib/global-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function GlobalContextWrapper({ children }) {
= sending user info to backend =
=============================================*/
const data = { user_email: user.email, user_name: user.displayName }
const apiUrlEndpoint = 'https://mockstock.live/api/user-lib'
const apiUrlEndpoint = 'https://www.mockstock.live/api/user-lib'
const response = await fetch(apiUrlEndpoint, {
method: 'POST',
body: JSON.stringify({ data }),
Expand All @@ -59,14 +59,14 @@ export function GlobalContextWrapper({ children }) {
function signOut() {
localStorage.clear()
sessionStorage.clear()
window.location.replace('https://mockstock.live');
window.location.replace('https://www.mockstock.live');
}

/*=============================================
= get user info from backend =
=============================================*/
async function getUserInfo(data) {
const apiUrlEndpointUser = 'https://mockstock.live/api/get-user-lib'
const apiUrlEndpointUser = 'https://www.mockstock.live/api/get-user-lib'
const response = await fetch(apiUrlEndpointUser, {
method: 'POST',
body: JSON.stringify({ data }),
Expand Down
20 changes: 5 additions & 15 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
/** @type {import('next').NextConfig} */

module.exports = {
async headers() {
return [
{
source: '/api/:path*',
headers: [
{ key: "Access-Control-Allow-Origin", value: "*" },
]
}
]
}
}, nextConfig = {
const nextConfig = {
reactStrictMode: true,
swcMinify: true
};
swcMinify: true,
}

module.exports = nextConfig
36 changes: 18 additions & 18 deletions pages/buy.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default function BuyPage() {
/* gets all the stocks from db */
async function getFirstData() {
setLoader(true)
const apiUrlEndpoint = 'https://mockstock.live/api/buy-lib'
const apiUrlEndpoint = 'https://www.mockstock.live/api/buy-lib'
const response = await fetch(apiUrlEndpoint)
const res = await response.json()
setdataResponse(res.products)
Expand Down Expand Up @@ -97,47 +97,47 @@ export default function BuyPage() {

for (let i = 0; i < 51; i += 3) {
console.log(curr_yest_price[i], curr_yest_price[i + 1], curr_yest_price[i + 2])
const currApiYestUpdate = 'https://mockstock.live/api/update-yest-lib'
const currApiYestUpdate = 'https://www.mockstock.live/api/update-yest-lib'
const currResponseYestResult = await fetch(currApiYestUpdate, {
method: 'POST',
body: JSON.stringify({
data: [curr_yest_price[i], curr_yest_price[i + 1], curr_yest_price[i + 2]],
}),
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': 'https://mockstock.live/'
'Access-Control-Allow-Origin': 'https://www.mockstock.live/'
},
})
await currResponseYestResult.json()
}

for (let i = 51; i < 102; i += 3) {
console.log(curr_yest_price[i], curr_yest_price[i + 1], curr_yest_price[i + 2])
const currApiYestUpdate = 'https://mockstock.live/api/update-yest-lib'
const currApiYestUpdate = 'https://www.mockstock.live/api/update-yest-lib'
const currResponseYestResult = await fetch(currApiYestUpdate, {
method: 'POST',
body: JSON.stringify({
data: [curr_yest_price[i], curr_yest_price[i + 1], curr_yest_price[i + 2]],
}),
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': 'https://mockstock.live/'
'Access-Control-Allow-Origin': 'https://www.mockstock.live/'
},
})
await currResponseYestResult.json()
}

for (let i = 102; i < 144; i += 3) {
// console.log(curr_yest_price[i], curr_yest_price[i + 1], curr_yest_price[i + 2])
const currApiYestUpdate = 'https://mockstock.live/api/update-yest-lib'
const currApiYestUpdate = 'https://www.mockstock.live/api/update-yest-lib'
const currResponseYestResult = await fetch(currApiYestUpdate, {
method: 'POST',
body: JSON.stringify({
data: [curr_yest_price[i], curr_yest_price[i + 1], curr_yest_price[i + 2]],
}),
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': 'https://mockstock.live/'
'Access-Control-Allow-Origin': 'https://www.mockstock.live/'
},
})
await currResponseYestResult.json()
Expand All @@ -146,47 +146,47 @@ export default function BuyPage() {

for (let i = 0; i < 51; i += 3) {
// console.log(fetchedData[i], fetchedData[i + 1], fetchedData[i + 2])
const currApiResultUpdate = 'https://mockstock.live/api/update-curr-lib'
const currApiResultUpdate = 'https://www.mockstock.live/api/update-curr-lib'
const currResponseResult = await fetch(currApiResultUpdate, {
method: 'POST',
body: JSON.stringify({ data: [fetchedData[i], fetchedData[i + 1], fetchedData[i + 2]] }),
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': 'https://mockstock.live/'
'Access-Control-Allow-Origin': 'https://www.mockstock.live/'
},
})
await currResponseResult.json()
}

for (let i = 51; i < 102; i += 3) {
// console.log(fetchedData[i], fetchedData[i + 1], fetchedData[i + 2])
const currApiResultUpdate = 'https://mockstock.live/api/update-curr-lib'
const currApiResultUpdate = 'https://www.mockstock.live/api/update-curr-lib'
const currResponseResult = await fetch(currApiResultUpdate, {
method: 'POST',
body: JSON.stringify({ data: [fetchedData[i], fetchedData[i + 1], fetchedData[i + 2]] }),
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': 'https://mockstock.live/'
'Access-Control-Allow-Origin': 'https://www.mockstock.live/'
},
})
await currResponseResult.json()
}

for (let i = 102; i < 147; i += 3) {
// console.log(fetchedData[i], fetchedData[i + 1], fetchedData[i + 2])
const currApiResultUpdate = 'https://mockstock.live/api/update-curr-lib'
const currApiResultUpdate = 'https://www.mockstock.live/api/update-curr-lib'
const currResponseResult = await fetch(currApiResultUpdate, {
method: 'POST',
body: JSON.stringify({ data: [fetchedData[i], fetchedData[i + 1], fetchedData[i + 2]] }),
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': 'https://mockstock.live/'
'Access-Control-Allow-Origin': 'https://www.mockstock.live/'
},
})
await currResponseResult.json()
}

const apiUrlPercentage = 'https://mockstock.live/api/update-percentage-lib'
const apiUrlPercentage = 'https://www.mockstock.live/api/update-percentage-lib'
const responsePercentage = await fetch(apiUrlPercentage)
const resPercentage = await responsePercentage.json()
setLoader(false)
Expand All @@ -198,7 +198,7 @@ export default function BuyPage() {
useEffect(() => {
async function getFirstData() {
setLoader(true)
const apiUrlEndpoint = 'https://mockstock.live/api/buy-lib'
const apiUrlEndpoint = 'https://www.mockstock.live/api/buy-lib'
const response = await fetch(apiUrlEndpoint)
const res = await response.json()
setdataResponse(res.products)
Expand All @@ -208,17 +208,17 @@ export default function BuyPage() {
}, [changed])

const buyStocks = async (data) => {
const apiUrlEndpoint = 'https://mockstock.live/api/buy-lib'
const apiUrlEndpoint = 'https://www.mockstock.live/api/buy-lib'
const response = await fetch(apiUrlEndpoint, {
method: 'POST',
body: JSON.stringify({ data }),
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': 'https://mockstock.live/'
'Access-Control-Allow-Origin': 'https://www.mockstock.live/'
},
})
await response.json()
const apiUpdateBalance = 'https://mockstock.live/api/update-balance-lib'
const apiUpdateBalance = 'https://www.mockstock.live/api/update-balance-lib'
const responseBalance = await fetch(apiUpdateBalance)
const resBalance = await responseBalance.json()
getUserInfo({ user_email: user[0].email })
Expand Down
2 changes: 1 addition & 1 deletion pages/leaderboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function LeaderboardPage() {
useEffect(() => {
async function getPageData() {
setLoader(true)
const apiUrlEndpoint = 'https://mockstock.live/api/leaderboard-lib'
const apiUrlEndpoint = 'https://www.mockstock.live/api/leaderboard-lib'
const response = await fetch(apiUrlEndpoint)
const res = await response.json()
// console.log(res)
Expand Down
2 changes: 1 addition & 1 deletion pages/portfolio.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function PortfolioPage() {
async function getPageData() {
setLoader(true)
const data = { user_email: user[0]?.email, user_emai: user[0]?.email }
const apiUrlEndpoint = 'https://mockstock.live/api/portfolio-lib'
const apiUrlEndpoint = 'https://www.mockstock.live/api/portfolio-lib'
const response = await fetch(apiUrlEndpoint, {
method: 'POST',
body: JSON.stringify({ data }),
Expand Down
22 changes: 11 additions & 11 deletions pages/sell.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function SellPage() {
async function getFirstData() {
setLoader(true)
const data = { user_email: user[0]?.email }
const apiUrlEndpoint = 'https://mockstock.live/api/sell-page-data-lib'
const apiUrlEndpoint = 'https://www.mockstock.live/api/sell-page-data-lib'
const response = await fetch(apiUrlEndpoint, {
method: 'POST',
body: JSON.stringify({ data }),
Expand Down Expand Up @@ -105,7 +105,7 @@ export default function SellPage() {

for (let i = 0; i < 51; i += 3) {
console.log(curr_yest_price[i], curr_yest_price[i + 1], curr_yest_price[i + 2])
const currApiYestUpdate = 'https://mockstock.live/api/update-yest-lib'
const currApiYestUpdate = 'https://www.mockstock.live/api/update-yest-lib'
const currResponseYestResult = await fetch(currApiYestUpdate, {
method: 'POST',
body: JSON.stringify({
Expand All @@ -121,7 +121,7 @@ export default function SellPage() {

for (let i = 51; i < 102; i += 3) {
console.log(curr_yest_price[i], curr_yest_price[i + 1], curr_yest_price[i + 2])
const currApiYestUpdate = 'https://mockstock.live/api/update-yest-lib'
const currApiYestUpdate = 'https://www.mockstock.live/api/update-yest-lib'
const currResponseYestResult = await fetch(currApiYestUpdate, {
method: 'POST',
body: JSON.stringify({
Expand All @@ -137,7 +137,7 @@ export default function SellPage() {

for (let i = 102; i < 144; i += 3) {
console.log(curr_yest_price[i], curr_yest_price[i + 1], curr_yest_price[i + 2])
const currApiYestUpdate = 'https://mockstock.live/api/update-yest-lib'
const currApiYestUpdate = 'https://www.mockstock.live/api/update-yest-lib'
const currResponseYestResult = await fetch(currApiYestUpdate, {
method: 'POST',
body: JSON.stringify({
Expand All @@ -154,7 +154,7 @@ export default function SellPage() {

for (let i = 0; i < 51; i += 3) {
console.log(fetchedData[i], fetchedData[i + 1], fetchedData[i + 2])
const currApiResultUpdate = 'https://mockstock.live/api/update-curr-lib'
const currApiResultUpdate = 'https://www.mockstock.live/api/update-curr-lib'
const currResponseResult = await fetch(currApiResultUpdate, {
method: 'POST',
body: JSON.stringify({ data: [fetchedData[i], fetchedData[i + 1], fetchedData[i + 2]] }),
Expand All @@ -168,7 +168,7 @@ export default function SellPage() {

for (let i = 51; i < 102; i += 3) {
console.log(fetchedData[i], fetchedData[i + 1], fetchedData[i + 2])
const currApiResultUpdate = 'https://mockstock.live/api/update-curr-lib'
const currApiResultUpdate = 'https://www.mockstock.live/api/update-curr-lib'
const currResponseResult = await fetch(currApiResultUpdate, {
method: 'POST',
body: JSON.stringify({ data: [fetchedData[i], fetchedData[i + 1], fetchedData[i + 2]] }),
Expand All @@ -182,7 +182,7 @@ export default function SellPage() {

for (let i = 102; i < 147; i += 3) {
console.log(fetchedData[i], fetchedData[i + 1], fetchedData[i + 2])
const currApiResultUpdate = 'https://mockstock.live/api/update-curr-lib'
const currApiResultUpdate = 'https://www.mockstock.live/api/update-curr-lib'
const currResponseResult = await fetch(currApiResultUpdate, {
method: 'POST',
body: JSON.stringify({ data: [fetchedData[i], fetchedData[i + 1], fetchedData[i + 2]] }),
Expand All @@ -194,7 +194,7 @@ export default function SellPage() {
console.log(currApiResResult)
}

const apiUrlPercentage = 'https://mockstock.live/api/update-percentage-lib'
const apiUrlPercentage = 'https://www.mockstock.live/api/update-percentage-lib'
const responsePercentage = await fetch(apiUrlPercentage)
const resPercentage = await responsePercentage.json()
setLoader(false)
Expand All @@ -208,7 +208,7 @@ export default function SellPage() {
async function getFirstData() {
setLoader(true)
const data = { user_email: user[0]?.email }
const apiUrlEndpoint = 'https://mockstock.live/api/sell-page-data-lib'
const apiUrlEndpoint = 'https://www.mockstock.live/api/sell-page-data-lib'
const response = await fetch(apiUrlEndpoint, {
method: 'POST',
body: JSON.stringify({ data }),
Expand All @@ -225,7 +225,7 @@ export default function SellPage() {

const sellStocks = async (data) => {
console.log(data)
const apiUrlEndpoint = 'https://mockstock.live/api/sell-lib'
const apiUrlEndpoint = 'https://www.mockstock.live/api/sell-lib'
const response = await fetch(apiUrlEndpoint, {
method: 'POST',
body: JSON.stringify({ data }),
Expand All @@ -234,7 +234,7 @@ export default function SellPage() {
},
})
const res = await response.json()
const apiUpdateBalance = 'https://mockstock.live/api/update-balance-lib'
const apiUpdateBalance = 'https://www.mockstock.live/api/update-balance-lib'
const responseBalance = await fetch(apiUpdateBalance)
getUserInfo({ user_email: user[0].email })
}
Expand Down
2 changes: 1 addition & 1 deletion pages/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function TansactionsPage() {
async function getPageData() {
setLoader(true)
const data = { user_email: user[0]?.email }
const apiUrlEndpoint = 'https://mockstock.live/api/transactions-lib'
const apiUrlEndpoint = 'https://www.mockstock.live/api/transactions-lib'
const response = await fetch(apiUrlEndpoint, {
method: 'POST',
body: JSON.stringify({ data }),
Expand Down

0 comments on commit 17b4d88

Please sign in to comment.