Skip to content

Commit

Permalink
Merge pull request #35 from culturecreates/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
sahalali authored May 29, 2024
2 parents da9ca73 + 46e413d commit 9fd62c0
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
REACT_APP_API_URL = https://api.footlight.io/calendars/
REACT_APP_API_URL = https://api.footlight.io/
2 changes: 2 additions & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
REACT_APP_ENVIRONMENT = PRODUCTION
REACT_APP_API_URL = https://api.footlight.io/
2 changes: 2 additions & 0 deletions .env.staging
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
REACT_APP_ENVIRONMENT = STAGING
REACT_APP_API_URL = https://staging.api.footlight.io/
2 changes: 1 addition & 1 deletion .github/workflows/build-production-deploy-s3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ jobs:
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npm run build
- run: npm run build:production
- run: aws s3 sync ./build s3://${{env.WEBHOSTING_BUCKET_NAME}}/ --acl public-read --delete --cache-control max-age=3600
2 changes: 1 addition & 1 deletion .github/workflows/build-staging-deploy-s3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ jobs:
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npm run build
- run: npm run build:staging
- run: aws s3 sync ./build s3://${{env.WEBHOSTING_BUCKET_NAME}}/ --acl public-read --delete --cache-control max-age=3600
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"dayjs": "^1.11.10",
"env-cmd": "^10.1.0",
"i18next": "^23.7.11",
"react": "^18.2.0",
"react-calendar": "^4.7.0",
Expand All @@ -21,7 +22,10 @@
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"start:staging": "env-cmd -f .env.staging react-scripts start",
"start:production": "env-cmd -f .env.production react-scripts start",
"build:staging": "env-cmd -f .env.staging react-scripts build",
"build:production": "env-cmd -f .env.production react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"lint": "eslint .",
Expand All @@ -35,6 +39,9 @@
"react-app/jest"
]
},
"engines": {
"node": "^14.17.0"
},
"browserslist": {
"production": [
">0.2%",
Expand Down
12 changes: 4 additions & 8 deletions src/components/card/Card.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,20 @@ import './card.css';
import { redirectionHandler } from '../../utils/redirectionHandler';
import WidgetContext from '../../context/WidgetContext';

const Card = ({ id, slug, name, place, image, startDate, endDate }) => {
const Card = ({ id, name, place, image, startDate, endDate }) => {
const [imgError, setImgError] = useState(false);
const { widgetProps } = useContext(WidgetContext);
const { eventUrl, locale } = widgetProps;
const { calendar } = widgetProps;

let url = eventUrl.replace('${locale}', locale).replace('${eventId}', id);

if (url.includes('${eventName}')) {
url = url.replace('${eventName}', slug);
}
let redirectionUrl = `${process.env.REACT_APP_API_URL}resource/${id}?calendar=${calendar}`;

return (
<li
className="card"
onClick={(e) => {
e.preventDefault();
redirectionHandler({
url,
url: redirectionUrl,
});
}}
>
Expand Down
24 changes: 4 additions & 20 deletions src/components/footer/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,14 @@ import { redirectionHandler } from '../../utils/redirectionHandler';

const Footer = () => {
const { t } = useTranslation();
const { widgetProps, searchKeyWord, startDateSpan, endDateSpan, totalCount } =
useContext(WidgetContext);
const { widgetProps, totalCount } = useContext(WidgetContext);

const { searchEventsUrl, locale, calendarName } = widgetProps;
const { calendar, calendarName } = widgetProps;
let redirectionUrl = `${process.env.REACT_APP_API_URL}calendars/${calendar}/events/redirect`;

const submitHandler = (event) => {
event.preventDefault();
const searchParams = new URLSearchParams();

searchParams.append('limit', 100);
if (searchKeyWord !== '' && searchKeyWord) {
widgetProps?.calendar == 'signe-laval'
? searchParams.append('q', searchKeyWord)
: searchParams.append('query', searchKeyWord);
}
if (startDateSpan) {
searchParams.append('start-date-range', startDateSpan);
}
if (endDateSpan) {
searchParams.append('end-date-range', endDateSpan);
}

let url = searchEventsUrl.replace('${locale}', locale).trim() + '?' + searchParams.toString();
redirectionHandler({ url: url });
redirectionHandler({ url: redirectionUrl });
};

return (
Expand Down
2 changes: 1 addition & 1 deletion src/utils/generateUrl.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-undef */
export const generateUrl = (urlComponents) => {
const baseUrl = process.env.REACT_APP_API_URL;
const baseUrl = process.env.REACT_APP_API_URL + 'calendars/';
const calendar = urlComponents.calendar;
const searchEntityType = urlComponents?.searchEntityType;
const limit = urlComponents?.limit || 10;
Expand Down

0 comments on commit 9fd62c0

Please sign in to comment.