Skip to content

Commit

Permalink
Feat/api changes (#18)
Browse files Browse the repository at this point in the history
* Feat(util): handler now contains singing out and refreshing mechanisms

* Feat(api): centralized all api calls to /api dir

* Feat(lib): added qs library for query string configuration

* Feat(types): added required types for new api calls

* Feat(App): replaced and refactored api calls to centralized functions

* Chore(Constants): cleaned up constants to use vite setup

* Refactor(MainBody): refactored api calls to centralized functions

* Refactor(HomePage): refactored api calls and choice type definition

* Refactor(AdminPanel): replaced api calls with centralized functions

* Refactor(MyDrafts): replaced api calls with centralized functions

* Fix(SignalCardPage): added error handling

* Refactor(TrendEntryFormEl): replaced api calls to centralized functions and updated choice types

* Refactor(SignalEntryFormEl): replaced api calls with centralized functions and updated choice types

* Refactor(components): updated choices objects according to new type definition

* Refactor(AddSingalsModal): replaced api calls with centralized calls and updated choice types

* Refactor(AddTrendsModal): replaced api calls to centralized function calls and updated choice types

* Refactor(SingOutButton): replaced api call to centralized function calls and updated choice types

* Refactor(SignUpButton): replaced api calls to centralized function calls

* Refactor(AllSignals): replaced api calls to centralized function calls

* Refactor(EditSignal): replaced api call to centralized function call

* Refactor(SignalDetail): replaced api calls to centralized function calls and updated choice types

* Refactor(AllTrends): replaced api calls to centralized function calls

* Refactor(EditTrend): replaced api call to centralized function call

* Refactor(TrendDetail): replaced api calls to centralized function calls and updated choice types

* Feat(asset): added hero image for easier relative import

* Refactor(auth): cleaned up authentication flow via use of interceptor

* Fix(Types): added missing attributes to types

* Fix(MainBody): added missing attributes to api function call

* Fix(PdfPageDesign): improved error handling for edge cases

* Fix(EntryForms): added required parameters to api function calls

* Fix(EditSignal/Trend): read using read endpoints instead of search endpoints

* Fix(AllSignals/Trends): added proper status to filter for search

* Refactor(minor): moved platform config to public folder

* Fix(constants): refactored constants for consistency

* Refactor(AuthConfig): renamed and refactored for consistency and readability

* Fix(types): added created by attribute to fix updating params

* Fix(api_config): increased timeout for image uploads and refactored auth process

* Feat(App): logs out automatically if token is expired

* Fix(main): minor import fix

* Fix(addModals): added essential params

* Fix(minor): import naming change

* Fix(entryFormEl): added proper params for update and image display

* Refactor(ci/cd): removed unused env variables and added new conditional variables for different branches

* Refactor(CI/CD): improved conditional env variables

* Fix(types): added created_for in signal create/update types

* Fix(api): export endpoints response type set to blob for incoming binary data

* Fix(entryForm): added missing types in update and create

* Fix(entryFormEls): added missing params
  • Loading branch information
GedionT authored Nov 4, 2024
1 parent a42febd commit a5555df
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/Components/SignalEntryFormEl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,7 @@ export function SignalEntryFormEl(props: Props) {
relevance: signalData?.relevance || '',
location: signalData?.location || '',
created_by: signalData?.created_by || '',
score: signalData?.score || '',
connected_trends: selectedTrendsList,
status: 'New',
keywords: [keyword1, keyword2, keyword3].filter(
Expand Down Expand Up @@ -1040,6 +1041,7 @@ export function SignalEntryFormEl(props: Props) {
url: signalData?.url || '',
relevance: signalData?.relevance || '',
location: signalData?.location || '',
score: signalData?.score || '',
created_by: signalData?.created_by || '',
connected_trends: selectedTrendsList,
keywords: [keyword1, keyword2, keyword3].filter(
Expand Down Expand Up @@ -1126,6 +1128,7 @@ export function SignalEntryFormEl(props: Props) {
status: signalData?.status || '',
created_by: signalData.created_by || '',
created_for: signalData?.created_for || '',
score: signalData?.score || '',
created_unit: signalData?.created_unit || '',
connected_trends: selectedTrendsList,
keywords: [keyword1, keyword2, keyword3].filter(
Expand Down Expand Up @@ -1180,6 +1183,7 @@ export function SignalEntryFormEl(props: Props) {
description: signalData?.description || '',
attachment: signalData?.attachment || '',
steep_primary: signalData?.steep_primary || '',
steep_secondary: signalData?.steep_secondary || undefined,
signature_primary: signalData?.signature_primary || '',
signature_secondary: signalData?.signature_secondary || [],
sdgs: signalData?.sdgs || [],
Expand All @@ -1188,6 +1192,7 @@ export function SignalEntryFormEl(props: Props) {
relevance: signalData?.relevance || '',
created_for: signalData?.created_for || '',
location: signalData?.location || '',
score: signalData?.score || '',
connected_trends: selectedTrendsList,
status: 'New',
keywords: [keyword1, keyword2, keyword3].filter(
Expand Down Expand Up @@ -1228,13 +1233,15 @@ export function SignalEntryFormEl(props: Props) {
description: signalData?.description || '',
attachment: signalData?.attachment || '',
steep_primary: signalData?.steep_primary || '',
steep_secondary: signalData.steep_secondary || undefined,
signature_primary: signalData?.signature_primary || '',
signature_secondary: signalData?.signature_secondary || [],
sdgs: signalData?.sdgs || [],
created_unit: signalData.created_unit || '',
url: signalData?.url || '',
relevance: signalData?.relevance || '',
created_for: signalData?.created_for || '',
score: signalData?.score || '',
location: signalData?.location || '',
connected_trends: selectedTrendsList,
status: 'Draft',
Expand Down
7 changes: 6 additions & 1 deletion src/Components/TrendEntryFormEl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export function TrendEntryFormEl(props: Props) {
time_horizon: trendData.time_horizon || '',
sdgs: trendData.sdgs || [],
status: 'New',
attachment: trendData.attachment || undefined,
attachment: trendData.attachment,
keywords: trendData.keywords,
location: trendData.location,
relevance: trendData.relevance,
Expand All @@ -206,6 +206,7 @@ export function TrendEntryFormEl(props: Props) {
steep_primary: trendData.steep_primary,
steep_secondary: trendData.steep_secondary || undefined,
assigned_to: trendData.assigned_to || undefined,
created_for: trendData.created_for || undefined,
connected_signals: trendsSignal || undefined,
};
};
Expand All @@ -217,15 +218,19 @@ export function TrendEntryFormEl(props: Props) {
headline: trendData.headline || '',
impact_description: trendData.impact_description || '',
signature_primary: trendData.signature_primary,
signature_secondary: trendData.signature_secondary,
impact_rating: trendData.impact_rating || '',
time_horizon: trendData.time_horizon || '',
sdgs: trendData.sdgs,
attachment: trendData.attachment,
steep_primary: trendData.steep_primary,
steep_secondary: trendData.steep_secondary,
status: trendData.status,
keywords: trendData.keywords,
location: trendData.location,
relevance: trendData.relevance,
created_by: trendData.created_by,
created_for: trendData.created_for || undefined,
assigned_to: trendData?.assigned_to || undefined,
connected_signals:
connectedSignal?.map(signal => Number(signal.id)) || undefined,
Expand Down
2 changes: 2 additions & 0 deletions src/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ export interface CreateTrendParams {
steep_primary?: string;
steep_secondary?: string[];
assigned_to?: string;
created_for?: string;
connected_signals?: number[];
}

Expand All @@ -358,6 +359,7 @@ export interface UpdateTrendParams {
steep_secondary?: string[];
assigned_to?: string;
created_by?: string;
created_for?: string;
connected_signals?: number[];
}

Expand Down
5 changes: 4 additions & 1 deletion src/api/signals_call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ export function exportSignals(params: BaseSignalsParams = {}) {
if (unit) queryParams.unit = unit;

return axiosInstance
.get<string>('/signals/export', { params: queryParams })
.get<string>('/signals/export', {
params: queryParams,
responseType: 'blob',
})
.then(response => response.data)
.catch(error => {
if (isAxiosError(error)) {
Expand Down
5 changes: 4 additions & 1 deletion src/api/trends_calls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ export function exportTrends(params: BaseTrendsParams = {}) {
if (impact_rating) queryParams.impact_rating = impact_rating;

return axiosInstance
.get<string>('/trends/export', { params: queryParams })
.get<string>('/trends/export', {
params: queryParams,
responseType: 'blob',
})
.then(response => response.data)
.catch(error => {
if (isAxiosError(error)) {
Expand Down

0 comments on commit a5555df

Please sign in to comment.