Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/add env new #16

Merged
merged 4 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Backend url
VITE_BACKEND_URL=https://intercom-manager.dev.eyevinn.technology/
1 change: 1 addition & 0 deletions .env.local.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Example .env.local file
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ export default {
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list

## Example .env.local file

Replace sample with actual values
21 changes: 10 additions & 11 deletions src/api/api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// TODO env variable
import { handleFetchRequest } from "./handle-fetch-request.ts";

const rootUrl = "https://intercom-manager.dev.eyevinn.technology/";
const API_URL = import.meta.env.VITE_BACKEND_URL ?? "";

type TCreateProductionOptions = {
name: string;
Expand Down Expand Up @@ -59,7 +58,7 @@ type TDeleteAudioSessionOptions = {
export const API = {
createProduction: async ({ name, lines }: TCreateProductionOptions) =>
handleFetchRequest<TCreateProductionResponse>(
fetch(`${rootUrl}production/`, {
fetch(`${API_URL}production/`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand All @@ -72,22 +71,22 @@ export const API = {
),
listProductions: (): Promise<TListProductionsResponse> =>
handleFetchRequest<TListProductionsResponse>(
fetch(`${rootUrl}productions/`, { method: "GET" })
fetch(`${API_URL}productions/`, { method: "GET" })
),
fetchProduction: (id: number): Promise<TFetchProductionResponse> =>
handleFetchRequest<TFetchProductionResponse>(
fetch(`${rootUrl}productions/${id}`, { method: "GET" })
fetch(`${API_URL}productions/${id}`, { method: "GET" })
),
deleteProduction: (id: number) =>
fetch(`${rootUrl}productions/${id}`, { method: "DELETE" }).then(
fetch(`${API_URL}productions/${id}`, { method: "DELETE" }).then(
(response) => response.json()
),
listProductionLines: (id: number) =>
fetch(`${rootUrl}productions/${id}/lines`, { method: "GET" }).then(
fetch(`${API_URL}productions/${id}/lines`, { method: "GET" }).then(
(response) => response.json()
),
fetchProductionLine: (productionId: number, lineId: number): Promise<TLine> =>
fetch(`${rootUrl}productions/${productionId}/lines/${lineId}`, {
fetch(`${API_URL}productions/${productionId}/lines/${lineId}`, {
method: "GET",
}).then((response) => response.json()),
offerAudioSession: ({
Expand All @@ -97,7 +96,7 @@ export const API = {
}: TOfferAudioSessionOptions): Promise<TOfferAudioSessionResponse> =>
handleFetchRequest<TOfferAudioSessionResponse>(
fetch(
`${rootUrl}productions/${productionId}/lines/${lineId}/users/${username}`,
`${API_URL}productions/${productionId}/lines/${lineId}/users/${username}`,
{ method: "POST" }
)
),
Expand All @@ -109,7 +108,7 @@ export const API = {
}: TPatchAudioSessionOptions): Promise<TPatchAudioSessionResponse> =>
handleFetchRequest<TPatchAudioSessionResponse>(
fetch(
`${rootUrl}productions/${productionId}/lines/${lineId}/session/${sessionId}`,
`${API_URL}productions/${productionId}/lines/${lineId}/session/${sessionId}`,
{
method: "PATCH",
body: sdpAnswer,
Expand All @@ -123,7 +122,7 @@ export const API = {
}: TDeleteAudioSessionOptions): Promise<string> =>
handleFetchRequest<string>(
fetch(
`${rootUrl}productions/${productionId}/lines/${lineId}/session/${sessionId}`,
`${API_URL}productions/${productionId}/lines/${lineId}/session/${sessionId}`,
{ method: "DELETE" }
)
),
Expand Down
2 changes: 1 addition & 1 deletion src/components/production-line/production-line.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const ProductionLine: FC = () => {
useEffect(() => {
if (!joinProductionOptions) return noop;

let interval: number | null = null;
let interval: number = 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@martinstark
Got type-error on the previous code so replaced it with this.


const productionId = parseInt(joinProductionOptions.productionId, 10);
const lineId = parseInt(joinProductionOptions.lineId, 10);
Expand Down