Skip to content

Commit

Permalink
FIX - Fix authorizion from backend
Browse files Browse the repository at this point in the history
  • Loading branch information
hdang09 committed Nov 20, 2023
1 parent 8244058 commit 831a299
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/components/Statistics/Statistics.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { HiCursorClick } from 'react-icons/hi';
import { RiLinksLine } from 'react-icons/ri';
import { Col, Container, Row } from 'styled-bootstrap-grid';

import { getReport } from '../../utils/urlAPI';
import { getReportForCurrentUser } from '../../utils/urlAPI';

import * as Styled from './Statistics.styled';
import Skeleton from './StatisticsSkeleton';
Expand All @@ -13,7 +13,7 @@ const Statistics = () => {

useEffect(() => {
const getAllLinks = async () => {
const { data } = await getReport();
const { data } = await getReportForCurrentUser();
setReport(data.data);
};
getAllLinks();
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Home/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Col, Container, Row } from 'styled-bootstrap-grid';
import { urlSelector } from '../../app/reducers/urlReducer';
import { Card, QR, URLList, URLShortener } from '../../components';
import config from '../../config';
import { getReport } from '../../utils/urlAPI';
import { getReportForCurrentUser } from '../../utils/urlAPI';

const Home = () => {
const currentURL = useSelector(urlSelector).shorten;
Expand All @@ -27,7 +27,7 @@ const Home = () => {

useEffect(() => {
const getLinks = async () => {
const { data } = await getReport();
const { data } = await getReportForCurrentUser();
setLinks(data.data.links);
};
getLinks();
Expand Down
4 changes: 0 additions & 4 deletions src/utils/adminAPI.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import Cookies from 'universal-cookie';

import { get, post, put } from './apiCaller';

const cookies = new Cookies();

// Admin API
export const getAllUser = () => {
const url = '/api/admin';
Expand Down
10 changes: 8 additions & 2 deletions src/utils/urlAPI.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Cookies from 'universal-cookie';

import { get, post } from './apiCaller';
import { get, post, put } from './apiCaller';

// URL API
export const shortenUrl = (link, linkcode) => {
Expand All @@ -19,7 +19,7 @@ export const shortenUrl = (link, linkcode) => {
export const updateLink = (shortenLink, linkcode, title) => {
const url = '/api/url/shorten/update-link';

return post(
return put(
url,
{},
{
Expand All @@ -38,3 +38,9 @@ export const getReport = (accountId, year, month) => {
if (year && month) url += `/${year}/${month}`;
return get(url);
};

export const getReportForCurrentUser = () => {
let url = `/api/report`;

return get(url);
};

1 comment on commit 831a299

@vercel
Copy link

@vercel vercel bot commented on 831a299 Nov 20, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

shorten-url – ./

shorten-url-git-main-hdang09.vercel.app
shorten-url-orpin.vercel.app
shorten-url-hdang09.vercel.app

Please sign in to comment.