Skip to content

Commit

Permalink
Merge pull request #4659 from freelawproject/4658-fix-update-react-an…
Browse files Browse the repository at this point in the history
…d-js-component-to-v4
  • Loading branch information
mlissner authored Nov 5, 2024
2 parents 417a674 + 857ef6d commit f340d11
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions cl/assets/react/DisclosureViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const TableMaker = (data: Data, key: string, is_admin: boolean) => {
<div className="table-responsive">
<h3>
{title}
<a href={`/api/rest/v3/${api_key}/?financial_disclosure__id=${disclosure_id}`}>
<a href={`/api/rest/v4/${api_key}/?financial_disclosure__id=${disclosure_id}`}>
<i className="fa fa-code gray pull-right" />
</a>
</h3>
Expand Down Expand Up @@ -236,7 +236,7 @@ const Thumb = (id: number, thumbnail: string, filepath: string) => {
<h3>
<span>
Download
<a href={`/api/rest/v3/financial-disclosures/${id}/`}>
<a href={`/api/rest/v4/financial-disclosures/${id}/`}>
<i className="fa fa-code gray pull-right" />
</a>
</span>
Expand Down
2 changes: 1 addition & 1 deletion cl/assets/react/TagList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const TagList: React.FC<UserState> = ({ userId, userName, isPageOwner }) => {

const getTags = React.useCallback(
async (key: string, page = 1) =>
await appFetch(`/api/rest/v3/tags/?user=${userId}&page=${page}&page_size=10&order_by=name`),
await appFetch(`/api/rest/v4/tags/?user=${userId}&page=${page}&page_size=10&order_by=name`),
[]
);
const {
Expand Down
4 changes: 2 additions & 2 deletions cl/assets/react/_disclosure_helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function isDescendant(parent: HTMLElement | null, child: HTMLElement | nu
export const fetchDisclosure = async (setData: any, parameters: any) => {
try {
const response: boolean | Query = await appFetch(
`/api/rest/v3/financial-disclosures/?person=${parameters['judge_id']}&id=${parameters['disclosure_id']}`
`/api/rest/v4/financial-disclosures/?person=${parameters['judge_id']}&id=${parameters['disclosure_id']}`
);
if (typeof response != 'boolean') {
const result = response['results'][0];
Expand Down Expand Up @@ -63,7 +63,7 @@ export const convertTD = (value: string | number, table: string, key: string) =>
const fetchData = async (query: string, setData: (arg0: Row[]) => void) => {
try {
const response: boolean | Query = await appFetch(
`/api/rest/v3/disclosure-typeahead/?fullname=${query}&page_size=5`
`/api/rest/v4/disclosure-typeahead/?fullname=${query}&page_size=5`
);
if (typeof response != 'boolean') {
const results: Row[] = response['results'];
Expand Down
14 changes: 7 additions & 7 deletions cl/assets/react/_useTags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const useTags = ({ docket, enabled, userId }: UseTagsProps) => {
const [textVal, setTextVal] = React.useState<string>('');

const getTags = React.useCallback(
async (key: string, page = 1) => await appFetch(`/api/rest/v3/tags/?user=${userId}&page=${page}`),
async (key: string, page = 1) => await appFetch(`/api/rest/v4/tags/?user=${userId}&page=${page}`),
[]
);

Expand All @@ -22,7 +22,7 @@ export const useTags = ({ docket, enabled, userId }: UseTagsProps) => {
let morePagesAvailable = true;
/* fetches all the tags associated to the given docket at once */
while (morePagesAvailable) {
const response = await appFetch(`/api/rest/v3/docket-tags/?docket=${docket}&tag__user=${userId}&page=${page}`);
const response = await appFetch(`/api/rest/v4/docket-tags/?docket=${docket}&tag__user=${userId}&page=${page}`);
(response as ApiResult<Association>).results.forEach((e) => associations.unshift(e));
const nextPage = (response as ApiResult<Association>).next;
if (!nextPage) morePagesAvailable = false;
Expand All @@ -36,7 +36,7 @@ export const useTags = ({ docket, enabled, userId }: UseTagsProps) => {

const postTag = React.useCallback(
async ({ name }: { name: string }) =>
await appFetch('/api/rest/v3/tags/', {
await appFetch('/api/rest/v4/tags/', {
method: 'POST',
body: { name },
}),
Expand All @@ -45,7 +45,7 @@ export const useTags = ({ docket, enabled, userId }: UseTagsProps) => {

const postAssoc = React.useCallback(
async ({ tag }: { tag: number }) =>
await appFetch('/api/rest/v3/docket-tags/', {
await appFetch('/api/rest/v4/docket-tags/', {
method: 'POST',
body: { tag, docket },
}),
Expand All @@ -54,7 +54,7 @@ export const useTags = ({ docket, enabled, userId }: UseTagsProps) => {

const deleteAssoc = React.useCallback(
async ({ assocId }: { assocId: number }) =>
await appFetch(`/api/rest/v3/docket-tags/${assocId}/`, {
await appFetch(`/api/rest/v4/docket-tags/${assocId}/`, {
method: 'DELETE',
}),
[]
Expand Down Expand Up @@ -183,7 +183,7 @@ export const updateTags = () => {
// Update our tag fields
const updateTag = React.useCallback(
async (tag: Tag) =>
await appFetch(`/api/rest/v3/tags/${tag.id}/`, {
await appFetch(`/api/rest/v4/tags/${tag.id}/`, {
method: 'PUT',
body: { ...tag },
}),
Expand All @@ -192,7 +192,7 @@ export const updateTags = () => {

const deleteTag = React.useCallback(
async (id: number) =>
await appFetch(`/api/rest/v3/tags/${id}/`, {
await appFetch(`/api/rest/v4/tags/${id}/`, {
method: 'DELETE',
}),
[]
Expand Down
4 changes: 2 additions & 2 deletions cl/corpus_importer/templates/ca_judges_input.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
{% block footer-scripts %}
{% include "includes/date_picker.html" %}
<script>
var array_forms = [['/api/rest/v3/schools/', '.school-select', 'name'],
['/api/rest/v3/courts/','.court-select', 'full_name']];
var array_forms = [['/api/rest/v4/schools/', '.school-select', 'name'],
['/api/rest/v4/courts/','.court-select', 'full_name']];
</script>
{% include "includes/select2.html" %}
{% endblock %}
Expand Down
2 changes: 1 addition & 1 deletion cl/favorites/static/js/tag-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ $(document).ready(function () {
untagOptionButtons.map((button) => {
button.addEventListener('click', (e) => {
e.preventDefault()
fetch('/api/rest/v3/docket-tags/' + button.dataset.id + '/', {
fetch('/api/rest/v4/docket-tags/' + button.dataset.id + '/', {
method: 'DELETE',
headers: { 'X-CSRFToken': token },
})
Expand Down
8 changes: 4 additions & 4 deletions cl/visualizations/static/js/scotus_map_new.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ $(document).ready(function () {
var setAuthorityIDs = function (id, cb) {
$.ajax({
method: 'GET',
url: '/api/rest/v3/search/',
url: '/api/rest/v4/search/',
data: {
q: 'cluster_id:' + id,
format: 'json',
Expand All @@ -24,7 +24,7 @@ $(document).ready(function () {
// We have the authority IDs, but we don't know how many
// are SCOTUS cases in the right date range.
method: 'GET',
url: '/api/rest/v3/search/',
url: '/api/rest/v4/search/',
data: {
q: dateFiledQ + ' AND id:(' + cache[id].authority_ids.join(' OR ') + ')',
court: 'scotus',
Expand All @@ -44,7 +44,7 @@ $(document).ready(function () {
cache[id]['citing_count'] = 0; // Set the default
$.ajax({
method: 'GET',
url: '/api/rest/v3/search/',
url: '/api/rest/v4/search/',
data: {
q: dateFiledQ + ' AND cites:(' + id + ')',
court: 'scotus',
Expand Down Expand Up @@ -119,7 +119,7 @@ $(document).ready(function () {
var params = getParamsForQuery(q);
return $.ajax({
method: 'GET',
url: '/api/rest/v3/search/',
url: '/api/rest/v4/search/',
data: params,
success: function (data) {
return async(data.results);
Expand Down

0 comments on commit f340d11

Please sign in to comment.