Skip to content

Commit

Permalink
fix: correct logic for history route to work
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-nfc committed Nov 14, 2024
1 parent 9200914 commit f74a8ac
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,12 @@ function App() {
>
<Route path='/login' element={<Login/>}/>

<Route path="/core/:model/:pk/:action"
<Route path="/core/:model/:pk/history"
element={<History
setContentHeading={setContentHeading}
SetContentHeaderIcon={SetContentHeaderIcon}
/>}
errorElement={<ErrorPage /> }
loader = {detailsLoader}
/>

<Route path="/settings"
Expand Down
2 changes: 1 addition & 1 deletion src/components/Table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ const Table = ({
<td
onClick={(e) => {
let a = e
document.getElementById('expandable-' + e.currentTarget.parentElement.id).classList.toggle("hide-expandable-row")
document.getElementById('expandable-' + data.id).classList.toggle("hide-expandable-row")
}}
>
<IconLoader
Expand Down
15 changes: 11 additions & 4 deletions src/hooks/urlBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ export default function urlBuilder(
pk = params.pk
}

if( ! module && path_directories[0] == 'settings' ) {
if( ! module ) {

module = 'settings'
module = path_directories[0]

}

Expand All @@ -75,12 +75,10 @@ export default function urlBuilder(

}


const allowed_actions = [ 'add', 'delete', 'edit' ]

if( ! allowed_actions.includes( action ) ) {

action = null

for( let dir of path_directories ) {

Expand All @@ -90,6 +88,12 @@ export default function urlBuilder(
}
}

if( ! action && path_directories[path_directories.length-1] == 'history' ) {

action = 'history'
}


const ticket_models = [
'change',
'incident',
Expand Down Expand Up @@ -294,6 +298,9 @@ export default function urlBuilder(

method = 'PATCH'

} else if( action === 'history' ) {

url += '/history'
}

if(
Expand Down
2 changes: 1 addition & 1 deletion src/layout/history.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const History = ({
<div className="content">
<Table
callback={setContentHeading}
data_url_path={'core/' + url_builder.model + '/' + url_builder.pk + '/history'}
data_url_path={'core/' + url_builder.params.model + '/' + url_builder.params.pk + '/history'}
/>
</div>
</section>
Expand Down

0 comments on commit f74a8ac

Please sign in to comment.