Skip to content

Commit

Permalink
refactor: simplify environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
steveoh committed Oct 8, 2024
1 parent 4608b47 commit 6644849
Show file tree
Hide file tree
Showing 12 changed files with 159 additions and 112 deletions.
9 changes: 1 addition & 8 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,4 @@ VITE_SERVICE_NAME=PLSS corner management
VITE_API_KEY=api.mapserv.utah.gov api key
VITE_DISCOVER_KEY=string;

VITE_FIREBASE_PROJECT_ID=ut-dts-agrc-plss-dev
VITE_FIREBASE_STORAGE_BUCKET=localhost
VITE_FIREBASE_API_KEY=string;
VITE_FIREBASE_AUTH_DOMAIN=string;
VITE_FIREBASE_DATABASE_URL=string;
VITE_FIREBASE_MESSAGING_SENDER_ID=string;
VITE_FIREBASE_APPID=string;
VITE_FIREBASE_MEASUREMENT_ID=string;
VITE_FIREBASE_CONFIG={"apiKey":"string","authDomain":"string","projectId":"ut-dts-agrc-plss-dev","storageBucket":"localhost","messagingSenderId":"string","appId":"string","measurementId":"string"}
23 changes: 14 additions & 9 deletions src/components/pageElements/AddPoint.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ import reduce, { defaults } from '../reducers/AppReducer';
import './../../index.css';
import AddPoint from './AddPoint.jsx';

let config = {
apiKey: '',
authDomain: '',
projectId: '',
storageBucket: '',
messagingSenderId: '',
appId: '',
measurementId: '',
};

if (import.meta.env.VITE_FIREBASE_CONFIG) {
config = JSON.parse(import.meta.env.VITE_FIREBASE_CONFIG);
}

export default {
title: 'Drawer/AddPoint',
component: AddPoint,
Expand All @@ -22,15 +36,6 @@ export default {
},
decorators: [
(Story) => {
const config = {
apiKey: import.meta.env.VITE_FIREBASE_API_KEY,
authDomain: import.meta.env.VITE_FIREBASE_AUTH_DOMAIN,
databaseURL: import.meta.env.VITE_FIREBASE_DATABASE_URL,
projectId: import.meta.env.VITE_FIREBASE_PROJECT_ID,
storageBucket: import.meta.env.VITE_FIREBASE_STORAGE_BUCKET,
messagingSenderId: import.meta.env.VITE_FIREBASE_MESSAGING_SENDER_ID,
appId: import.meta.env.VITE_FIREBASE_APPID,
};
const app = initializeApp(config);
const storage = getStorage(app);
const functions = getFunctions(app);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,25 @@ import {
StorageProvider,
} from 'reactfire';

let config = {
apiKey: '',
authDomain: '',
projectId: '',
storageBucket: '',
messagingSenderId: '',
appId: '',
measurementId: '',
};

if (import.meta.env.VITE_FIREBASE_CONFIG) {
config = JSON.parse(import.meta.env.VITE_FIREBASE_CONFIG);
}

export default {
title: 'Corner/Submission',
component: CornerSubmission,
decorators: [
(Story) => {
const config = {
apiKey: import.meta.env.VITE_FIREBASE_API_KEY,
authDomain: import.meta.env.VITE_FIREBASE_AUTH_DOMAIN,
databaseURL: import.meta.env.VITE_FIREBASE_DATABASE_URL,
projectId: import.meta.env.VITE_FIREBASE_PROJECT_ID,
storageBucket: import.meta.env.VITE_FIREBASE_STORAGE_BUCKET,
messagingSenderId: import.meta.env.VITE_FIREBASE_MESSAGING_SENDER_ID,
appId: import.meta.env.VITE_FIREBASE_APPID,
};
const app = initializeApp(config);
const storage = getStorage(app);
const functions = getFunctions(app);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,25 @@ import {
StorageProvider,
} from 'reactfire';

let config = {
apiKey: '',
authDomain: '',
projectId: '',
storageBucket: '',
messagingSenderId: '',
appId: '',
measurementId: '',
};

if (import.meta.env.VITE_FIREBASE_CONFIG) {
config = JSON.parse(import.meta.env.VITE_FIREBASE_CONFIG);
}

export default {
title: 'Corner/Submission/Parts',
component: Metadata,
decorators: [
(Story) => {
const config = {
apiKey: import.meta.env.VITE_FIREBASE_API_KEY,
authDomain: import.meta.env.VITE_FIREBASE_AUTH_DOMAIN,
databaseURL: import.meta.env.VITE_FIREBASE_DATABASE_URL,
projectId: import.meta.env.VITE_FIREBASE_PROJECT_ID,
storageBucket: import.meta.env.VITE_FIREBASE_STORAGE_BUCKET,
messagingSenderId: import.meta.env.VITE_FIREBASE_MESSAGING_SENDER_ID,
appId: import.meta.env.VITE_FIREBASE_APPID,
};
const app = initializeApp(config);
const storage = getStorage(app);
const functions = getFunctions(app);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,22 @@ export default {
},
};

let config = {
apiKey: '',
authDomain: '',
projectId: '',
storageBucket: '',
messagingSenderId: '',
appId: '',
measurementId: '',
};

if (import.meta.env.VITE_FIREBASE_CONFIG) {
config = JSON.parse(import.meta.env.VITE_FIREBASE_CONFIG);
}

const Template = (args) => {
const data = { ...args };
const config = {
apiKey: import.meta.env.VITE_FIREBASE_API_KEY,
authDomain: import.meta.env.VITE_FIREBASE_AUTH_DOMAIN,
databaseURL: import.meta.env.VITE_FIREBASE_DATABASE_URL,
projectId: import.meta.env.VITE_FIREBASE_PROJECT_ID,
storageBucket: import.meta.env.VITE_FIREBASE_STORAGE_BUCKET,
messagingSenderId: import.meta.env.VITE_FIREBASE_MESSAGING_SENDER_ID,
appId: import.meta.env.VITE_FIREBASE_APPID,
};
const app = initializeApp(config);
const storage = getStorage(app);
const auth = getAuth(app);
Expand Down
23 changes: 14 additions & 9 deletions src/components/pageElements/CornerSubmission/3c-Height.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,25 @@ import {
StorageProvider,
} from 'reactfire';

let config = {
apiKey: '',
authDomain: '',
projectId: '',
storageBucket: '',
messagingSenderId: '',
appId: '',
measurementId: '',
};

if (import.meta.env.VITE_FIREBASE_CONFIG) {
config = JSON.parse(import.meta.env.VITE_FIREBASE_CONFIG);
}

export default {
title: 'Corner/Submission/Parts',
component: GeographicHeight,
decorators: [
(Story) => {
const config = {
apiKey: import.meta.env.VITE_FIREBASE_API_KEY,
authDomain: import.meta.env.VITE_FIREBASE_AUTH_DOMAIN,
databaseURL: import.meta.env.VITE_FIREBASE_DATABASE_URL,
projectId: import.meta.env.VITE_FIREBASE_PROJECT_ID,
storageBucket: import.meta.env.VITE_FIREBASE_STORAGE_BUCKET,
messagingSenderId: import.meta.env.VITE_FIREBASE_MESSAGING_SENDER_ID,
appId: import.meta.env.VITE_FIREBASE_APPID,
};
const app = initializeApp(config);
const storage = getStorage(app);
const functions = getFunctions(app);
Expand Down
23 changes: 14 additions & 9 deletions src/components/pageElements/CornerSubmission/4-Images.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,22 @@ export default {
},
};

let config = {
apiKey: '',
authDomain: '',
projectId: '',
storageBucket: '',
messagingSenderId: '',
appId: '',
measurementId: '',
};

if (import.meta.env.VITE_FIREBASE_CONFIG) {
config = JSON.parse(import.meta.env.VITE_FIREBASE_CONFIG);
}

const Template = (args) => {
const data = { ...args };
const config = {
apiKey: import.meta.env.VITE_FIREBASE_API_KEY,
authDomain: import.meta.env.VITE_FIREBASE_AUTH_DOMAIN,
databaseURL: import.meta.env.VITE_FIREBASE_DATABASE_URL,
projectId: import.meta.env.VITE_FIREBASE_PROJECT_ID,
storageBucket: import.meta.env.VITE_FIREBASE_STORAGE_BUCKET,
messagingSenderId: import.meta.env.VITE_FIREBASE_MESSAGING_SENDER_ID,
appId: import.meta.env.VITE_FIREBASE_APPID,
};
const app = initializeApp(config);
const storage = getStorage(app);
const auth = getAuth(app);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,25 @@ import { getFunctions } from 'firebase/functions';
import { getStorage } from 'firebase/storage';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';

let config = {
apiKey: '',
authDomain: '',
projectId: '',
storageBucket: '',
messagingSenderId: '',
appId: '',
measurementId: '',
};

if (import.meta.env.VITE_FIREBASE_CONFIG) {
config = JSON.parse(import.meta.env.VITE_FIREBASE_CONFIG);
}

export default {
title: 'Corner/Submission/Parts',
component: Review,
decorators: [
(Story) => {
const config = {
apiKey: import.meta.env.VITE_FIREBASE_API_KEY,
authDomain: import.meta.env.VITE_FIREBASE_AUTH_DOMAIN,
databaseURL: import.meta.env.VITE_FIREBASE_DATABASE_URL,
projectId: import.meta.env.VITE_FIREBASE_PROJECT_ID,
storageBucket: import.meta.env.VITE_FIREBASE_STORAGE_BUCKET,
messagingSenderId: import.meta.env.VITE_FIREBASE_MESSAGING_SENDER_ID,
appId: import.meta.env.VITE_FIREBASE_APPID,
};
const app = initializeApp(config);
const functions = getFunctions(app);
const storage = getStorage(app);
Expand Down
28 changes: 16 additions & 12 deletions src/components/pageElements/Identify.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,25 @@ import { getStorage } from 'firebase/storage';
import { initializeApp } from 'firebase/app';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';

let config = {
apiKey: '',
authDomain: '',
projectId: '',
storageBucket: '',
messagingSenderId: '',
appId: '',
measurementId: '',
};

if (import.meta.env.VITE_FIREBASE_CONFIG) {
config = JSON.parse(import.meta.env.VITE_FIREBASE_CONFIG);
}
// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
export default {
title: 'Page Elements/Identify',
component: Identify,
decorators: [
(Story) => {
const config = {
apiKey: import.meta.env.VITE_FIREBASE_API_KEY,
authDomain: import.meta.env.VITE_FIREBASE_AUTH_DOMAIN,
databaseURL: import.meta.env.VITE_FIREBASE_DATABASE_URL,
projectId: import.meta.env.VITE_FIREBASE_PROJECT_ID,
storageBucket: import.meta.env.VITE_FIREBASE_STORAGE_BUCKET,
messagingSenderId: import.meta.env.VITE_FIREBASE_MESSAGING_SENDER_ID,
appId: import.meta.env.VITE_FIREBASE_APPID,
};
const app = initializeApp(config);
const storage = getStorage(app);
const auth = getAuth(app);
Expand Down Expand Up @@ -61,7 +65,7 @@ Authenticated.args = {
point_id: 'UT260060S0020E0_240400',
},
},
dispatch: () => {},
dispatch: () => { },
};

export const Unauthenticated = Template.bind({});
Expand All @@ -72,12 +76,12 @@ Unauthenticated.args = {
point_id: 'UT260060S0020E0_240400',
},
},
dispatch: () => {},
dispatch: () => { },
};

export const Empty = Template.bind({});
Empty.args = {
authenticated: false,
graphic: null,
dispatch: () => {},
dispatch: () => { },
};
23 changes: 14 additions & 9 deletions src/components/pageElements/MyContent.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ import {
import './../../index.css';
import MyContent from './MyContent.jsx';

let config = {
apiKey: '',
authDomain: '',
projectId: '',
storageBucket: '',
messagingSenderId: '',
appId: '',
measurementId: '',
};

if (import.meta.env.VITE_FIREBASE_CONFIG) {
config = JSON.parse(import.meta.env.VITE_FIREBASE_CONFIG);
}

export default {
title: 'Drawer/MyContent',
component: MyContent,
Expand All @@ -20,15 +34,6 @@ export default {
},
decorators: [
(Story) => {
const config = {
apiKey: import.meta.env.VITE_FIREBASE_API_KEY,
authDomain: import.meta.env.VITE_FIREBASE_AUTH_DOMAIN,
databaseURL: import.meta.env.VITE_FIREBASE_DATABASE_URL,
projectId: import.meta.env.VITE_FIREBASE_PROJECT_ID,
storageBucket: import.meta.env.VITE_FIREBASE_STORAGE_BUCKET,
messagingSenderId: import.meta.env.VITE_FIREBASE_MESSAGING_SENDER_ID,
appId: import.meta.env.VITE_FIREBASE_APPID,
};
const app = initializeApp(config);
const storage = getStorage(app);
const functions = getFunctions(app);
Expand Down
25 changes: 15 additions & 10 deletions src/components/pageElements/mapElements/MonumentRecord.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,26 @@ import { getStorage } from 'firebase/storage';
import { initializeApp } from 'firebase/app';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';

let config = {
apiKey: '',
authDomain: '',
projectId: '',
storageBucket: '',
messagingSenderId: '',
appId: '',
measurementId: '',
};

if (import.meta.env.VITE_FIREBASE_CONFIG) {
config = JSON.parse(import.meta.env.VITE_FIREBASE_CONFIG);
}

// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
export default {
title: 'Map Elements/Monument Record Finder',
component: MonumentRecord,
decorators: [
(Story) => {
const config = {
apiKey: import.meta.env.VITE_FIREBASE_API_KEY,
authDomain: import.meta.env.VITE_FIREBASE_AUTH_DOMAIN,
databaseURL: import.meta.env.VITE_FIREBASE_DATABASE_URL,
projectId: import.meta.env.VITE_FIREBASE_PROJECT_ID,
storageBucket: import.meta.env.VITE_FIREBASE_STORAGE_BUCKET,
messagingSenderId: import.meta.env.VITE_FIREBASE_MESSAGING_SENDER_ID,
appId: import.meta.env.VITE_FIREBASE_APPID,
};
const app = initializeApp(config);
const storage = getStorage(app);

Expand All @@ -44,6 +49,6 @@ export default {
};

// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
const Template = (args) => <MonumentRecord dispatch={() => {}} {...args} />;
const Template = (args) => <MonumentRecord dispatch={() => { }} {...args} />;

export const Primary = Template.bind({});
Loading

0 comments on commit 6644849

Please sign in to comment.